using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using Pub_Class;
|
|
namespace APSM
|
{
|
public partial class Sc_ICMOSortCloseBill : Form
|
{
|
public Sc_ICMOSortCloseBill()
|
{
|
InitializeComponent();
|
}
|
|
//¶¨Òå
|
public const Int16 HTagCol = 0;
|
public const Int16 HSnoCol = 1;
|
public const Int16 HSourceIDCol = 2;
|
public const Int16 HSourceNumberCol = 3;
|
public const Int16 HSourceNameCol = 4;
|
public const Int16 HCheckCol = 5;
|
public const Int16 HRemarkCol = 6;
|
//
|
public string ModName = "Sc_ICMOSortCloseBill";
|
public string ModCaption = "";
|
ClsGridViewSum oSumGrid = new ClsGridViewSum();
|
|
public DAL.ClsSc_ICMOSortCloseBill BillNew = new DAL.ClsSc_ICMOSortCloseBill();
|
|
|
//±£´æµ¥¾Ý
|
private bool Sub_SaveBill()
|
{
|
Model.ClsSc_ICMOSortCloseBillMain oBillSub = new Model.ClsSc_ICMOSortCloseBillMain();
|
Int32 i;
|
bool bResult;
|
BillNew = new DAL.ClsSc_ICMOSortCloseBill();
|
//ʧȥ½¹µã
|
//lblCaption.Focus();
|
this.label4.Focus();
|
//if (!Sub_AllowSave())//µ¥¾ÝÍêÕûÐÔÅжÏ
|
// return false;
|
//Ã÷ϸÀำֵ
|
int col = Fun_GetCol("È·ÈÏ");
|
BillNew.DetailColl = new List<Model.ClsSc_ICMOSortCloseBillMain>();
|
for (i = 0; i <= grdMain.RowCount - 1; i++)
|
{
|
if (ClsPub.isLong(grdMain.Rows[i].Cells[HSourceIDCol].Value) != 0)
|
{
|
Model.ClsSc_ICMOSortCloseBillMain oSub = new Model.ClsSc_ICMOSortCloseBillMain();
|
//oSub.HEntryID = i + 1;
|
//
|
oSub.HBillType = "3733";
|
oSub.HSourceID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSourceIDCol].Value);
|
oSub.HDeptID = DBUtility.ClsPub.isLong(this.txtHDeptID.Tag);
|
oSub.HDate = this.dtpHDate.Value;
|
if (DBUtility.ClsPub.isBool( grdMain.Rows[i].Cells[col].Value) == true)
|
{
|
oSub.HMaker = ClsPub.CurUserName;
|
oSub.HMakeDate = DateTime.Today.ToString();
|
}
|
else
|
{
|
oSub.HMaker = "";
|
oSub.HMakeDate ="";
|
}
|
oSub.HRemark = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HRemarkCol].Value);
|
BillNew.DetailColl.Add(oSub);
|
}
|
}
|
bResult=BillNew.AddBill(this.dtpHDate.Value, DBUtility.ClsPub.isLong(this.txtHDeptID.Tag), ref ClsPub.sExeReturnInfo);
|
//Ìáʾ
|
if (bResult == true)
|
{
|
MessageBox.Show("µ¥¾Ý´æÅÌÍê±Ï!", "Ìáʾ");
|
return true;
|
}
|
else
|
{
|
MessageBox.Show("±£´æÊ§°Ü!ÔÒò:" + ClsPub.sExeReturnInfo, "Ìáʾ");
|
return false;
|
}
|
}
|
|
//³õʼ»¯GRID
|
private void initGrid()
|
{
|
grdMain.ColumnCount = 7; //×ÜÁÐÊý
|
this.Text = ModCaption;
|
oSumGrid.NoCol = HSnoCol;
|
oSumGrid.ogrdMain = grdMain;
|
oSumGrid.oGridsum = grdSum;
|
//
|
DataGridViewCheckBoxColumn newColumn = new DataGridViewCheckBoxColumn();
|
newColumn.HeaderText = "È·ÈÏ";
|
grdMain.Columns.Add(newColumn);
|
//ÉèÖÿɱà¼ÁÐ
|
string sAllowCol = HCheckCol.ToString() +
|
",7," + HRemarkCol.ToString();
|
//ÉèÖúϼÆÁÐ
|
string sTotalCol = HCheckCol.ToString();
|
//¸ñʽ»¯Íø¸ñ
|
DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid);
|
//
|
|
DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
|
grdMain.Columns[HSourceIDCol].HeaderText = "Éú²ú×ÊÔ´ID";
|
grdMain.Columns[HSourceNumberCol].HeaderText = "Éú²ú×ÊÔ´´úÂë";
|
grdMain.Columns[HSourceNameCol].HeaderText = "Éú²ú×ÊÔ´Ãû³Æ";
|
grdMain.Columns[HCheckCol].HeaderText = "È·ÈÏ1";
|
grdMain.Columns[HSnoCol].HeaderText = "ÐòºÅ";
|
grdMain.Columns[HRemarkCol].HeaderText = "±¸×¢";
|
//¸ñʽ»¯
|
grdMain.Columns[HTagCol].Visible = false; //Òþ²ØÁÐ
|
grdMain.Columns[HSourceIDCol].Visible = false;
|
grdMain.Columns[HCheckCol].Visible = false;
|
|
|
//ÉèÖúϼÆÁÐ
|
//
|
ClsPub.GetGridView(grdMain, this.Name, ClsPub.AppPath);
|
}
|
|
private void cmdHDeptID_Click(object sender, EventArgs e)
|
{
|
DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View();
|
if (oDept.RefreshView())
|
{
|
this.txtHDeptID.Text = oDept.oModel.HName;
|
this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString();
|
FillSelectData();
|
}
|
else
|
{
|
this.txtHDeptID.Text = "";
|
}
|
}
|
//
|
private void FillSelectData()
|
{
|
initGrid();
|
DataSet Ds;
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
//µÃµ½ÐÅÏ¢
|
Ds = oCn.RunProcReturn("select a.hitemid,a.hnumber,a.hname from Gy_Source a left join Gy_WorkCenter b on a.hcenterid=b.hitemid where b.hdeptid=" + this.txtHDeptID.Tag, "h_v_Sc_ICMOSortBillList_Source");
|
//дÈëÐÅÏ¢
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
Sub_WriteInForm(Ds.Tables[0], i);
|
}
|
|
}
|
//¸ù¾ÝTABLEдÈë½çÃæ
|
private void Sub_WriteInForm(DataTable oTable, int i)
|
{
|
grdMain.Rows[i].Cells[HTagCol].Value = "*";
|
grdMain.Rows[i].Cells[HSnoCol].Value = i+1;
|
grdMain.Rows[i].Cells[HSourceIDCol].Value = ClsPub.isLong(oTable.Rows[i]["hitemid"]);
|
grdMain.Rows[i].Cells[HSourceNumberCol].Value = ClsPub.isStrNull(oTable.Rows[i]["hnumber"]);
|
grdMain.Rows[i].Cells[HSourceNameCol].Value = ClsPub.isStrNull(oTable.Rows[i]["hname"]);
|
//
|
}
|
//
|
private void bc_Click(object sender, EventArgs e)
|
{
|
Sub_SaveBill();
|
}
|
//
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
initGrid();
|
}
|
//
|
private Int32 Fun_GetCol(string sCol)
|
{
|
for (int c = 0; c < grdMain.ColumnCount; c++)
|
{
|
if (ClsPub.isStrNull(grdMain.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper())
|
{
|
return c;
|
}
|
}
|
return 0;
|
}
|
//
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void Sc_ICMOSortCloseBill_Load(object sender, EventArgs e)
|
{
|
|
}
|
|
private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
|
{
|
int i = grdMain.CurrentCell.ColumnIndex;
|
if (DBUtility.Xt_BaseBillFun.AllowEdit(true, oSumGrid, i))
|
{
|
e.Cancel = true;
|
}
|
}
|
|
private void Sc_ICMOSortCloseBill_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
Pub_Class.ClsPub.SaveGridView(grdMain, this.Name, ClsPub.AppPath);
|
}
|
}
|
}
|