private void ImportICB() { this.ShowMessage(""); string flds = "Industry,Supersector,Sector,Subsector,Definition"; databases.importDS.icbCodeDataTable icbTbl = new databases.importDS.icbCodeDataTable(); common.import.ImportFromExcel(dataFileNameEd.Text, sheetNameEd.Text, flds, true, icbTbl); ImportICB_ValidateData(icbTbl); //Add to database string sysCodeCat = sysCodeCatEd.Text.Trim(); databases.baseDS.sysCodeDataTable sysCodeTbl = new databases.baseDS.sysCodeDataTable(); ImportICB_AddToDb(icbTbl, icbTbl.industryColumn.ColumnName, false, sysCodeTbl, sysCodeCat, null); ImportICB_AddToDb(icbTbl, icbTbl.superSectorColumn.ColumnName, false, sysCodeTbl, sysCodeCat, icbTbl.industryColumn.ColumnName); ImportICB_AddToDb(icbTbl, icbTbl.sectorColumn.ColumnName, false, sysCodeTbl, sysCodeCat, icbTbl.superSectorColumn.ColumnName); ImportICB_AddToDb(icbTbl, icbTbl.subSectorColumn.ColumnName, true, sysCodeTbl, sysCodeCat, icbTbl.sectorColumn.ColumnName); databases.DbAccess.DeleteSysCode_ByCategory(sysCodeCat); databases.DbAccess.UpdateData(sysCodeTbl); this.ShowMessage("Hòan tất"); //ImportICB_AddToDb("ICB", icbTbl); //common.Export.ExportToExcel(icbTbl.DefaultView.ToTable(),"d://tmp.xls"); }
//Add to database private void ImportICB_AddToDb(databases.importDS.icbCodeDataTable tbl, string fldName, bool haveDefitionFld, databases.baseDS.sysCodeDataTable sysCodeTbl, string category, string codeGroupFldName) { databases.baseDS.sysCodeRow sysCodeRow; common.myKeyValueItem item; for (int idx = 0; idx < tbl.Count; idx++) { if (tbl[idx].RowState == DataRowState.Deleted) { continue; } item = Imports.Libs.SplitKeyValue(tbl[idx][fldName].ToString(), " "); if (item == null) { common.SysLog.WriteLog(tbl[idx][fldName].ToString() + " not found."); continue; } if (sysCodeTbl.FindBycategorycode(category, item.Key) == null) { sysCodeRow = sysCodeTbl.NewsysCodeRow(); databases.AppLibs.InitData(sysCodeRow); sysCodeRow.category = category; sysCodeRow.code = item.Key; sysCodeRow.description1 = item.Value; sysCodeRow.tag1 = fldName; if (codeGroupFldName != null) { sysCodeRow.inGroup = tbl[idx][codeGroupFldName].ToString(); } if (haveDefitionFld && !tbl[idx].IsdefinitionNull()) { sysCodeRow.notes = tbl[idx].definition; } sysCodeTbl.AddsysCodeRow(sysCodeRow); } tbl[idx][fldName] = item.Key; } }
private void ImportICB() { this.ShowMessage(""); string flds = "Industry,Supersector,Sector,Subsector,Definition"; databases.importDS.icbCodeDataTable icbTbl = new databases.importDS.icbCodeDataTable(); common.import.ImportFromExcel(dataFileNameEd.Text, sheetNameEd.Text, flds, true, icbTbl); ImportICB_ValidateData(icbTbl); //Add to database string sysCodeCat = sysCodeCatEd.Text.Trim(); databases.baseDS.sysCodeDataTable sysCodeTbl = new databases.baseDS.sysCodeDataTable(); ImportICB_AddToDb(icbTbl, icbTbl.industryColumn.ColumnName, false, sysCodeTbl, sysCodeCat, null); ImportICB_AddToDb(icbTbl, icbTbl.superSectorColumn.ColumnName, false, sysCodeTbl, sysCodeCat, icbTbl.industryColumn.ColumnName); ImportICB_AddToDb(icbTbl, icbTbl.sectorColumn.ColumnName, false, sysCodeTbl, sysCodeCat, icbTbl.superSectorColumn.ColumnName); ImportICB_AddToDb(icbTbl, icbTbl.subSectorColumn.ColumnName, true, sysCodeTbl, sysCodeCat, icbTbl.sectorColumn.ColumnName); databases.DbAccess.DeleteSysCode_ByCategory(sysCodeCat); databases.DbAccess.UpdateData(sysCodeTbl); this.ShowMessage("Hòan tất"); //ImportICB_AddToDb("ICB", icbTbl); //common.Export.ExportToExcel(icbTbl.DefaultView.ToTable(),"d://tmp.xls"); }
public static databases.baseDS.sysCodeRow UpdateData(databases.baseDS.sysCodeRow row) { try { lock (myClient) { databases.baseDS.sysCodeDataTable tbl = new databases.baseDS.sysCodeDataTable(); tbl.ImportRow(row); myClient.UpdateSysCode(ref tbl); row.AcceptChanges(); return tbl[0]; } } catch (Exception er) { if (OnError != null) OnError(er); } return null; }
public bool UpdateSysCode(ref databases.baseDS.sysCodeDataTable sysCodeTbl) { return(base.Channel.UpdateSysCode(ref sysCodeTbl)); }
public databases.baseDS.sysCodeDataTable GetSysCode(string catCode) { try { databases.baseDS.sysCodeDataTable tbl = new databases.baseDS.sysCodeDataTable(); databases.DbAccess.LoadData(tbl, catCode); return tbl; } catch (Exception ex) { WriteSysLogLocal("WS033", ex); } return null; }