public ActionResult SaveTrans(OrderTrans vm) { int pk = OrderService.fnSaveTrans(vm); return Content("Transaction Saved at " + System.DateTime.Now.ToString()); }
public static OrderTrans fnCreateTrans(int id) { // id=orderid using (var db = new EF.CMCSQL03Entities()) { var vm = new OrderTrans(); var cl = (from t in db.tblOrderMaster where t.OrderID == id select t).FirstOrDefault(); vm.ordertransid = -1; vm.orderid = id; vm.createdate = System.DateTime.Now; vm.transdate = System.DateTime.Now.Date; vm.createuser = HttpContext.Current.User.Identity.Name; vm.clientid = cl.ClientID; // vm.ListOfOrderTransTypes = fnListOfOrderTransTypes(); return vm; } }
public static OrderTrans fnFillTrans(int id) { OrderTrans vm = new OrderTrans(); using (var db = new EF.CMCSQL03Entities()) { var qry = (from t in db.tblOrderTrans where t.OrderTransID == id select t).FirstOrDefault(); vm.ordertransid = qry.OrderTransID; vm.orderid = qry.OrderID; vm.orderitemid = qry.OrderItemID; vm.clientid = qry.ClientID; vm.transdate = qry.TransDate; vm.transtype = qry.TransType; vm.transqty = qry.TransQty; vm.transamount = qry.TransAmount; vm.comments = qry.Comments; vm.createdate = qry.CreateDate; vm.createuser = qry.CreateUser; vm.updatedate = qry.UpdateDate; vm.updateuser = qry.UpdateUser; return vm; } }
public static int fnSaveTrans(OrderTrans vm) { using (var db = new EF.CMCSQL03Entities()) { if (vm.ordertransid == -1) { EF.tblOrderTrans newrec = new EF.tblOrderTrans(); db.tblOrderTrans.Add(newrec); vm.createdate = System.DateTime.Now; vm.createuser = HttpContext.Current.User.Identity.Name; db.SaveChanges(); vm.ordertransid = newrec.OrderTransID; } vm.updatedate = System.DateTime.Now; vm.updateuser = HttpContext.Current.User.Identity.Name; var d = (from t in db.tblOrderTrans where t.OrderTransID == vm.ordertransid select t).FirstOrDefault(); d.OrderID = vm.orderid; d.OrderItemID = vm.orderitemid; d.ClientID = vm.clientid; d.TransDate = vm.transdate; d.TransType = vm.transtype; d.TransQty = vm.transqty; d.TransAmount = vm.transamount; d.Comments = vm.comments; d.CreateDate = vm.createdate; d.CreateUser = vm.createuser; d.UpdateDate = vm.updatedate; d.UpdateUser = vm.updateuser; db.SaveChanges(); return vm.ordertransid; } }