private static List <Receiptitems> GetOldItemsData(int id, string OldDB) { string q = "USE " + OldDB + "; "; q += " SELECT " + RECEIPTITEMS.RECEIPTITEMS_TBL + ".* \r\n"; q += " FROM " + RECEIPTITEMS.RECEIPTITEMS_TBL + " \r\n"; q += " WHERE " + RECEIPTITEMS.RECEIPTITEMS_TBL + "." + RECEIPT.RECEIPT_ID + " = '" + id + "' \r\n"; q += " ORDER BY " + RECEIPTITEMS.RECEIPTITEMS_TBL + "." + RECEIPTITEMS.RECEIPTITEMS_ID + ";\r\n"; List <Receiptitems> list = new List <Receiptitems>(); using (IDataReader redr = new DAL().Listreader(q)) { while (redr.Read() == true) { Receiptitems obj = new Receiptitems() { Receiptitems_id = "", Receipt_id = "", Receipt_by = redr[RECEIPTITEMS.RECEIPT_BY].ToString(), Invoiced_no = redr[RECEIPTITEMS.INVOICED_NO].ToString(), Invoiced_amount = redr[RECEIPTITEMS.INVOICED_AMOUNT].ToString(), Receipt_amount = ConvertTO.Decimal(redr[RECEIPTITEMS.RECEIPT_AMOUNT].ToString()), }; list.Add(obj); } return(list); } }
private List <Receiptitems> Collectitems(string vId) { List <Receiptitems> list = new List <Receiptitems>(); for (int r = 0; r < editgrid.RowCount; r++) { Receiptitems obj = new Receiptitems(); if ( (editgrid[RECEIPTITEMS.RECEIPT_AMOUNT, r].Value + "") == "" ) { //==LEAVE IT(the empty row). } else { obj.Receiptitems_id = ""; obj.Receipt_id = vId; obj.Receipt_by = (editgrid[RECEIPTITEMS.RECEIPT_BY, r].Value + ""); obj.Invoiced_no = (editgrid[RECEIPTITEMS.INVOICED_NO, r].Value + ""); obj.Invoiced_amount = editgrid[RECEIPTITEMS.INVOICED_AMOUNT, r].Value + ""; obj.Receipt_amount = ConvertTO.Decimal(editgrid[RECEIPTITEMS.RECEIPT_AMOUNT, r].Value + ""); list.Add(obj); } } if (list.Count != 0) { return(list); } return(null); }
private static string AttachParams(string q, Receiptitems v) { q = q.Replace("@" + RECEIPTITEMS.RECEIPT_ID + "@", "" + ConvertTO.SqlString(v.Receipt_id) + ""); q = q.Replace("@" + RECEIPTITEMS.RECEIPT_BY + "@", "" + ConvertTO.SqlString(v.Receipt_by) + ""); q = q.Replace("@" + RECEIPTITEMS.INVOICED_NO + "@", "" + ConvertTO.SqlString(v.Invoiced_no) + ""); q = q.Replace("@" + RECEIPTITEMS.INVOICED_AMOUNT + "@", "" + ConvertTO.SqlString(v.Invoiced_amount) + ""); q = q.Replace("@" + RECEIPTITEMS.RECEIPT_AMOUNT + "@", "" + ConvertTO.SqlDecimal(v.Receipt_amount) + ""); return(q); }
public static void Insert(List <Receiptitems> list, DAL dalsession) { for (int i = 0; i < list.Count; i++) { Receiptitems obj = new Receiptitems() { Receipt_id = list[i].Receipt_id, Receipt_by = list[i].Receipt_by, Invoiced_no = list[i].Invoiced_no, Invoiced_amount = list[i].Invoiced_amount, Receipt_amount = list[i].Receipt_amount }; InsertSub(obj, dalsession); } }
public static void InsertSub(Receiptitems v, DAL dalsession) { string q = " INSERT INTO " + RECEIPTITEMS.RECEIPTITEMS_TBL + " ( "; q += " " + RECEIPTITEMS.RECEIPT_ID + " \r\n "; q += "," + RECEIPTITEMS.RECEIPT_BY + " \r\n "; q += "," + RECEIPTITEMS.INVOICED_NO + " \r\n "; q += "," + RECEIPTITEMS.INVOICED_AMOUNT + " \r\n "; q += "," + RECEIPTITEMS.RECEIPT_AMOUNT + " \r\n "; q += " ) VALUES ( "; q += " @" + RECEIPTITEMS.RECEIPT_ID + "@ \r\n "; q += ", @" + RECEIPTITEMS.RECEIPT_BY + "@ \r\n "; q += ", @" + RECEIPTITEMS.INVOICED_NO + "@ \r\n "; q += ", @" + RECEIPTITEMS.INVOICED_AMOUNT + "@ \r\n "; q += ", @" + RECEIPTITEMS.RECEIPT_AMOUNT + "@ \r\n "; q += " ) \r\n "; q = AttachParams(q, v); dalsession.Execute(q); }
private static void InsertData(Receipt obj, List <Receiptitems> items, string newDB) { DAL dalsession; try { dalsession = new DAL(); dalsession.BeginTransaction(); List <Receiptitems> list_new = new List <Receiptitems>(); if (obj != null) { if (CheckData(obj, newDB) != true) { CReceipt.Insert(obj, dalsession); var vId = DAL.GetIdentity(dalsession); for (int k = 0; k < items.Count; k++) { Receiptitems v = new Receiptitems() { Receipt_id = vId, Receipt_by = items[k].Receipt_by, Invoiced_no = items[k].Invoiced_no, Invoiced_amount = items[k].Invoiced_amount, Receipt_amount = items[k].Receipt_amount }; list_new.Add(v); } CReceiptitems.Insert(list_new, dalsession); dalsession.Commit(); } } } catch (Exception ex) { MessageBox.Show("error : " + ex); } }
private static List <Receiptitems> EntityList(string q) { List <Receiptitems> list = new List <Receiptitems>(); using (IDataReader redr = new DAL().Listreader(q)) { while (redr.Read() == true) { Receiptitems obj = new Receiptitems() { Receiptitems_id = redr[RECEIPTITEMS.RECEIPTITEMS_ID].ToString(), Receipt_id = redr[RECEIPTITEMS.RECEIPT_ID].ToString(), Receipt_by = redr[RECEIPTITEMS.RECEIPT_BY].ToString(), Invoiced_no = redr[RECEIPTITEMS.INVOICED_NO].ToString(), Invoiced_amount = redr[RECEIPTITEMS.INVOICED_AMOUNT].ToString(), Receipt_amount = ConvertTO.Decimal(redr[RECEIPTITEMS.RECEIPT_AMOUNT].ToString()), }; list.Add(obj); } } return(list); }