private void btnKdas_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { DataTable table = ImportExcel2007.TranslateToTable(ofd.FileName); foreach (DataRow row in table.Rows) { string id = row.ItemArray[0].ToString().Trim(); string name = AdUtil.getUsernameByUserId(id, "kmas.local"); string dept = row.ItemArray[2].ToString().Trim(); string sect = row.ItemArray[3].ToString().Trim(); string div = row.ItemArray[4].ToString().Trim(); string query = string.Format("insert into TB_USER_AS (u_staffid, u_name, u_dept, u_sect, u_div) values ('{0}', N'{1}', '{2}', N'{3}', N'{4}')", id, name, dept, sect, div); DataServiceM.GetInstance().ExecuteNonQuery(query); } } }
public static DataServiceM GetInstance() { if (_dataService == null) { _dataService = new DataServiceM(); } return(_dataService); }