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); }