using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using System.Data.Sql; namespace BaseSet { public partial class Gy_DataInTmp_DuSubsidyItem : Form { ClsGy_DataInTmp_DuSubsidyItem oTmp = new ClsGy_DataInTmp_DuSubsidyItem(); DAL.ClsPay_DuSubsidyItemBill BillNew = new DAL.ClsPay_DuSubsidyItemBill(); DAL.ClsGy_DuSubsidyItem_View oDuHlp = new DAL.ClsGy_DuSubsidyItem_View(); DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View();//K3²¿ÃÅ DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View(); DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View(); // public Gy_DataInTmp_DuSubsidyItem() { InitializeComponent(); } private void initHeadCaption() { } // private void yl_Click(object sender, EventArgs e) { WriteClass(cmbHDataInTmp.Text); } //Êý¾Ýµ¼Èë public void WriteClass(string sName) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); string sColName; string sFieldName; if (sName == "¿Û²¹ÏîÄ¿·ÑÓõ¼Èë") { for (int i = 0; i <= grdmain.Rows.Count - 1; i++) { if (DBUtility.ClsPub.isStrNull(grdmain.Rows[i].Cells[0].Value) != "") { if (Mater_WriteClass(i)) { BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } } } } MessageBox.Show("µ¼ÈëÍê±Ï"); grdmain.DataSource = null; } //дÈëÀà ´Ó¿Ø¼þ private bool Mater_WriteClass(int row) { // string sBillNo = ""; sBillNo = DBUtility.ClsPub.CreateBillCode("2233", ref DBUtility.ClsPub.sExeReturnInfo, true);//µÃµ½Ðµ¥ºÅ£¨È±ÉÙº¯Êý£© δÍê³É int sDuSubCol = DBUtility.Gy_BaseFun.Fun_GetCol("¿Û²¹ÏîÄ¿", grdmain); int sDeptCol = DBUtility.Gy_BaseFun.Fun_GetCol("²¿ÃÅ", grdmain); int sGroupCol = DBUtility.Gy_BaseFun.Fun_GetCol("°à×é", grdmain); int sEmpCol = DBUtility.Gy_BaseFun.Fun_GetCol("Ö°Ô±", grdmain); // string sDuSubName = DBUtility.ClsPub.isStrNull(grdmain.Rows[row].Cells[sDuSubCol].Value); string sDeptName = DBUtility.ClsPub.isStrNull(grdmain.Rows[row].Cells[sDeptCol].Value); string sGroupName = DBUtility.ClsPub.isStrNull(grdmain.Rows[row].Cells[sGroupCol].Value); string sEmpName = DBUtility.ClsPub.isStrNull(grdmain.Rows[row].Cells[sEmpCol].Value); //ÅжÏÊÇ·ñÔÊÐí ±£´æ //ÅжÏÊÇ·ñÔÊÐí ±£´æ //µÃµ½Òµ»§ÄÚÂ룬·ÑÓÃÏîÄ¿ÄÚÂë //дÈëÐÅÏ¢ BillNew.omodel.HYear = 2011; BillNew.omodel.HPeriod = 1; BillNew.omodel.HBillNo = sBillNo; BillNew.omodel.HDate = DateTime.Today; BillNew.omodel.HRemark = "ϵͳµ¼Èë"; // if (oDept.GetInfoByName(sDeptName)) { BillNew.omodel.HDeptID = oDept.omodel.HItemID; } else { BillNew.omodel.HDeptID = 0; return false; } // if (oGroup.GetInfoByName(sGroupName)) { BillNew.omodel.HGroupID = oGroup.omodel.HItemID; } else { BillNew.omodel.HGroupID = 0; return false; } BillNew.omodel.HExplanation = DBUtility.ClsPub.isStrNull(grdmain.Rows[row].Cells[DBUtility.Gy_BaseFun.Fun_GetCol("ÕªÒª", grdmain)].Value);// DBUtility.Gy_BaseFun.Fun_GetCol("ÕªÒª", grdmain); BillNew.omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(grdmain.Rows[row].Cells[DBUtility.Gy_BaseFun.Fun_GetCol("ÄÚ²¿µ¥¾ÝºÅ", grdmain)].Value); //DBUtility.Gy_BaseFun.Fun_GetCol("ÄÚ²¿µ¥¾ÝºÅ", grdmain); BillNew.omodel.HAutoSaveFlag = false; // //BillNew.HExRate = ClsPub.isDoule(this.txtHMaterName.Text.ToString()); //Ã÷ϸÀำֵ BillNew.DetailColl = new List(); Model.ClsPay_DuSubsidyItemBillSub oSub = new Model.ClsPay_DuSubsidyItemBillSub(); oSub.HEntryID = 1; // if (oDuHlp.GetInfoByName(sDuSubName)) { oSub.HDuSubsidyItemID = oDuHlp.omodel.HItemID; } else { oSub.HDuSubsidyItemID = 0; return false; } // if (oEmp.GetInfoByName(sEmpName)) { oSub.HEmpID = oEmp.omodel.HItemID; } else { oSub.HEmpID = 0; return false; } oSub.HQty = DBUtility.ClsPub.isLong(grdmain.Rows[row].Cells[DBUtility.Gy_BaseFun.Fun_GetCol("ÊýÁ¿", grdmain)].Value); //DBUtility.Gy_BaseFun.Fun_GetCol("ÊýÁ¿", grdmain); ; oSub.HPrice = DBUtility.ClsPub.isLong(grdmain.Rows[row].Cells[DBUtility.Gy_BaseFun.Fun_GetCol("µ¥¼Û", grdmain)].Value); //DBUtility.Gy_BaseFun.Fun_GetCol("µ¥¼Û", grdmain); ; oSub.HMoney = DBUtility.ClsPub.isLong(grdmain.Rows[row].Cells[DBUtility.Gy_BaseFun.Fun_GetCol("½ð¶î", grdmain)].Value); //DBUtility.Gy_BaseFun.Fun_GetCol("½ð¶î", grdmain); ; BillNew.DetailColl.Add(oSub); return true; } private void tc_Click(object sender, EventArgs e) { this.Close(); } private void K3_OutMachFeeDataIn_Load(object sender, EventArgs e) { initHeadCaption(); } public string ExcelPath; private void OpenExcelData(string sPath) { string sName; sName = "Sheet1"; string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sPath + ";" + "Extended Properties='Excel 8.0;IMEX=1'"; DataSet ds = new DataSet(); OleDbConnection conn = new OleDbConnection(strConn); conn.Open(); try { OleDbDataAdapter Da = new OleDbDataAdapter("select * from [" + sName + "$]", conn); Da.Fill(ds); grdmain.DataSource = ds.Tables[0]; } catch(Exception e) { MessageBox.Show("ÒýÈëEXCELÊý¾Ýʧ°Ü£¡ÇëÓë¹ÜÀíÔ±ÁªÏµ£¡" + e.Message); } } private void button1_Click_1(object sender, EventArgs e) { OpenExcelFile.Title = "Open Excel File "; OpenExcelFile.FileName = ""; OpenExcelFile.Filter = "Microsoft Office Excel Files(*.xls)|*.xls|(*.csv)|*.csv"; OpenExcelFile.ShowDialog(); if (OpenExcelFile.FileName != "") { ExcelPath = OpenExcelFile.FileName; OpenExcelData(ExcelPath); } else { ExcelPath = ""; } } } }