/// <summary> /// For statement other than 'in', like =,>,< /// </summary> /// <param name="colName">column name</param> /// <param name="opt">operater</param> /// <param name="val_str">value in string</param> /// <returns></returns> private string Init_RO(string colName, RelationalOperator opt, string val_str) { StringBuilder sb = new StringBuilder(); if (string.IsNullOrEmpty(colName)) { return(null); } sb.Append('[').Append(colName.Replace("]", "]]")).Append(']'); if (val_str == null) { if (opt == RelationalOperator.Equals) { sb.Append(" is NULL "); } else { sb.Append(" is not NULL "); } } else { sb.Append(' ').Append(SQL_relation.Operater_to_str(opt)).Append(' '); sb.Append("'").Append(val_str.Replace("'", "''")).Append("'"); } return(sb.ToString()); }
public static bool IsNull_or_Empty(SQL_relation rela) { if (rela == null) { return(true); } return(string.IsNullOrEmpty(rela.SQL_str)); }
/*-------------------------------------------------------------------------------------------------------------*/ private string Create_SQL_str(SQL_relation rela) { if (rela == null) { return(null); } else { return(rela.SQL_str); } }
internal HssUtility.SQLserver.DB_update Get_DBupdate() { if (!this.CheckValueChanges()) { return(null); } HssUtility.SQLserver.DB_update upd = new HssUtility.SQLserver.DB_update(DTCPositionModelNumber_Mapping.Get_cmdTP()); if (this.Country.ValueChanged) { upd.AddValue("Country", this.Country); } if (this.Issue.ValueChanged) { upd.AddValue("Issue", this.Issue); } if (this.RecordYear.ValueChanged) { upd.AddValue("RecordYear", this.RecordYear); } if (this.IncomeEvent.ValueChanged) { upd.AddValue("IncomeEvent", this.IncomeEvent); } if (this.ModelNumber.ValueChanged) { upd.AddValue("ModelNumber", this.ModelNumber); } if (this.ADRRecordDate.ValueChanged) { upd.AddValue("ADRRecordDate", this.ADRRecordDate); } if (this.ORDPayDate.ValueChanged) { upd.AddValue("ORDPayDate", this.ORDPayDate); } if (this.SecurityTypeID.ValueChanged) { upd.AddValue("SecurityTypeID", this.SecurityTypeID); } if (this.ADRRecordDate_End.ValueChanged) { upd.AddValue("ADRRecordDate_End", this.ADRRecordDate_End); } if (this.AtSourceSumFromDetails.ValueChanged) { upd.AddValue("AtSourceSumFromDetails", this.AtSourceSumFromDetails); } HssUtility.SQLserver.SQL_relation rela = new HssUtility.SQLserver.SQL_relation("DTCModelMappingID", HssUtility.General.RelationalOperator.Equals, this.pk_ID); upd.SetCondition(rela); return(upd); }
private string Create_SQL_str(SQL_condition con1, ConditionalOperator opt, SQL_relation rela2) { if (SQL_condition.IsNull_or_Empty(con1) && SQL_relation.IsNull_or_Empty(rela2)) { return(null); } if (SQL_condition.IsNull_or_Empty(con1)) { return(rela2.SQL_str); } if (SQL_relation.IsNull_or_Empty(rela2)) { return(con1.SQL_str); } SQL_condition con2 = new SQL_condition(rela2); return(this.Create_SQL_str(con1, opt, con2)); }
/// <summary> /// Initialize object from DB /// </summary> public bool Init_from_DB() { if (this.DTCModelMappingID < 0) { return(false); } HssUtility.SQLserver.DB_select db_sel = new HssUtility.SQLserver.DB_select(DTCPositionModelNumber_Mapping.Get_cmdTP()); db_sel.tableName = "DTCPositionModelNumber_Mapping"; HssUtility.SQLserver.SQL_relation rela = new HssUtility.SQLserver.SQL_relation("DTCModelMappingID", HssUtility.General.RelationalOperator.Equals, this.DTCModelMappingID); db_sel.SetCondition(rela); bool res_flag = false; HssUtility.SQLserver.DB_reader reader = new HssUtility.SQLserver.DB_reader(db_sel, Utility.Get_DRWIN_hDB()); if (reader.Read()) { this.Init_from_reader(reader); res_flag = true; } reader.Close(); return(res_flag); }
public SQL_condition(SQL_condition con1, ConditionalOperator opt, SQL_relation rela2) { this.SQL_str = this.Create_SQL_str(con1, opt, rela2); }
public SQL_condition(SQL_relation rela) { this.SQL_str = this.Create_SQL_str(rela); }
public void SetCondition(SQL_relation rela) { SQL_condition cond = new SQL_condition(rela); this.condition = cond; }