private static string AttachParams(string q, Defaultcompany v) { q = q.Replace("@" + DEFAULTCOMPANY.DEFAULTCOMPANY_ID + "@", "" + ConvertTO.SqlString(v.Defaultcompany_id) + ""); q = q.Replace("@" + DEFAULTCOMPANY.COMPANY_ID + "@", "" + ConvertTO.SqlString(v.Company_id) + ""); q = q.Replace("@" + DEFAULTCOMPANY.ACY_ID + "@", "" + ConvertTO.SqlString(v.Acy_id) + ""); return(q); }
private static void InsertData(Defaultcompany obj, string newDB) { if (CheckData(obj, newDB) == false) { CDefaultcompany.Insert(obj, new DAL()); } ; }
public static void Update(Defaultcompany v, DAL dalsession) { string q = "UPDATE " + DEFAULTCOMPANY.DEFAULTCOMPANY_TBL + " SET"; q += " " + DEFAULTCOMPANY.COMPANY_ID + " = @" + DEFAULTCOMPANY.COMPANY_ID + "@ \r\n "; q += "," + DEFAULTCOMPANY.ACY_ID + " = @" + DEFAULTCOMPANY.ACY_ID + "@ \r\n "; q += " WHERE " + DEFAULTCOMPANY.DEFAULTCOMPANY_ID + " = @" + DEFAULTCOMPANY.DEFAULTCOMPANY_ID + "@ "; q = AttachParams(q, v); dalsession.Execute(q); }
private void Btn_default_Click(object sender, EventArgs e) { Defaultcompany obj = new Defaultcompany() { Defaultcompany_id = "1", Company_id = Current.Company_id, Acy_id = GetSelectedPkValue() }; CDefaultcompany.Update(obj, new DAL()); Load_sacy(); }
private void Btn_removedefault_Click(object sender, EventArgs e) { Defaultcompany obj = new Defaultcompany() { Defaultcompany_id = "1", Company_id = "NO", Acy_id = "NO" }; CDefaultcompany.Update(obj, new DAL()); Load_sacy(); }
public static void Insert(Defaultcompany v, DAL dalsession) { string q = " INSERT INTO " + DEFAULTCOMPANY.DEFAULTCOMPANY_TBL + " ( "; q += " " + DEFAULTCOMPANY.COMPANY_ID + " \r\n "; q += "," + DEFAULTCOMPANY.ACY_ID + " \r\n "; q += " ) VALUES ( "; q += " @" + DEFAULTCOMPANY.COMPANY_ID + "@ \r\n "; q += ", @" + DEFAULTCOMPANY.ACY_ID + "@ \r\n "; q += " ) \r\n "; q = AttachParams(q, v); dalsession.Execute(q); }
private static bool CheckData(Defaultcompany obj, string newDB) { string q = "USE " + newDB + "; "; q += "SELECT * FROM " + DEFAULTCOMPANY.DEFAULTCOMPANY_TBL + " WHERE " + DEFAULTCOMPANY.DEFAULTCOMPANY_NAME + " = '" + obj.Defaultcompany_name + "'; "; using (IDataReader redr = new DAL().Listreader(q)) { while (redr.Read() == true) { obj.Defaultcompany_id = redr[DEFAULTCOMPANY.DEFAULTCOMPANY_ID].ToString(); CDefaultcompany.Update(obj, new DAL()); return(true); } return(false); } }
private static Defaultcompany EntityData(string q) { using (IDataReader redr = new DAL().Listreader(q)) { while (redr.Read() == true) { Defaultcompany obj = new Defaultcompany() { Defaultcompany_id = redr[DEFAULTCOMPANY.DEFAULTCOMPANY_ID].ToString(), Company_id = redr[DEFAULTCOMPANY.COMPANY_ID].ToString(), Acy_id = redr[DEFAULTCOMPANY.ACY_ID].ToString() }; return(obj); } redr.Close(); return(new Defaultcompany()); } }
private static Defaultcompany GetOldData(int id, string OldDB) { string q = "USE " + OldDB + "; "; q += "SELECT * FROM " + DEFAULTCOMPANY.DEFAULTCOMPANY_TBL + " WHERE " + DEFAULTCOMPANY.DEFAULTCOMPANY_ID + " = '" + id + "'; "; using (IDataReader redr = new DAL().Listreader(q)) { while (redr.Read() == true) { Defaultcompany obj = new Defaultcompany { Company_id = ConvertTO.Integer(redr[DEFAULTCOMPANY.COMPANY_ID].ToString()), Acy_id = ConvertTO.Integer(redr[DEFAULTCOMPANY.ACY_ID].ToString()), Notes = redr[DEFAULTCOMPANY.NOTES].ToString(), Active_id = redr[DEFAULTCOMPANY.ACTIVE_ID].ToString(), User_id = "1" }; return(obj); } return(null); } }