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 BaseSet { public partial class Gy_WorkShift : Form { public Gy_WorkShift() { InitializeComponent(); } //定义 public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HSno2Col = 2; public const Int16 HStartDateCol = 3; public const Int16 HEndDateCol = 4; public const Int16 HOverDayCol = 5; public const string ModName = "3701"; public const string ModCaption = "班次表"; public bool BillChange; // public Pub_Class.ClsPub.Enum_BillStatus BillStatus; public Int64 KeyID; public bool grdStatus; DAL.ClsGy_WorkShift_Ctl BillNew = new DAL.ClsGy_WorkShift_Ctl(); public DAL.ClsGy_WorkShift_Ctl BillOld = new DAL.ClsGy_WorkShift_Ctl(); ClsGridViewSum oSumGrid = new ClsGridViewSum(); //------------------------------------------------------------------------- #region 固定代码 private void Total() { oSumGrid.Total(); } //清空界面 public void Sub_ClearBill() { //清空界面控件 for 控件 foreach (Control ct in gbUp.Controls) { switch (ct.GetType().Name) { case "ListBox": ((ListBox)ct).Items.Clear(); break; case "CheckBox": ((CheckBox)ct).Checked = false; break; case "RadioButton": break; case "ComboBox": ((ComboBox)ct).SelectedIndex = 0; break; case "TextBox": ((TextBox)ct).Text = ""; break; case "DateTimePicker": ((DateTimePicker)ct).Value = DateTime.Today; break; default: break; } } // txtHMaker.Text = ClsPub.CurUserName; txtHMakeDate.Text = ""; txtHChecker.Text = ""; txtHCheckDate.Text = ""; txtHCloseMan.Text = ""; txtHCloseDate.Text = ""; txtHDeleteMan.Text = ""; txtHDeleteDate.Text = ""; txtHUpDater.Text = ""; txtHUpDateDate.Text = ""; initGrid(); } //编辑单据 private void Sub_EditBill() { this.BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify; this.Sub_OperStatus(); txtHUpDater.Text = ClsPub.CurUserName; txtHName.Enabled = false; } //删除单据 private void Sub_DeleteBill() { if (MessageBox.Show("确定要删除当前单据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { if (BillOld.DeleteBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) != true) { BillChange = true; MessageBox.Show("删除失败,原因:" + ClsPub.sExeReturnInfo, "提示"); return; } MessageBox.Show("删除成功", "提示"); BillOld = new DAL.ClsGy_WorkShift_Ctl(); if (BillOld.omodel.HInterID == 0)//若找不到上一张,清空 { this.Sub_ClearBill(); } BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_View; this.Sub_OperStatus(); } } private void bclk_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } private void mrlk_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); } //离开单元格 private void grdMain_LeaveCell(object sender, EventArgs e) { oSumGrid.LeaveCell(); } //网格单元格变化事件 private void grdMain_RowColChange(object sender, EventArgs e) { if (!grdStatus) { return; } // oSumGrid.SetGridsum(); oSumGrid.Total(); // //if (oSumGrid.Changelock) // return; //if(oSumGrid.EditStatus) //{ if (!CheckGridRow(oSumGrid.OldCell.Row)) return; //} } //放弃 编辑 private void Sub_AbandonBill() { //if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew || BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify) //{ // if (MessageBox.Show("单据尚未保存,是否放弃?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) // { // //显示第一张单据 // this.Sub_First(); // } //} } private void Gy_WorkShift_Paint(object sender, PaintEventArgs e)//画线 { Graphics g = this.panel2.CreateGraphics(); Pen p = new Pen(Color.Gray); p.Width = 1; g.DrawLine(p, new Point(txtHMaker.Left, txtHMaker.Top + txtHMaker.Height), new Point(txtHMaker.Left + txtHMaker.Width, txtHMaker.Top + txtHMaker.Height)); g.DrawLine(p, new Point(txtHMakeDate.Left, txtHMakeDate.Top + txtHMakeDate.Height), new Point(txtHMakeDate.Left + txtHMakeDate.Width, txtHMakeDate.Top + txtHMakeDate.Height)); // g.DrawLine(p, new Point(txtHChecker.Left, txtHChecker.Top + txtHChecker.Height), new Point(txtHChecker.Left + txtHChecker.Width, txtHChecker.Top + txtHChecker.Height)); g.DrawLine(p, new Point(txtHCheckDate.Left, txtHCheckDate.Top + txtHCheckDate.Height), new Point(txtHCheckDate.Left + txtHCheckDate.Width, txtHCheckDate.Top + txtHCheckDate.Height)); // g.DrawLine(p, new Point(txtHCloseMan.Left, txtHCloseMan.Top + txtHCloseMan.Height), new Point(txtHCloseMan.Left + txtHCloseMan.Width, txtHCloseMan.Top + txtHCloseMan.Height)); g.DrawLine(p, new Point(txtHCloseDate.Left, txtHCloseDate.Top + txtHCloseDate.Height), new Point(txtHCloseDate.Left + txtHCloseDate.Width, txtHCloseDate.Top + txtHCloseDate.Height)); // g.DrawLine(p, new Point(this.txtHDeleteMan.Left, txtHDeleteMan.Top + txtHDeleteMan.Height), new Point(txtHDeleteMan.Left + txtHDeleteMan.Width, txtHDeleteMan.Top + txtHDeleteMan.Height)); g.DrawLine(p, new Point(txtHDeleteDate.Left, txtHDeleteDate.Top + txtHDeleteDate.Height), new Point(txtHDeleteDate.Left + txtHDeleteDate.Width, txtHDeleteDate.Top + txtHDeleteDate.Height)); // g.DrawLine(p, new Point(this.txtHUpDater.Left, txtHUpDater.Top + txtHUpDater.Height), new Point(txtHUpDater.Left + txtHUpDater.Width, txtHUpDater.Top + txtHUpDater.Height)); g.DrawLine(p, new Point(txtHUpDateDate.Left, txtHUpDateDate.Top + txtHUpDateDate.Height), new Point(txtHUpDateDate.Left + txtHUpDateDate.Width, txtHUpDateDate.Top + txtHUpDateDate.Height)); //控件位置设置 } //控件位置 private void Sub_ControlLocation() { } //窗体加载 private void Gy_WorkShift_Load(object sender, EventArgs e) { //打印初始化 oSumGrid.NoCol = HSnoCol; oSumGrid.ogrdMain = grdMain; oSumGrid.oGridsum = grdSum; this.Text = ModCaption; //命名窗体标题 this.lblCaption.Text = ModCaption;//命名单据标题 } //新增按纽 private void xz_Click(object sender, EventArgs e) { this.Sub_AddBill(); } //修改按纽 private void xg_Click(object sender, EventArgs e) { this.Sub_EditBill(); } //删除按钮 private void sc_Click(object sender, EventArgs e) { this.Sub_DeleteBill(); } //保存按钮 private void bc_Click(object sender, EventArgs e) { this.Sub_SaveBill(); } //放弃按钮 private void fq_Click(object sender, EventArgs e) { this.Sub_AbandonBill(); } //退出按钮 private void tc_Click(object sender, EventArgs e) { this.Close(); } //窗体尺寸变化时 private void Gy_WorkShift_Resize(object sender, EventArgs e) { Sub_ControlLocation(); } //根据编辑状态 设置 控件是否允许录入 private void Sub_LrtextStatus(bool TextEnabled) { if (TextEnabled == true) { //控件全部有效 gbUp.Enabled = true; grdMain.BackColor = ClsPub.EditColor; } else { //控件全部无效 gbUp.Enabled = false; grdMain.BackColor = ClsPub.ViewColor; } } //复制单据 private void Sub_CopyBill() { this.BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew; this.Sub_OperStatus();//设置TOOLBAR this.txtHName.Text = ClsPub.CreateBillCode(BillNew.MvarItemKey, ref ClsPub.sExeReturnInfo, true);//得到新单号 this.txtHName.Enabled = true; this.txtHName.Focus(); this.txtHMaker.Text = ClsPub.CurUserName; this.txtHMakeDate.Text = ClsPub.GetServerDate(-1); this.txtHChecker.Text = ""; this.txtHCloseDate.Text = ""; this.txtHCloseMan.Text = ""; this.txtHCloseDate.Text = ""; this.txtHDeleteMan.Text = ""; this.txtHDeleteDate.Text = ""; this.txtHUpDater.Text = ""; this.txtHUpDateDate.Text = ""; } //复制按钮 private void fz_Click(object sender, EventArgs e) { Sub_CopyBill(); } //timer private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; Sub_ControlLocation(); if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_View) { this.Sub_ShowBill(); } else { this.Sub_AddBill(); } oSumGrid.SetGridsum(); } //窗体卸载 private void Gy_WorkShift_FormClosing(object sender, FormClosingEventArgs e) { BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew; DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name); } //新增单据 private void Sub_AddBill() { this.BillNew = new DAL.ClsGy_WorkShift_Ctl(); this.BillOld = new DAL.ClsGy_WorkShift_Ctl(); this.BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew; this.Sub_OperStatus();//设置TOOLBAR this.Sub_ClearBill();//清空界面 //this.txtHName.Text = ClsPub.CreateBillCode(BillNew.MvarItemKey, ref ClsPub.sExeReturnInfo, true);//得到新单号(缺少函数) 未完成 this.txtHName.Enabled = true; this.txtHName.Focus(); } //TOOLBAR状态 按钮是否灰度 public void Sub_OperStatus() { switch (BillStatus) { case Pub_Class.ClsPub.Enum_BillStatus.BillStatus_View: //浏览状态 yl.Enabled = true; xz.Enabled = true; xg.Enabled = true; sc.Enabled = true; AddRow.Enabled = false; DelRow.Enabled = false; bc.Enabled = false; fq.Enabled = false; tc.Enabled = true; fz.Enabled = true; //未审核 if (txtHChecker.Text.Trim() == "") { xg.Enabled = true; sc.Enabled = true; //未审核 pic1.Visible = false; pic1.Image = null; // } else if (txtHCloseMan.Text.Trim() == "" && txtHChecker.Text.Trim() != "")//审核未关闭 { xg.Enabled = false; sc.Enabled = false; // pic1.Visible = true; pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Checked.jpg"); // } else//已关闭 { xg.Enabled = false; sc.Enabled = false; // pic1.Visible = true; pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Closed.jpg"); // } if (txtHDeleteMan.Text.Trim() == "") { } else //已作废 { xg.Enabled = false; sc.Enabled = false; AddRow.Enabled = false; DelRow.Enabled = false; bc.Enabled = false; fq.Enabled = false; // pic1.Visible = true; pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Deleted.jpg"); // } Sub_LrtextStatus(false); grdStatus = false; break; case Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew: //新增状态 yl.Enabled = false; xz.Enabled = false; xg.Enabled = false; sc.Enabled = false; AddRow.Enabled = true; DelRow.Enabled = true; bc.Enabled = true; fq.Enabled = true; tc.Enabled = true; Sub_LrtextStatus(true); grdStatus = true; fz.Enabled = false; //未审核 pic1.Visible = false; pic1.Image = null; // break; case Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify: //修改状态 yl.Enabled = false; xz.Enabled = false; xg.Enabled = false; sc.Enabled = false; AddRow.Enabled = true; DelRow.Enabled = true; bc.Enabled = true; fq.Enabled = true; tc.Enabled = true; Sub_LrtextStatus(true); grdStatus = true; fz.Enabled = false; //未审核 pic1.Visible = false; pic1.Image = null; // break; } } #endregion #region 读写类 //显示单据 public void Sub_ShowBill() { DAL.ClsGy_WorkShift_View oWorkShift = new DAL.ClsGy_WorkShift_View(); DAL.ClsIF_Source_View oSource = new DAL.ClsIF_Source_View(); DAL.ClsIF_Department_View oDept = new DAL.ClsIF_Department_View(); //判断是否存在单据 if(BillOld.ShowBill(BillOld.omodel.HInterID,ref ClsPub.sExeReturnInfo)==false ) { MessageBox.Show(ClsPub.sExeReturnInfo, "提示"); return; } //清空 Sub_ClearBill(); //grid禁止刷新 //加载表头 this.txtHRemark.Text = BillOld.omodel.HRemark; this.txtHNumber.Text = BillOld.omodel.HNumber; this.txtHName.Text = BillOld.omodel.HName; this.txtHNote.Text = BillOld.omodel.HNote; this.txtHWorkTimes.Text = BillOld.omodel.HWorkTimes.ToString(); if (BillOld.omodel.HStopflag) chkHStopflag.Checked = true; else chkHStopflag.Checked = false; if (oDept.GetInfoByID(BillOld.omodel.HDeptID)) { this.txtHDeptID.Tag = oDept.omodel.HItemID.ToString().Trim(); this.txtHDeptID.Text = oDept.omodel.HName; } else { this.txtHDeptID.Text = ""; } //加载表体 int i = 0; foreach (Model.ClsGy_WorkShiftSub oSub in BillOld.DetailColl) { if (i >= grdMain.RowCount - 1) grdMain.Rows.Add(); grdMain.Rows[i].Cells[HTagCol].Value = "*"; grdMain.Rows[i].Cells[HSno2Col].Value = oSub.HSno.ToString(); grdMain.Rows[i].Cells[HStartDateCol].Value = oSub.HStartDate.ToShortTimeString(); grdMain.Rows[i].Cells[HEndDateCol].Value = oSub.HEndDate.ToShortTimeString(); grdMain.Rows[i].Cells[HOverDayCol].Value = oSub.HOverDay; i = i + 1; } //GRID允许刷新 DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); //合计 Total(); // Sub_OperStatus(); } //单据完整性判断 未完成 private bool Sub_AllowSave() { //必输项目是否为空 if (txtHNumber.Text.Trim() == "") { MessageBox.Show("班次代码不能为空!"); return false; } if (txtHName.Text.Trim() == "") { MessageBox.Show("班次名称不能为空!"); return false; } //单据号是否重复 //明细表是否为零行 return true; } //保存单据 private bool Sub_SaveBill() { Model.ClsGy_WorkShiftSub oBillSub = new Model.ClsGy_WorkShiftSub(); Int32 i; bool bResult; this.lblCaption.Focus(); BillNew = new DAL.ClsGy_WorkShift_Ctl(); if (!Sub_AllowSave())//单据完整性判断 return false; //赋值ID if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify) BillNew.omodel.HInterID = BillOld.omodel.HInterID; //主类赋值 BillNew.omodel.HNumber = this.txtHNumber.Text.Trim(); BillNew.omodel.HName = this.txtHName.Text.Trim(); BillNew.omodel.HNote = this.txtHNote.Text.Trim(); BillNew.omodel.HRemark = this.txtHRemark.Text.Trim(); BillNew.omodel.HStopflag = ClsPub.isBool(this.chkHStopflag.Checked); BillNew.omodel.HDeptID = ClsPub.isLong(this.txtHDeptID.Tag.ToString()); BillNew.omodel.HWorkTimes = ClsPub.isDoule(this.txtHWorkTimes.Text); //明细类赋值 BillNew.DetailColl = new List(); for (i = 0; i <= grdMain.RowCount - 1; i++) { if (ClsPub.isStrNull(grdMain.Rows[i].Cells[HSno2Col].Value) != "") { Model.ClsGy_WorkShiftSub oSub = new Model.ClsGy_WorkShiftSub(); oSub.HEntryID = i; // oSub.HSno = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HSno2Col].Value); oSub.HStartDate = DBUtility.ClsPub.isDate(grdMain.Rows[i].Cells[HStartDateCol].Value); oSub.HEndDate = DBUtility.ClsPub.isDate(grdMain.Rows[i].Cells[HEndDateCol].Value); oSub.HOverDay = DBUtility.ClsPub.GridToBool(grdMain.Rows[i].Cells[HOverDayCol].Value); BillNew.DetailColl.Add(oSub); } } //保存完毕后处理 if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew) { bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo ); } else { bResult = BillNew.ModifyBill(BillNew.omodel.HInterID, ref ClsPub.sExeReturnInfo); } //提示 if (bResult == true) { BillChange = true; MessageBox.Show("单据存盘完毕!", "提示"); if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_AddNew) { this.Sub_AddBill(); } else if (BillStatus == Pub_Class.ClsPub.Enum_BillStatus.BillStatus_Modify ) { BillStatus = Pub_Class.ClsPub.Enum_BillStatus.BillStatus_View; } this.Sub_OperStatus(); return true; } else { MessageBox.Show("保存失败!原因:" + ClsPub.sExeReturnInfo, "提示"); return false; } } #endregion #region 窗体处理方法 //初始化GRID private void initGrid() { grdMain.ColumnCount = 6; //总列数 DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name); // grdMain.Columns[HSnoCol].HeaderText = "序号"; grdMain.Columns[HSno2Col].HeaderText = "次序号"; grdMain.Columns[HStartDateCol].HeaderText = "开始时间"; grdMain.Columns[HEndDateCol].HeaderText = "结束时间"; grdMain.Columns[HOverDayCol].HeaderText = "是否跨天"; // grdMain.Columns[HTagCol].Visible = false; // //设置可编辑列和合计列 string sAllowCol = HStartDateCol.ToString() + "," + HEndDateCol.ToString() + "," + HSno2Col.ToString() + "," + HOverDayCol.ToString(); //设置合计列 string sTotalCol = ""; //格式化网格 // DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); //网格打勾 for (int i = 0; i < grdMain.Rows.Count; i++) { DataGridViewCheckBoxCell oCell = new DataGridViewCheckBoxCell(); oCell.ThreeState = false; oCell.Value = 0; oCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; grdMain.Rows[i].Cells[HOverDayCol] = oCell; } } //公式重算 private void RowCount(int sRow, int sTag) { if (sTag == 0) { } else { //单价列=金额/数量 double sMoney = 0; } } //增行按钮 未完成 private void AddRow_Click(object sender, EventArgs e) { oSumGrid.Sub_AddRow(); } //删行按纽 未完成 private void DelRow_Click(object sender, EventArgs e) { oSumGrid.Sub_DelRow(); } //选择 部门按钮 //选择班组 //核对选择的内容 public bool CheckGridCell(Cell oCell) { int Row; int Col; Row = oCell.Row; Col = oCell.Col; //if (ClsPub.isStrNull(grdMain.get_TextMatrix(Row, HTagCol)) != "*") //{ // return true; //} //判断选中列 //if (Col == HCheckItemIDCol) //单位ID列 //{ //} //else //其他列 //{ //} // return true; } //是否是空行 private bool IsNullRow(int Row) { if (ClsPub.isLong(grdMain.Rows[Row].Cells[HSnoCol].Value) == 0) { return true; } return false; } //'判断网格行的录入是否正确 private bool CheckGridRow(int Row) { Cell oCell = new Cell(); int c = 0; //for (c = 0; c < grdMain.ColumnCount; c++) //{ // oCell.Row = Row; // oCell.Col = c; // //if (!CheckGridCell(oCell)) // // return false; //} return true; } private void Sub_GridKey(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit) { if (!grdStatus) { return; } oSumGrid.EditStatus = true; switch (sKeyCode) { case 118: //F7 { switch (sCol) { default: break; } break; } case 117: //F6 { switch (sCol) { default: break; } break; } default: break; } } //选原单 private void cmdSourceBillNo_Click(object sender, EventArgs e) { //if (cmbSourceBillType.Text.Trim() == "") //{ // Cls_S_Gy_WorkShift oWorkTimesBill = new Cls_S_Gy_WorkShift(); // if (oWorkTimesBill.Refresh()) //选择原单 // { // FillSelectData(oWorkTimesBill.oBillSelectColl); // } //} //else //{ //} } // private void FillSelectData(List oList) { //DataSet Ds; //ClsCN oCn = new ClsCN(); //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone; //oSumGrid.Changelock = true; //initGrid(); //int i = grdMain.FixedRows - 1; //foreach (BillSelect oSelectRow in oList) //{ // i = i + 1; // if (oSelectRow.BillType == "1201") // { // grdMain.AddItem("", grdMain.Rows - 1); // grdMain.set_TextMatrix(i, HTagCol, "*"); // //得到信息 // Ds = oCn.RunProcReturn("select * from h_v_Gy_WorkShiftList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_Gy_WorkShiftList"); // //写入信息 // Sub_WriteInForm(Ds.Tables[0], i); // } //} //// //oSumGrid.Changelock = false; //oSumGrid.Total(); //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDBuffered; } //根据TABLE写入界面 private void Sub_WriteInForm(DataTable oTable, int i) { ////加载表头 //this.txtHDeptID.Tag = oTable.Rows[0]["部门ID"].ToString(); //this.txtHDeptID.Text = oTable.Rows[0]["部门"].ToString(); //this.txtHCurID.Text = oTable.Rows[0]["班组"].ToString(); //this.txtHCurID.Tag = oTable.Rows[0]["班组ID"].ToString(); ////加载表体 //grdMain.set_TextMatrix(i, HTagCol, "*"); //grdMain.set_TextMatrix(i, HMaterIDCol, oTable.Rows[0]["职员ID"].ToString()); //grdMain.set_TextMatrix(i, HMaterNameCol, oTable.Rows[0]["职员"].ToString()); //grdMain.set_TextMatrix(i, HRemarkCol, oTable.Rows[0]["表体备注"].ToString()); //grdMain.set_TextMatrix(i, HPriceCol, oTable.Rows[0]["上午"].ToString()); //grdMain.set_TextMatrix(i, HQtyCol, oTable.Rows[0]["下午"].ToString()); //grdMain.set_TextMatrix(i, HTaxRateCol, oTable.Rows[0]["加班工时"].ToString()); //grdMain.set_TextMatrix(i, HMoneyCol, oTable.Rows[0]["基本工时"].ToString()); //// //grdMain.set_TextMatrix(i, HSourceInterIDCol, oTable.Rows[0]["hmainid"].ToString()); //grdMain.set_TextMatrix(i, HSourceEntryIDCol, oTable.Rows[0]["hsubid"].ToString()); //grdMain.set_TextMatrix(i, HSourceBillTypeCol, oTable.Rows[0]["hbilltype"].ToString()); } #endregion private void cmdHDeptID_Click(object sender, EventArgs e) { DAL.ClsIF_Department_View oDept = new DAL.ClsIF_Department_View(); if (oDept.RefreshView()) { txtHDeptID.Text = oDept.oModel.HName; txtHDeptID.Tag = oDept.oModel.HItemID; } else { txtHDeptID.Text = ""; } } DataGridViewTextBoxEditingControl EditingControl; private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { int i = grdMain.CurrentCell.ColumnIndex; if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid, i)) { e.Cancel = true; } } private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); RowCount(e.RowIndex, 0); //计算 金额 单价 // if (this.EditingControl != null) //释放事件 { EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown); this.EditingControl = null; } } private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e) { // if (!grdStatus) { return; } DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // if (!CheckGridRow(oSumGrid.OldCell.Row)) return; } private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (grdMain.CurrentCell != null) { if (e.Control is DataGridViewTextBoxEditingControl) { this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control; //增加委托处理 this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown); } } } private void EditingControl_KeyDown(object sender, KeyEventArgs e) { //业务处理 Sub_GridKey(e.KeyValue, grdMain.CurrentRow.Index, grdMain.CurrentCell.ColumnIndex, EditingControl); } private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); } private void grdMain_Scroll(object sender, ScrollEventArgs e) { DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); oSumGrid.DisplayCurRow(); } } }