public JsonResult SaveProds([FromBody] Prod[] prods) { string msg = ""; if (!CSys.OpenCon(ref con)) { JsonResult errjson = Json(new { ok = "no", Error = "connection error." }); return(errjson); } NpgsqlTransaction sqlTrans; sqlTrans = con.BeginTransaction(); BaseADOPG.ExceuteSql("Delete from prod ", con, sqlTrans); dt = BaseADOPG.GetData("Select * from prod"); DataRow nrow; foreach (Prod itm in prods) { nrow = dt.NewRow(); nrow["prodid"] = itm.prodid; nrow["code"] = itm.code; nrow["codename"] = itm.codename; nrow["prodgroup"] = itm.prodgroup; nrow["modifieddate"] = DateTime.Now; nrow["lastuser"] = "******"; dt.Rows.Add(nrow); } bool success = false; CAdapter.GenerateProdCommand(ref da); if (UpdateTable(ref dt, sqlTrans)) { sqlTrans.Commit(); success = true; msg = "Saved successfully"; } else { sqlTrans.Rollback(); msg = _err; } JsonResult restultJson = Json(new { ok = (success) ? "yes" : "no", Error = msg }); con.Close(); return(restultJson); }
public JsonResult SavePriceSet([FromBody] PrcSet[] prcsets) { string msg = ""; if (!CSys.OpenCon(ref con)) { JsonResult errjson = Json(new { ok = "no", Error = "connection error." }); return(errjson); } NpgsqlTransaction sqlTrans; sqlTrans = con.BeginTransaction(); // BaseADOPG.ExceuteSql("Delete from prchdr",con,sqlTrans); dt = BaseADOPG.GetData("Select * from prchdr"); foreach (DataRow row in dt.Select()) { row.Delete(); } UpdatePrcSet(prcsets); bool success = false; CAdapter.GeneratePrcHdrCommand(ref da); if (UpdateTable(ref dt, sqlTrans)) { sqlTrans.Commit(); success = true; msg = "Saved successfully"; } else { sqlTrans.Rollback(); msg = _err; } JsonResult restultJson = Json(new { ok = (success) ? "yes" : "no", Error = msg }); con.Close(); return(restultJson); }
public JsonResult SavePriceSet([FromBody] PriceSet prcset) { string msg = ""; if (!CSys.OpenCon(ref con)) { JsonResult errjson = Json(new { ok = "no", Error = "connection error." }); return(errjson); } // BaseADOPG.ExceuteSql("Delete from from prcdtl where where prcdate='" + prcset.prcdate + "' and prcid='" + prcset.prcid + "'", con, sqlTrans); dt = BaseADOPG.GetData("Select * from prcdtl where prcdate='" + prcset.prcdate + "' and prcid='" + prcset.prcid + "'"); UpdatePrcdtl(prcset); bool success = false; NpgsqlTransaction sqlTrans; sqlTrans = con.BeginTransaction(); CAdapter.GeneratePrcDtlCommand(ref da); if (UpdateTable(ref dt, sqlTrans)) { sqlTrans.Commit(); success = true; msg = "Saved successfully"; } else { sqlTrans.Rollback(); msg = _err; } JsonResult restultJson = Json(new { ok = (success) ? "yes" : "no", Error = msg }); con.Close(); return(restultJson); }
private void SELL_Load(object sender, EventArgs e) { int del = SAdapter.Delete(); SqlConnection con = new SqlConnection("Data Source='.\\SQLEXPRESS';Integrated Security='true';Initial Catalog='MEDICAL'"); SqlCommand cmd = new SqlCommand("SELECT I_name FROM StockInMst", con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); AutoCompleteStringCollection SCollection = new AutoCompleteStringCollection(); while (reader.Read()) { SCollection.Add(reader.GetString(0)); } txtiname.AutoCompleteCustomSource = SCollection; con.Close(); CDT = CAdapter.SelectClient(); comboBox1.DataSource = CDT; comboBox1.DisplayMember = "cu_name"; comboBox1.ValueMember = "cu_id"; }