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_ICMOSortBillDlg_Group : Form 
 | 
    { 
 | 
        public Sc_ICMOSortBillDlg_Group() 
 | 
        { 
 | 
            InitializeComponent(); 
 | 
        } 
 | 
        //¶¨Òå 
 | 
        public const Int16 HTagCol = 0; 
 | 
        public const Int16 HSnoCol = 1; 
 | 
        // 
 | 
        public const Int16 HEmpIDCol = 2; 
 | 
        public const Int16 HEmpNumberCol = 3; 
 | 
        public const Int16 HEmpNameCol = 4; 
 | 
        // 
 | 
        public bool grdStatus = true; 
 | 
        ClsGridViewSum oSumGrid = new ClsGridViewSum(); 
 | 
        public DAL.ClsSc_ICMOSortBill_Group BillNew = new DAL.ClsSc_ICMOSortBill_Group(); 
 | 
        public DAL.ClsSc_ICMOSortBill_Group BillOld = new DAL.ClsSc_ICMOSortBill_Group(); 
 | 
        // 
 | 
        public long HICMOInterID; 
 | 
        public string HICMOBillNo; 
 | 
        public long HMaterID; 
 | 
        public long HSourceID; 
 | 
        public long HGroupID; 
 | 
        public string HSplitNO; 
 | 
  
 | 
  
 | 
        private void Sc_ICMOSortBillDlg_Group_Load(object sender, EventArgs e) 
 | 
        { 
 | 
            oSumGrid.NoCol = HSnoCol; 
 | 
            oSumGrid.ogrdMain = grdMain; 
 | 
            initGrid(); 
 | 
            Sub_ShowBill(); 
 | 
        } 
 | 
  
 | 
        //³õʼ»¯GRID 
 | 
        private void initGrid() 
 | 
        { 
 | 
            grdMain.ColumnCount = 5;                       //×ÜÁÐÊý 
 | 
            DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name + "Group"); 
 | 
            grdMain.Columns[HEmpIDCol].HeaderText = "Ö°Ô±ID"; 
 | 
            grdMain.Columns[HEmpNumberCol].HeaderText = "Ö°Ô±´úÂë"; 
 | 
            grdMain.Columns[HEmpNameCol].HeaderText = "Ö°Ô±Ãû³Æ"; 
 | 
            grdMain.Columns[HSnoCol].HeaderText = "ÐòºÅ"; 
 | 
            //¸ñʽ»¯  
 | 
            grdMain.Columns[HTagCol].Visible = false;                           //Òþ²ØÁÐ 
 | 
            grdMain.Columns[HEmpIDCol].Visible = false; 
 | 
  
 | 
            //ÉèÖÿɱà¼ÁÐ 
 | 
            string sAllowCol = HEmpNumberCol.ToString(); 
 | 
            //ÉèÖúϼÆÁÐ 
 | 
            string sTotalCol = HTagCol.ToString(); 
 | 
            // 
 | 
            DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid); 
 | 
        } 
 | 
  
 | 
        //ÔöÐа´Å¥   
 | 
        private void AddRow_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            DBUtility.Xt_BaseBillFun.AddRow(oSumGrid); 
 | 
        } 
 | 
        //ɾÐа´Å¦   
 | 
        private void DelRow_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            DBUtility.Xt_BaseBillFun.DelRow(oSumGrid); 
 | 
        } 
 | 
        private void bclk_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            //±£´æÁпí 
 | 
            ClsPub.SaveGridView(grdMain, this.Name,ClsPub.AppPath); 
 | 
        } 
 | 
        private void mrlk_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name); 
 | 
        } 
 | 
  
 | 
  
 | 
        //ÊÇ·ñÊÇ¿ÕÐÐ 
 | 
        private bool IsNullRow(int Row) 
 | 
        { 
 | 
            return DBUtility.Xt_BaseBillFun.IsNullRow(Row, HEmpIDCol, grdMain); 
 | 
        } 
 | 
        //'ÅжÏÍø¸ñÐеļÈëÊÇ·ñÕýÈ· 
 | 
        private bool CheckGridRow(int Row) 
 | 
        { 
 | 
            Cell oCell = new Cell(); 
 | 
            int c = 0; 
 | 
            //if (ClsPub.isStrNull(grdMain.get_TextMatrix(Row, HTagCol)) != "*") 
 | 
            //{ 
 | 
            //    return true; 
 | 
            //} 
 | 
            // 
 | 
            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) 
 | 
        { 
 | 
            DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); 
 | 
            if (!grdStatus) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
            //if (oSumGrid.FindAllowEditCol(sCol)) 
 | 
            //{ 
 | 
            oSumGrid.EditStatus = true; 
 | 
            //} 
 | 
            //else 
 | 
            //{ 
 | 
            //    return; 
 | 
            //} 
 | 
            switch (sKeyCode) 
 | 
            { 
 | 
                case 118:          //F7 
 | 
                    { 
 | 
                        switch (sCol) 
 | 
                        { 
 | 
                            case HEmpNumberCol: 
 | 
                                oEmp.WherePart = ""; 
 | 
                                if (oEmp.RefreshView()) 
 | 
                                { 
 | 
                                    grdMain.Rows[sRow].Cells[HEmpIDCol].Value = oEmp.oModel.HItemID.ToString(); 
 | 
                                    grdMain.Rows[sRow].Cells[HEmpNumberCol].Value = oEmp.oModel.HNumber; 
 | 
                                    grdMain.Rows[sRow].Cells[HEmpNameCol].Value = oEmp.oModel.HName; 
 | 
                                } 
 | 
                                else 
 | 
                                { 
 | 
                                    grdMain.Rows[sRow].Cells[HEmpIDCol].Value = 0; 
 | 
                                    grdMain.Rows[sRow].Cells[HEmpNumberCol].Value = ""; 
 | 
                                    grdMain.Rows[sRow].Cells[HEmpNameCol].Value = ""; 
 | 
                                } 
 | 
                                break; 
 | 
                            default: 
 | 
                                break; 
 | 
                        } 
 | 
                        break; 
 | 
                    } 
 | 
                case 117:  //F6 
 | 
                    { 
 | 
                        switch (sCol) 
 | 
                        { 
 | 
  
 | 
  
 | 
                            default: 
 | 
                                break; 
 | 
                        } 
 | 
                        break; 
 | 
                    } 
 | 
                default: 
 | 
                    break; 
 | 
            } 
 | 
        } 
 | 
  
 | 
  
 | 
  
 | 
        //Íø¸ñ±à¼Ç°ÅÐ¶Ï 
 | 
        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; 
 | 
            } 
 | 
        } 
 | 
        DataGridViewTextBoxEditingControl EditingControl; 
 | 
  
 | 
        private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e) 
 | 
        { 
 | 
            // 
 | 
            if (!grdStatus) 
 | 
            { 
 | 
                return; 
 | 
            } 
 | 
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); 
 | 
            // 
 | 
            //if (oSumGrid.Changelock) 
 | 
            //    return; 
 | 
            //if(oSumGrid.EditStatus) 
 | 
            //{ 
 | 
            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 bc_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            Sub_SaveBill(); 
 | 
        } 
 | 
  
 | 
        private void fq_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            this.Close(); 
 | 
        } 
 | 
  
 | 
        private void tc_Click(object sender, EventArgs e) 
 | 
        { 
 | 
            this.Close(); 
 | 
        } 
 | 
         
 | 
        //±£´æµ¥¾Ý 
 | 
        private bool Sub_SaveBill() 
 | 
        { 
 | 
            Model.ClsSc_ICMOSortBill_GroupSub oBillSub = new Model.ClsSc_ICMOSortBill_GroupSub(); 
 | 
            Int32 i; 
 | 
            bool bResult; 
 | 
            BillNew = new DAL.ClsSc_ICMOSortBill_Group(); 
 | 
            //ʧȥ½¹µã 
 | 
            label1.Focus(); 
 | 
            //¸³ÖµID 
 | 
            //Ö÷Àำֵ 
 | 
            BillNew.omodel.HICMOInterID = ClsPub.isLong(this.txtHICMOBillNo.Tag); 
 | 
            BillNew.omodel.HICMOBillNo = ClsPub.isStrNull(this.txtHICMOBillNo.Text); 
 | 
            BillNew.omodel.HMaterID = ClsPub.isLong(this.txtHMaterNumber.Tag); 
 | 
            BillNew.omodel.HSourceID = ClsPub.isLong(this.txtHSourceNumber.Tag); 
 | 
            BillNew.omodel.HGroupID = ClsPub.isLong(this.txtHGroupNumber.Tag); 
 | 
            BillNew.omodel.HSplitNO = ClsPub.isStrNull(this.txtHSplitNO.Text); 
 | 
            // 
 | 
            //Ã÷ϸÀำֵ 
 | 
            BillNew.DetailColl = new List<Model.ClsSc_ICMOSortBill_GroupSub>(); 
 | 
            for (i = 0; i <= grdMain.RowCount - 1; i++) 
 | 
            { 
 | 
                if (ClsPub.isLong(grdMain.Rows[i].Cells[HEmpIDCol].Value) != 0) 
 | 
                { 
 | 
                    Model.ClsSc_ICMOSortBill_GroupSub oSub = new Model.ClsSc_ICMOSortBill_GroupSub(); 
 | 
                    // 
 | 
                    oSub.HEmpID = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HEmpIDCol].Value); 
 | 
                    // 
 | 
                    BillNew.DetailColl.Add(oSub); 
 | 
                } 
 | 
            } 
 | 
            //±£´æÍê±Ïºó´¦Àí 
 | 
            bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo); 
 | 
            //Ìáʾ 
 | 
            if (bResult == true) 
 | 
            { 
 | 
                MessageBox.Show("ÉèÖÃÖ°Ô±³É¹¦£¡", "Ìáʾ"); 
 | 
                return true; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                MessageBox.Show("ÉèÖÃʧ°Ü£¡ÔÒò:" + ClsPub.sExeReturnInfo, "Ìáʾ"); 
 | 
                return false; 
 | 
            } 
 | 
        } 
 | 
  
 | 
  
 | 
        //ÏÔʾµ¥¾Ý 
 | 
        public void Sub_ShowBill() 
 | 
        { 
 | 
            DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View(); 
 | 
            DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); 
 | 
            DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); 
 | 
            DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); 
 | 
            //ÅжÏÊÇ·ñ´æÔÚµ¥¾Ý 
 | 
            if (BillOld.ShowBill(HICMOInterID, HSplitNO, HSourceID, HGroupID, ref  ClsPub.sExeReturnInfo) == false) 
 | 
            { 
 | 
                GetEmpByGroup(); 
 | 
                return; 
 | 
            } 
 | 
            //Çå¿Õ 
 | 
            //grid½ûֹˢР 
 | 
            //¼ÓÔØ±íÍ· 
 | 
            //// 
 | 
            if (oMater.GetInfoByID(BillOld.omodel.HMaterID)) 
 | 
            { 
 | 
                this.txtHMaterNumber.Text = oMater.omodel.HNumber; 
 | 
                this.txtHMaterNumber.Tag = oMater.omodel.HItemID.ToString(); 
 | 
                this.txtHMaterName.Text = oMater.omodel.HName; 
 | 
                this.txtHMaterModel.Text = oMater.omodel.HModel; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                this.txtHMaterNumber.Tag = "0"; 
 | 
                this.txtHMaterNumber.Text = ""; 
 | 
                this.txtHMaterName.Text = ""; 
 | 
                this.txtHMaterModel.Text = ""; 
 | 
            } 
 | 
            // 
 | 
            if (oSource.GetInfoByID(BillOld.omodel.HSourceID)) 
 | 
            { 
 | 
                this.txtHSourceNumber.Text = oSource.omodel.HNumber; 
 | 
                this.txtHSourceNumber.Tag = oSource.omodel.HItemID.ToString(); 
 | 
                this.txtHSourceName.Text = oSource.omodel.HName; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                this.txtHSourceNumber.Text = ""; 
 | 
                this.txtHSourceNumber.Tag = "0"; 
 | 
                this.txtHSourceName.Text = ""; 
 | 
            } 
 | 
            // 
 | 
            if (oGroup.GetInfoByID(BillOld.omodel.HGroupID)) 
 | 
            { 
 | 
                this.txtHGroupNumber.Text = oGroup.omodel.HNumber; 
 | 
                this.txtHGroupNumber.Tag = oGroup.omodel.HItemID.ToString(); 
 | 
                this.txtHGroupName.Text = oGroup.omodel.HName; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                this.txtHGroupNumber.Text = ""; 
 | 
                this.txtHGroupNumber.Tag = "0"; 
 | 
                this.txtHGroupName.Text = ""; 
 | 
            } 
 | 
            this.txtHICMOBillNo.Tag = HICMOInterID.ToString(); 
 | 
            this.txtHICMOBillNo.Text = HICMOBillNo; 
 | 
            this.txtHSplitNO.Text = HSplitNO; 
 | 
            //¼ÓÔØ±íÌå 
 | 
            int i = 0; 
 | 
            foreach (Model.ClsSc_ICMOSortBill_GroupSub oSub in BillOld.DetailColl) 
 | 
            { 
 | 
                if (i >= grdMain.RowCount - 1) 
 | 
                    grdMain.Rows.Add(); 
 | 
                grdMain.Rows[i].Cells[HTagCol].Value = "*"; 
 | 
  
 | 
                grdMain.Rows[i].Cells[HEmpIDCol].Value = oSub.HEmpID.ToString(); 
 | 
                if (oEmp.GetInfoByID(oSub.HEmpID)) 
 | 
                { 
 | 
                    grdMain.Rows[i].Cells[HEmpNumberCol].Value = oEmp.omodel.HNumber; 
 | 
                    grdMain.Rows[i].Cells[HEmpNameCol].Value = oEmp.omodel.HName; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    grdMain.Rows[i].Cells[HEmpNumberCol].Value = ""; 
 | 
                    grdMain.Rows[i].Cells[HEmpNameCol].Value = ""; 
 | 
                } 
 | 
                i = i + 1; 
 | 
            } 
 | 
            //GRIDÔÊÐíˢР 
 | 
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); 
 | 
        } 
 | 
  
 | 
        public void GetEmpByGroup() 
 | 
        { 
 | 
            DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View(); 
 | 
            DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); 
 | 
            DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View(); 
 | 
            DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); 
 | 
  
 | 
            //// 
 | 
            if (oMater.GetInfoByID(HMaterID)) 
 | 
            { 
 | 
                this.txtHMaterNumber.Text = oMater.omodel.HNumber; 
 | 
                this.txtHMaterNumber.Tag = oMater.omodel.HItemID.ToString(); 
 | 
                this.txtHMaterName.Text = oMater.omodel.HName; 
 | 
                this.txtHMaterModel.Text = oMater.omodel.HModel; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                this.txtHMaterNumber.Tag = "0"; 
 | 
                this.txtHMaterNumber.Text = ""; 
 | 
                this.txtHMaterName.Text = ""; 
 | 
                this.txtHMaterModel.Text = ""; 
 | 
            } 
 | 
            // 
 | 
            if (oSource.GetInfoByID(HSourceID)) 
 | 
            { 
 | 
                this.txtHSourceNumber.Text = oSource.omodel.HNumber; 
 | 
                this.txtHSourceNumber.Tag = oSource.omodel.HItemID.ToString(); 
 | 
                this.txtHSourceName.Text = oSource.omodel.HName; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                this.txtHSourceNumber.Text = ""; 
 | 
                this.txtHSourceNumber.Tag = "0"; 
 | 
                this.txtHSourceName.Text = ""; 
 | 
            } 
 | 
            // 
 | 
            if (oGroup.GetInfoByID(HGroupID)) 
 | 
            { 
 | 
                this.txtHGroupNumber.Text = oGroup.omodel.HNumber; 
 | 
                this.txtHGroupNumber.Tag = oGroup.omodel.HItemID.ToString(); 
 | 
                this.txtHGroupName.Text = oGroup.omodel.HName; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                this.txtHGroupNumber.Text = ""; 
 | 
                this.txtHGroupNumber.Tag = "0"; 
 | 
                this.txtHGroupName.Text = ""; 
 | 
            } 
 | 
            this.txtHICMOBillNo.Tag = HICMOInterID.ToString(); 
 | 
            this.txtHICMOBillNo.Text = HICMOBillNo; 
 | 
            this.txtHSplitNO.Text = HSplitNO; 
 | 
            // 
 | 
  
 | 
  
 | 
        } 
 | 
  
 | 
        private void grdMain_Group_Scroll(object sender, ScrollEventArgs e) 
 | 
        { 
 | 
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); 
 | 
            oSumGrid.DisplayCurRow(); 
 | 
        } 
 | 
  
 | 
  
 | 
  
 | 
    } 
 | 
} 
 |