| using System; | 
| using System.Collections.Generic; | 
| using System.ComponentModel; | 
| using System.Data; | 
| using System.Drawing; | 
| using System.Text; | 
| using System.Windows.Forms; | 
|   | 
| namespace BaseSet | 
| { | 
|     public partial class Gy_DataIn_Source :BLL.Gy_DataInTmp | 
|     { | 
|         public Gy_DataIn_Source() | 
|         { | 
|             InitializeComponent(); | 
|         } | 
|   | 
|         public int HCollectIDCol = 1;         //²É¼¯Æ÷ÄÚÂë | 
|         public int HRoomIDCol = 5;            //Òµ»§ÄÚÂë | 
|         public int HBeginDateCol = 13;         //¿ªÊ¼ÈÕÆÚ | 
|         public int HEndDateCol = 10;           //½áÊøÈÕÆÚ | 
|         public int HItMoneyIDCol = 5;         //·ÑÓÃÏîÄ¿ | 
|         public int HQtyCol = 6;               //ÊýÁ¿ | 
|         public int HPriceCol = 7;             //µ¥¼Û | 
|         public int HMoneyCol = 8;             //½ð¶î | 
|         public int HBeginBalanceCol = 12;      //¿ªÊ¼ÊýÖµ | 
|         public int HEndBalanceCol = 9;        //½áÊøÊýÖµ | 
|         // | 
|         public const int HBeginRow = 2;         //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý | 
|         // | 
|         public DAL.ClsGy_Source_Ctl oSource = new DAL.ClsGy_Source_Ctl(); | 
|         public DAL.ClsGy_Source_View oSourceHlp = new DAL.ClsGy_Source_View(); | 
|         public DAL.ClsGy_WorkCenter_View oWorkCenter = new DAL.ClsGy_WorkCenter_View(); | 
|         public DAL.ClsGy_Process_View oProce = new DAL.ClsGy_Process_View(); | 
|   | 
|         /// <summary> | 
|         ///  ³õʼ»¯½çÃæ | 
|         /// </summary> | 
|         public override void initData() | 
|         { | 
|             base.initData(); | 
|             base.sSheetName = "Éú²ú×ÊÔ´"; | 
|             base.ModRightName = "Gy_DataIn_Source"; | 
|             base.ModRightNameCheck = base.ModRightName + base.ModRightNameCheck; | 
|             base.ModRightNameClose = base.ModRightName + base.ModRightNameClose; | 
|             base.ModRightNameDelete = base.ModRightName + base.ModRightNameDelete; | 
|             base.ModRightNameEdit = base.ModRightName + base.ModRightNameEdit; | 
|             base.ModRightNameMoney = base.ModRightName + base.ModRightNameMoney; | 
|             base.ModRightNameQty = base.ModRightName + base.ModRightNameQty; | 
|             base.ModCaption = "Éú²ú×ÊÔ´µ¼Èë"; | 
|             this.Text = base.ModCaption; | 
|             lblCaption.Text = base.ModCaption; | 
|             // | 
|             DBUtility.Gy_BaseFun.SetComboxYear(cmbHYear); | 
|             DBUtility.Gy_BaseFun.SetComboxPeriod(cmbHPeriod); | 
|             // | 
|         } | 
|   | 
|         public override void Sub_DataIn() | 
|         { | 
|   | 
|             for (int i = 0; i <= grdMain.Rows.Count - 1; i++) | 
|             { | 
|                 if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[0].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[1].Value) != "") | 
|                 { | 
|                     //дÈëÀà | 
|                     if (WriteClass(i)) | 
|                     { | 
|                         //±£´æ¼Ç¼ | 
|                         if (!oSource.AddNew()) | 
|                         { | 
|                             MessageBox.Show("µ¼Èëʧ°Ü!ÔÒò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ"); | 
|                             return; | 
|                         } | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     MessageBox.Show("Éú²ú×ÊÔ´´úÂë»òÃû³ÆÎª¿Õ!ÔÒò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ"); | 
|                     return; | 
|                 } | 
|             } | 
|             MessageBox.Show("µ¼ÈëÍê±Ï"); | 
|             grdMain.DataSource = null; | 
|         } | 
|   | 
|         //дÈëÀ࠴ӿؼþ | 
|         private bool WriteClass(int row) | 
|         { | 
|             string sHNumber = ""; | 
|             string sHName = ""; | 
|             string sWorkCenterNumber = ""; | 
|             string sProcNumber = ""; | 
|             string sTye = ""; | 
|             string sR = ""; | 
|             long HItemID = 0; | 
|             int sCol = DBUtility.Gy_BaseFun.Fun_GetCol("×ÊÔ´´úÂë", grdMain); | 
|             int sHNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("×ÊÔ´Ãû³Æ", grdMain); | 
|             int sTyeCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÀàÐÍ", grdMain); | 
|             int sWorkCenterNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤×÷ÖÐÐÄ´úÂë", grdMain); | 
|             int sProcNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain); | 
|             int sRCol = DBUtility.Gy_BaseFun.Fun_GetCol("±¸×¢", grdMain); | 
|             // | 
|             sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sCol].Value);             | 
|             sHName=DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHNameCol].Value); | 
|             sTye = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sTyeCol].Value); | 
|             sWorkCenterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sWorkCenterNumberCol].Value); | 
|             sProcNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sProcNumberCol].Value); | 
|             sR = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sRCol].Value); | 
|             //ÅжÏÊÇ·ñÔÊÐí ±£´æ | 
|             //ÉóºË´úÂëÊÇ·ñºÏÀí | 
|             if (!DBUtility.ClsPub.AllowNumber(sHNumber)) | 
|             { | 
|                 MessageBox.Show("´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ"); | 
|                 return false; | 
|             } | 
|   | 
|             //ÊÇ·ñÖØ¸´´úÂë | 
|             if (oSource.HavSameNumber(HItemID, sHNumber)) | 
|             { | 
|                 MessageBox.Show("´úÂëÖØ¸´£¡", "Ìáʾ"); | 
|                 return false; | 
|             } | 
|             //¼ì²é¸¸¼¶ÊÇ·ñ´æÔÚ | 
|             string sParent; | 
|             sParent = DBUtility.ClsPub.GetParentCode(sHNumber); | 
|             if (sParent.Trim() == "") | 
|             { | 
|                 oSource.oModel.HParentID = 0; | 
|             } | 
|             else | 
|             { | 
|                 if (oSource.HavParentCode(sParent.Trim(), HItemID)) | 
|                 { | 
|                     oSource.oModel.HParentID = oSource.oModel.HItemID; | 
|                 } | 
|                 else | 
|                 { | 
|                     MessageBox.Show("Éϼ¶´úÂë²»´æÔÚ»ò±»½ûÓã¡", "Ìáʾ"); | 
|                     return false; | 
|                 } | 
|             } | 
|             //µÃµ½¶Ì´úÂë | 
|             string sShortNumber; | 
|             sShortNumber = DBUtility.ClsPub.GetShortNumber(sHNumber); | 
|             if (sShortNumber.Trim() == "") | 
|             { | 
|                 return false; | 
|             } | 
|             //±£´æÔ´úÂë | 
|             if (oSourceHlp.GetInfoByID(HItemID)) | 
|             { | 
|                 oSource.HOldNumber = oSourceHlp.oModel.HNumber; | 
|                 //ÊÇ·ñдúÂëÊÇ×Ô¼º×ÓÏîÄ¿µÄ¡¡×ÓÏîÄ¿ | 
|                 if (sParent.Length >= oSource.HOldNumber.Length) | 
|                 { | 
|                     if (sParent.Substring(0, oSource.HOldNumber.ToString().Length) == oSource.HOldNumber.Trim()) | 
|                     { | 
|                         MessageBox.Show("дúÂë²»ÄÜÊÇ×Ô¼ºµÄϼ¶µÄ×ÓÏîÄ¿£¡", "Ìáʾ"); | 
|                         return false; | 
|                     } | 
|                 } | 
|             } | 
|             else | 
|             { | 
|                 oSource.HOldNumber = ""; | 
|             } | 
|   | 
|             //µÃµ½  | 
|             if (oWorkCenter.GetInfoByNumber(sWorkCenterNumber)) | 
|             { | 
|                 oSource.oModel.HCenterID = oWorkCenter.omodel.HItemID; | 
|             } | 
|             else | 
|             { | 
|                 oSource.oModel.HCenterID = 0; | 
|                 MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sWorkCenterNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄ¹¤×÷ÖÐÐÄ£¡"); | 
|                 return false; | 
|             } | 
|             //дÈëÐÅÏ¢ | 
|             oSource.oModel.HShortNumber = sShortNumber; | 
|             oSource.oModel.HEndFlag = true; | 
|             oSource.oModel.HLevel = DBUtility.ClsPub.GetLevel(sHNumber); | 
|             oSource.oModel.HNumber = sHNumber; | 
|             oSource.oModel.HHelpCode = ""; | 
|             oSource.oModel.HName = sHName; | 
|             oSource.oModel.HStopflag = false; | 
|             oSource.oModel.HRemark = sR; | 
|             oSource.oModel.HType = sTye; | 
|             //if (oFactory.GetInfoByName(sWorkNumber)) | 
|             //{ | 
|             //    oSource.oModel.HCenterID = oFactory.omodel.HItemID; | 
|             //} | 
|             //else | 
|             //{ | 
|             //    oSource.oModel.HCenterID = 0; | 
|             //    return false; | 
|             //} | 
|             // | 
|             if (oProce.GetInfoByNumber(sProcNumber)) | 
|             { | 
|                 oSource.oModel.HProcID = oProce.omodel.HItemID; | 
|             } | 
|             else | 
|             { | 
|                 oSource.oModel.HProcID = 0; | 
|                 return false; | 
|             } | 
|             | 
|             return true; | 
|         } | 
|   | 
|         private void button1_Click(object sender, EventArgs e) | 
|         { | 
|   | 
|         } | 
|   | 
|          | 
|   | 
|     } | 
| } |