本文整理汇总了C#中SES.Service.OrmliteConnection.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# OrmliteConnection.Execute方法的具体用法?C# OrmliteConnection.Execute怎么用?C# OrmliteConnection.Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SES.Service.OrmliteConnection
的用法示例。
在下文中一共展示了OrmliteConnection.Execute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWH
public ActionResult CreateWH(WareHouse item)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
var isExist = db.SingleOrDefault<WareHouse>("SELECT WHID, Id FROM dbo.WareHouse Where WHID ='" + item.WHID + "'");
if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null)
{
if (isExist != null)
{
return Json(new { success = false, message = "Kho đã tồn tại." });
}
string id = "";
var checkID = db.SingleOrDefault<WareHouse>("SELECT WHID, Id FROM dbo.WareHouse ORDER BY Id DESC");
if (checkID != null)
{
var nextNo = int.Parse(checkID.WHID.Substring(2, checkID.WHID.Length - 2)) + 1;
id = "WH" + String.Format("{0:00000000}", nextNo);
}
else
{
id = "WH00000001";
}
item.WHID = id;
item.WHName = !string.IsNullOrEmpty(item.WHName) ? item.WHName.Trim() : "";
item.Address = !string.IsNullOrEmpty(item.Address) ? item.Address.Trim() : "";
item.WHKeeper = !string.IsNullOrEmpty(item.WHKeeper) ? item.WHKeeper.Trim() : "";
item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note.Trim() : "";
item.CreatedAt = DateTime.Now;
item.CreatedBy = currentUser.UserID;
item.UpdatedAt = DateTime.Parse("1900-01-01");
item.UpdatedBy = "";
item.Status = item.Status;
db.Insert<WareHouse>(item);
return Json(new { success = true, Code = item.WHID, createdate = item.CreatedAt, createdby = item.CreatedBy });
}
else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
{
var success = db.Execute(@"UPDATE WareHouse SET Status = @Status, [email protected],[email protected],
Note = @Note, UpdatedAt = @UpdatedAt, UpdatedBy = @UpdatedBy, [email protected]
WHERE WHID = '" + item.WHID + "'", new
{
Status = item.Status,
//WHName = !string.IsNullOrEmpty(item.WHName) ? item.WHName.Trim() : "",
Address = !string.IsNullOrEmpty(item.Address) ? item.Address.Trim() : "",
WHKeeper = !string.IsNullOrEmpty(item.WHKeeper) ? item.WHKeeper.Trim() : "",
Note = !string.IsNullOrEmpty(item.Note) ? item.Note.Trim() : "",
UpdatedAt = DateTime.Now,
UpdatedBy = currentUser.UserID,
WHName = !string.IsNullOrEmpty(item.WHName) ? item.WHName.Trim() : "",
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Cập nhật không thành công." });
}
return Json(new { success = true });
}
else
return Json(new { success = false, message = "Bạn không có quyền" });
}
catch (Exception e)
{
log.Error(" WareHouse - Create - " + e.Message);
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}
示例2: Create
public ActionResult Create(Products item)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
var isExist = db.SingleOrDefault<Products>("SELECT Code, Id FROM dbo.Products Where Code ='"+item.Code+"'");
if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null)
{
if (isExist != null)
{
return Json(new { success = false, message = "Ấn phẩm đã tồn tại." });
}
string id = "";
var checkID = db.SingleOrDefault<Products>("SELECT Code, Id FROM dbo.Products ORDER BY Id DESC");
if (checkID != null)
{
var nextNo = int.Parse(checkID.Code.Substring(2, checkID.Code.Length - 2)) + 1;
id = "AD" + String.Format("{0:00000000}", nextNo);
}
else
{
id = "AD00000001";
}
item.Code = id;
item.Name = !string.IsNullOrEmpty(item.Name) ? item.Name.Trim() : "";
item.Price = item.VATPrice / 1.1;
item.VATPrice = item.VATPrice;
item.Size = !string.IsNullOrEmpty(item.Size) ? item.Size.Trim() : ""; ;
item.Unit = !string.IsNullOrEmpty(item.Unit) ? item.Unit.Trim() : ""; ;
item.Type = !string.IsNullOrEmpty(item.Type) ? item.Type.Trim() : ""; ;
item.WHID = !string.IsNullOrEmpty(item.WHID) ? item.WHID : "";
item.WHLID = !string.IsNullOrEmpty(item.WHLID) ? item.WHLID : "";
item.Desc = !string.IsNullOrEmpty(item.Desc) ? item.Desc.Trim() : "";
item.ShapeTemplate = !string.IsNullOrEmpty(item.ShapeTemplate) ? item.ShapeTemplate.Trim() : "";
item.CreatedAt = DateTime.Now;
item.CreatedBy = currentUser.UserID;
item.UpdatedAt = DateTime.Parse("1900-01-01");
item.UpdatedBy = "";
item.Status = item.Status;
db.Insert<Products>(item);
return Json(new { success = true, Code = item.Code, createdat = item.CreatedAt, createdby = item.CreatedBy });
}
else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
{
var success = db.Execute(@"UPDATE Products SET Status = @Status, VATPrice = @VATPrice, Size= @Size, [email protected],[email protected], [email protected], [email protected],
ShapeTemplate = @ShapeTemplate, UpdatedAt = @UpdatedAt,UpdatedBy [email protected], [email protected],[Desc][email protected], Name = @Name WHERE Code = '" + item.Code + "'", new
{
Status = item.Status,
Price = item.VATPrice / 1.1,
VATPrice = item.VATPrice,
Size = !string.IsNullOrEmpty(item.Size) ? item.Size.Trim() : "",
Unit = !string.IsNullOrEmpty(item.Unit) ? item.Unit.Trim() : "",
Type = !string.IsNullOrEmpty(item.Type) ? item.Type.Trim() : "",
WHID = !string.IsNullOrEmpty(item.WHID) ? item.WHID : "",
WHLID = !string.IsNullOrEmpty(item.WHLID) ? item.WHLID : "",
ShapeTemplate = !string.IsNullOrEmpty(item.ShapeTemplate) ? item.ShapeTemplate.Trim() : "",
UpdatedAt = DateTime.Now,
UpdatedBy = currentUser.UserID,
Desc = !string.IsNullOrEmpty(item.Desc) ? item.Desc.Trim() : "",
Name = !string.IsNullOrEmpty(item.Name) ? item.Name.Trim() : "",
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Cập nhật không thành công." });
}
//item.Price = item.VATPrice / 1.1;
//item.VATPrice = item.VATPrice;
//item.Size = !string.IsNullOrEmpty(item.Size) ? item.Size.Trim() : ""; ;
//item.Unit = !string.IsNullOrEmpty(item.Unit) ? item.Unit.Trim() : ""; ;
//item.Type = !string.IsNullOrEmpty(item.Type) ? item.Type.Trim() : ""; ;
//item.WHID = !string.IsNullOrEmpty(item.WHID) ? item.WHID : "";
//item.WHLID = !string.IsNullOrEmpty(item.WHLID) ? item.WHLID : "";
//item.Desc = !string.IsNullOrEmpty(item.Desc) ? item.Desc.Trim() : "";
//item.ShapeTemplate = !string.IsNullOrEmpty(item.ShapeTemplate) ? item.ShapeTemplate.Trim() : "";
//item.UpdatedAt = DateTime.Now;
//item.UpdatedBy = currentUser.UserID;
//item.Status = item.Status;
//db.Update<Products>(item);
return Json(new { success = true });
}
else
return Json(new { success = false, message = "Bạn không có quyền" });
}
catch (Exception e)
{
log.Error(" ListPublication - Create - " + e.Message);
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}
示例3: CreateUnit
public ActionResult CreateUnit(DC_AD_Unit item)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
var isExist = db.SingleOrDefault<DC_AD_Unit>("SELECT UnitID, Id FROM dbo.DC_AD_Unit Where UnitID ='" + item.UnitID + "'");
if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy ==null)
{
if (isExist != null)
{
return Json(new { success = false, message = "Đơn vị tính đã tồn tại." });
}
string id = "";
var checkID = db.SingleOrDefault<DC_AD_Unit>("SELECT UnitID, Id FROM dbo.DC_AD_Unit ORDER BY Id DESC");
if (checkID != null)
{
var nextNo = int.Parse(checkID.UnitID.Substring(3, checkID.UnitID.Length - 3)) + 1;
id = "UIT" + String.Format("{0:00000000}", nextNo);
}
else
{
id = "UIT00000001";
}
item.UnitID = id;
item.UnitName = !string.IsNullOrEmpty(item.UnitName) ? item.UnitName.Trim() : "";
item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note.Trim() : "";
item.CreatedAt = DateTime.Now;
item.CreatedBy = currentUser.UserID;
item.UpdatedAt = DateTime.Parse("1900-01-01");
item.UpdatedBy = "";
item.Status = item.Status;
db.Insert<DC_AD_Unit>(item);
return Json(new { success = true, Code = item.UnitID, createdate = item.CreatedAt, createdby = item.CreatedBy });
}
else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
{
var success = db.Execute(@"UPDATE DC_AD_Unit SET Status = @Status,
Note = @Note, UpdatedAt = @UpdatedAt, UpdatedBy = @UpdatedBy, UnitName = @UnitName
WHERE UnitID = '" + item.UnitID + "'", new
{
Status = item.Status,
//WHName = !string.IsNullOrEmpty(item.WHName) ? item.WHName.Trim() : "",
Note = !string.IsNullOrEmpty(item.Note) ? item.Note.Trim() : "",
UpdatedAt = DateTime.Now,
UpdatedBy = currentUser.UserID,
UnitName = !string.IsNullOrEmpty(item.UnitName) ? item.UnitName.Trim() : "",
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Cập nhật không thành công." });
}
return Json(new { success = true });
}
else
return Json(new { success = false, message = "Bạn không có quyền" });
}
catch (Exception e)
{
log.Error(" ListPublication - Create - " + e.Message);
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}
示例4: ConfirmCreate
public ActionResult ConfirmCreate()
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Insert") && userAsset["Insert"])
{
try
{
string SONumber = Request["SONumber"];
var header = new SOHeader();
var detail = new SODetail();
if (string.IsNullOrEmpty(SONumber))
{
string datetimeSO = DateTime.Now.ToString("yyMMdd");
var existSO = dbConn.SingleOrDefault<SOHeader>("SELECT id, SONumber FROM SOHeader ORDER BY Id DESC");
if (existSO != null)
{
var nextNo = Int32.Parse(existSO.SONumber.Substring(8, 5)) + 1;
SONumber = "SO" + datetimeSO + String.Format("{0:00000}", nextNo);
}
else
{
SONumber = "SO" + datetimeSO + "00001";
}
}
if (!string.IsNullOrEmpty(Request["SODate"]))
{
DateTime fromDateValue;
if (!DateTime.TryParseExact(Request["SODate"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out fromDateValue))
{
return Json(new { message = "Ngày tạo không đúng." });
}
}
if (dbConn.Select<DC_OCM_Merchant>(p => p.MerchantID == Request["MerchantID"]).Count() <= 0)
{
return Json(new { success = false, message = "Nhà cung cấp không tồn tại." });
}
if (dbConn.Select<SODetail>(p => p.SONumber == SONumber).Count() > 0)
{
if (!string.IsNullOrEmpty(Request["ItemCode"]))
{
if (dbConn.Select<Products>(p => p.Code == Request["ItemCode"]).Count() <= 0)
{
return Json(new { success = false, message = "Ấn phẩm không tồn tại." });
}
var itemcode = dbConn.Select<Products>(s => s.Code == Request["ItemCode"]).FirstOrDefault();
var itemunit = dbConn.Select<Products>(s => s.UnitID == itemcode.Unit).FirstOrDefault();
if (dbConn.Select<SODetail>(p => p.ItemCode == Request["ItemCode"] && p.SONumber == SONumber).Count() > 0)
{
var success = dbConn.Execute(@"UPDATE SODetail Set Qty = @Qty, TotalAmt [email protected] ,UpdatedAt = @UpdatedAt, UpdatedBy = @UpdatedBy, Price = @Price
WHERE SONumber = '" + SONumber + "' AND ItemCode = '" + Request["ItemCode"] + "'", new
{
Qty = dbConn.Select<SODetail>(s => s.ItemCode == Request["ItemCode"] && s.SONumber == SONumber).Sum(s => s.Qty) + int.Parse(Request["Qty"]),
TotalAmt = itemcode != null ? itemcode.VATPrice * (dbConn.Select<SODetail>(s => s.ItemCode == Request["ItemCode"] && s.SONumber == SONumber).Sum(s => s.Qty) + int.Parse(Request["Qty"])) : 0,
Price = itemcode.VATPrice,
UpdatedBy = currentUser.UserID,
UpdatedAt = DateTime.Now,
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Không thể lưu" });
}
}
else
{
detail.SONumber = SONumber;
detail.ItemCode = !string.IsNullOrEmpty(Request["ItemCode"]) ? Request["ItemCode"] : "";
detail.ItemName = !string.IsNullOrEmpty(itemcode.Name) ? itemcode.Name : "";
detail.Price = itemcode != null ? itemcode.VATPrice : 0;
detail.Qty = int.Parse(Request["Qty"]);
detail.TotalAmt = itemcode.VATPrice * int.Parse(Request["Qty"]);
detail.UnitID = !string.IsNullOrEmpty(itemunit.UnitID) ? itemunit.UnitID : "";
detail.UnitName = !string.IsNullOrEmpty(itemunit.UnitName) ? itemunit.UnitName : "";
detail.Note = "";
detail.Status = "";
detail.CreatedBy = currentUser.UserID;
detail.CreatedAt = DateTime.Now;
detail.UpdatedBy = "";
detail.UpdatedAt = DateTime.Parse("1900-01-01");
dbConn.Insert<SODetail>(detail);
}
}
}
else
{
if (string.IsNullOrEmpty(Request["ItemCode"]) || dbConn.Select<Products>(p => p.Code == Request["ItemCode"]).Count() <= 0)
{
return Json(new { success = false, message = "Ấn phẩm không tồn tại." });
}
var itemcode = dbConn.Select<Products>(s => s.Code == Request["ItemCode"]).FirstOrDefault();
var itemunit = dbConn.Select<Products>(s => s.UnitID == itemcode.Unit).FirstOrDefault();
detail.SONumber = SONumber;
detail.ItemCode = !string.IsNullOrEmpty(Request["ItemCode"]) ? Request["ItemCode"] : "";
detail.ItemName = !string.IsNullOrEmpty(itemcode.Name) ? itemcode.Name : "";
detail.Price = itemcode != null ? itemcode.VATPrice :0 ;
detail.Qty = int.Parse(Request["Qty"]);
detail.TotalAmt = itemcode.VATPrice * int.Parse(Request["Qty"]);
detail.UnitID = !string.IsNullOrEmpty(itemunit.UnitID) ? itemunit.UnitID : "";
detail.UnitName = !string.IsNullOrEmpty(itemunit.UnitName) ? itemunit.UnitName : "";
//.........这里部分代码省略.........
示例5: CreatePO
public ActionResult CreatePO(string data, string printer, string delivery)
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Insert") && userAsset["Insert"])
{
try
{
string[] separators = { "@@" };
var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string PONumber = "";
string datetimeSO = DateTime.Now.ToString("yyMMdd");
var existSO = dbConn.SingleOrDefault<DC_AD_PO_Header>("SELECT id, PONumber FROM DC_AD_PO_Header ORDER BY Id DESC");
if (existSO != null)
{
var nextNo = Int32.Parse(existSO.PONumber.Substring(8, 5)) + 1;
PONumber = "PO" + datetimeSO + String.Format("{0:00000}", nextNo);
}
else
{
PONumber = "PO" + datetimeSO + "00001";
}
if (!string.IsNullOrEmpty(delivery))
{
DateTime fromDateValue;
if (!DateTime.TryParseExact(delivery, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out fromDateValue))
{
return Json(new { message = "Ngày tạo không đúng." });
}
}
var detail = new DC_AD_PO_Detail();
foreach (var item in listdata)
{
if (dbConn.Select<SOHeader>(s => s.Status != "Mới" && s.SONumber == item).Count() > 0)
{
return Json(new { success = false, message = "Không thể đặt hàng." });
}
foreach (var dtSO in dbConn.Select<SODetail>(s => s.SONumber == item).ToList())
{
if (dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber && s.ItemCode == dtSO.ItemCode).Count() > 0)
{
var success = dbConn.Execute(@"UPDATE DC_AD_PO_Detail Set Qty = @Qty, TotalAmt [email protected] ,UpdatedAt = @UpdatedAt, UpdatedBy = @UpdatedBy, Price = @Price
WHERE PONumber = '" + PONumber + "' AND ItemCode = '" + dtSO.ItemCode + "'", new
{
Qty = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber && s.ItemCode == dtSO.ItemCode).Sum(s => s.Qty) + dtSO.Qty,
TotalAmt = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber && s.ItemCode == dtSO.ItemCode).Sum(s => s.TotalAmt)+dtSO.TotalAmt,
Price = dtSO.Price,
UpdatedBy = currentUser.UserID,
UpdatedAt = DateTime.Now,
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Không thể lưu" });
}
}
else
{
detail.PONumber = PONumber;
detail.ItemCode = !string.IsNullOrEmpty(dtSO.ItemCode) ? dtSO.ItemCode : "";
detail.ItemName = !string.IsNullOrEmpty(dtSO.ItemName) ? dtSO.ItemName : "";
detail.Price = dtSO.Price;
detail.Qty = dtSO.Qty;
detail.TotalAmt = dtSO.TotalAmt;
detail.UnitID = !string.IsNullOrEmpty(dtSO.UnitID) ? dtSO.UnitID : "";
detail.UnitName = !string.IsNullOrEmpty(dtSO.UnitName) ? dtSO.UnitName : "";
detail.Note = "";
detail.Status = "Mới";
detail.CreatedBy = currentUser.UserID;
detail.CreatedAt = DateTime.Now;
detail.UpdatedBy = "";
detail.UpdatedAt = DateTime.Parse("1900-01-01");
dbConn.Insert<DC_AD_PO_Detail>(detail);
}
}
dbConn.Update<SOHeader>(set: "Status = N'Đã đặt hàng'", where: "SONumber = '" + item + "'");
}
var header = new DC_AD_PO_Header();
header.PONumber = PONumber;
header.PODate = DateTime.Now;
header.DeliveryDate = !string.IsNullOrEmpty(delivery) ? DateTime.Parse(DateTime.ParseExact(delivery, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd")) : DateTime.Now;
header.PrinterID = printer;
header.PrinterName = dbConn.Select<DC_AD_Printer>(s => s.PrinterID == printer).FirstOrDefault().PrinterName;
header.TotalQty = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber).Sum(s => s.Qty);
header.TotalAmt = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber).Sum(s => s.TotalAmt);
header.Note = "";
header.Status = "Nhà in đang xử lý";
header.CreatedBy = currentUser.UserID;
header.CreatedAt = DateTime.Now;
header.UpdatedBy = "";
header.UpdatedAt = DateTime.Parse("1900-01-01");
dbConn.Insert<DC_AD_PO_Header>(header);
}
catch (Exception ex)
{
return Json(new { success = false, message = ex.Message });
}
return Json(new { success = true });
}
else
{
//.........这里部分代码省略.........
示例6: UpdateDetail
public ActionResult UpdateDetail([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<DC_AD_Picking_Detail> list)
{
var dbConn = new OrmliteConnection().openConn();
try
{
if (list != null && ModelState.IsValid)
{
foreach (var item in list)
{
if (string.IsNullOrEmpty(item.PickingNumber))
{
ModelState.AddModelError("", "Số picking không tồn tại");
return Json(list.ToDataSourceResult(request, ModelState));
}
if (item.Qty <= 0)
{
ModelState.AddModelError("", "Số lượng phải lớn hơn 0.");
return Json(list.ToDataSourceResult(request, ModelState));
}
dbConn.Update<DC_AD_Picking_Detail>(set: "Qty = '" + item.Qty + "', TotalAmt = '" + item.Price * item.Qty + "'", where: "ID = '" + item.Id + "'");
var success = dbConn.Execute(@"UPDATE DC_AD_Picking_Header Set TotalQty = @TotalQty, TotalAmt [email protected]
WHERE PickingNumber = '" + item.PickingNumber +"'", new
{
TotalQty = dbConn.Select<DC_AD_Picking_Detail>(s => s.PickingNumber == item.PickingNumber).Sum(s => s.Qty),
TotalAmt = dbConn.Select<DC_AD_Picking_Detail>(s => s.PickingNumber == item.PickingNumber).Sum(s => s.TotalAmt),
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Không thể lưu" });
}
}
}
}
catch (Exception e)
{
ModelState.AddModelError("error", e.Message);
return Json(list.ToDataSourceResult(request, ModelState));
}
return Json(new { sussess = true });
}
示例7: UpdateDetail
public ActionResult UpdateDetail([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<SODetail> list)
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Update") && userAsset["Update"])
{
if (list != null)//&& ModelState.IsValid)
{
foreach (var item in list)
{
if (dbConn.Select<SOHeader>(s => s.SONumber == item.SONumber && s.Status != "Mới").Count() > 0)
{
return Json(new { success = false, message = "Đơn hàng đã xác nhận nên không được xóa." });
}
else if (item.Qty > 0)
{
var isExist = dbConn.SingleOrDefault<SODetail>("SONumber = {0} AND ItemCode = {1}", item.SONumber, item.ItemCode);
if (isExist != null)
{
try
{
isExist.Qty = item.Qty;
isExist.TotalAmt = item.Qty * item.Price;
isExist.UpdatedAt = DateTime.Now;
isExist.UpdatedBy = currentUser.UserID;
dbConn.Update<SODetail>(isExist);
//dbConn.Update<SODetail>(set: "Qty = '" + item.Qty + "', TotalAmt = '" + item.Qty * item.Price + "',UpdatedAt = '" + DateTime.Now + "', UpdatedBy ='" + currentUser.UserID + "'", where: "SONumber = '" + item.SONumber + "' AND ItemCode ='" + item.ItemCode + "'");
dbConn.Update<SOHeader>(set: "UpdatedBy='" + currentUser.UserID + "',TotalQty ='" + dbConn.Select<SODetail>(s => s.SONumber == item.SONumber).Sum(s => s.Qty) + "', TotalAmt = '" + dbConn.Select<SODetail>(s => s.SONumber == item.SONumber).Sum(s => s.TotalAmt) + "'", where: "SONumber ='" + item.SONumber + "'");
var success = dbConn.Execute(@"UPDATE SOHeader Set UpdatedAt = @UpdatedAt WHERE SONumber = '" + item.SONumber + "'",
new
{
UpdatedAt = DateTime.Now,
}) == 1;
}
catch (Exception ex)
{
ModelState.AddModelError("error", ex.Message);
return Json(list.ToDataSourceResult(request, ModelState));
}
}
}
else
{
ModelState.AddModelError("error", "Đơn hàng được tạo khi số lượng > 0");
return Json(list.ToDataSourceResult(request, ModelState));
}
}
}
dbConn.Close();
return Json(new { sussess = true });
}
else
{
dbConn.Close();
ModelState.AddModelError("error", "Bạn không có quyền cập nhật.");
return Json(list.ToDataSourceResult(request, ModelState));
}
}