public int Update_to_DB() { if (dvdCust == null) { return(-1); } int count = 0, oneTimeAmount = Bulk_DBcmd.BatchAmount; DB_update upd = new DB_update(Dividend_Detail_simpleAP.Get_cmdTP()); upd.AddValue("CustodianID", this.dvdCust.CustodianID); List <int> detailID_list = new List <int>(oneTimeAmount); foreach (Dividend_Detail_simpleAP dd in this.dd_list) { detailID_list.Add(dd.DetailID); if (detailID_list.Count >= oneTimeAmount) { upd.SetCondition(new SQL_relation("DetailID", true, detailID_list)); count += upd.SaveToDB(Utility.Get_DRWIN_hDB()); detailID_list.Clear(); } } if (detailID_list.Count > 0) { upd.SetCondition(new SQL_relation("DetailID", true, detailID_list)); count += upd.SaveToDB(Utility.Get_DRWIN_hDB()); } return(count); }
public static int UpdateDetail_singleValue(int detailID, string colName, DateTime dt) { if (string.IsNullOrEmpty(colName)) { return(-5); } if (dt < Utility.MinDate) { return(-6); } CmdTemplate cmdTp = new CmdTemplate();//create template for DB cmdTp.tableName = DividendDetail_master.Detail_tableName; cmdTp.AddColumn(DividendDetail_master.Detail_PK_colName); cmdTp.AddColumn(colName); DB_update upd = new DB_update(cmdTp); upd.AddValue(colName, dt); SQL_relation rela = new SQL_relation(DividendDetail_master.Detail_PK_colName, RelationalOperator.Equals, detailID); upd.SetCondition(rela); if (colName.Contains(" ") || colName.Contains("-")) { Helper_SQLserver.SetTriger(DividendDetail_master.Detail_tableName, "TR_Dividend_Detail_Audit_History", false, Utility.Get_DRWIN_hDB()); int count = upd.SaveToDB(Utility.Get_DRWIN_hDB()); Helper_SQLserver.SetTriger(DividendDetail_master.Detail_tableName, "TR_Dividend_Detail_Audit_History", true, Utility.Get_DRWIN_hDB()); return(count); } else { int count = upd.SaveToDB(Utility.Get_DRWIN_hDB()); return(count); } }