当前位置: 首页>>代码示例>>C#>>正文


C# OrmliteConnection.Update方法代码示例

本文整理汇总了C#中SES.Service.OrmliteConnection.Update方法的典型用法代码示例。如果您正苦于以下问题:C# OrmliteConnection.Update方法的具体用法?C# OrmliteConnection.Update怎么用?C# OrmliteConnection.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SES.Service.OrmliteConnection的用法示例。


在下文中一共展示了OrmliteConnection.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CancelSalesOrder

        public ActionResult CancelSalesOrder(string data)
        {
            var dbConn = new OrmliteConnection().openConn();
            if (userAsset.ContainsKey("Insert") && userAsset["Insert"])
            {
                try
                {
                    string[] separators = { "@@" };
                    var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in listdata)
                    {
                        if (dbConn.Select<SOHeader>("Select * from SOHeader where Status <> N'Mới' AND SONumber = '"+item+"'").Count() > 0)
                        {
                            return Json(new { success = false, message = "Chỉ hủy được các mẫu tin có trạng thái Mới" });
                        }

                        dbConn.Update<SOHeader>(set: "Status = N'Hủy'", where: "SONumber = '" + item + "'");
                    }
                }
                catch (Exception e)
                {
                    return Json(new { success = false, message = e.Message });
                }
                return Json(new{success = true});
            }
            else{
                return Json(new { success = false, message = "Bạn không có quyền hủy." });
            }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:29,代码来源:AD_OrderController.cs

示例2: Create

        public ActionResult Create([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<Models.Master_Calendar> lst)
        {
            IDbConnection dbConn = new OrmliteConnection().openConn();

            try
            {
                foreach (var item in lst)
                {
                    if (userAsset.ContainsKey("Update") && userAsset["Update"] && dbConn.GetByIdOrDefault<Master_Calendar>(item.Date) != null)
                    {
                        if (string.IsNullOrEmpty(item.Holiday))
                        {
                            item.Holiday = "";
                        }
                        item.RowUpdatedAt = DateTime.Now;
                        item.RowUpdatedBy = currentUser.UserID;
                        dbConn.Update<Master_Calendar>(item);
                    }
                    else
                        return Json(new { success = false, message = "You don't have permission" });
                }
                return Json(new { success = true });
            }
            catch (Exception ex)
            {
                log.Error("AdminMasterHoliday - Create - " + ex.Message);
                return Json(new { success = false, message = ex.Message });
            }
            finally
            {
                dbConn.Close();
            }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:33,代码来源:AdminMasterHolidayController.cs

示例3: Create

 public ActionResult Create(DC_LG_Discountion item)
 {
     IDbConnection db = new OrmliteConnection().openConn();
     try
     {
         if (!string.IsNullOrEmpty(item.DiscountionID) &&
             !string.IsNullOrEmpty(item.DiscountionName)
             )
         {
             var isExist = db.SingleOrDefault<DC_LG_Discountion>("DiscountionID={0}", item.DiscountionID);
             item.FromDate = item.FromDate != null ? item.FromDate : DateTime.Now;
             item.EndDate = item.EndDate != null ? item.EndDate : DateTime.Now;
             item.EndDate = item.EndDate != null ? item.EndDate : DateTime.Now;
             if (item.FromDate > item.EndDate)
             {
                 return Json(new { success = false, message = "Ngày kết thúc không thể lớn hơn " + item.FromDate });
             }
             item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : "";
             item.DiscountionType = !string.IsNullOrEmpty(item.DiscountionType) ? item.DiscountionType : "";
             if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null)
             {
                 if (isExist != null)
                     return Json(new { success = false, message = "Mã chương trình chiết khấu đã tồn tại" });
                 item.DiscountionName = !string.IsNullOrEmpty(item.DiscountionName) ? item.DiscountionName : "";
                 item.CreatedAt = DateTime.Now;
                 item.UpdatedAt = DateTime.Now;
                 item.CreatedBy = currentUser.UserID;
                 db.Insert(item);
                 return Json(new { success = true, DiscountionID = item.DiscountionID, CreatedBy = item.CreatedBy, CreatedAt = item.CreatedAt });
             }
             else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
             {
                 item.DiscountionName = !string.IsNullOrEmpty(item.DiscountionName) ? item.DiscountionName : "";
                 item.CreatedAt = item.CreatedAt;
                 item.UpdatedAt = DateTime.Now;
                 item.CreatedBy = currentUser.UserID;
                 db.Update(item);
                 return Json(new { success = true });
             }
             else
                 return Json(new { success = false, message = "Bạn không có quyền" });
         }
         else
         {
             return Json(new { success = false, message = "Chưa nhập đủ giá trị" });
         }
     }
     catch (Exception e)
     {
         log.Error("DeliveryDiscountion - Create - " + e.Message);
         return Json(new { success = false, message = e.Message });
     }
     finally { db.Close(); }
 }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:54,代码来源:DeliveryDiscountController.cs

示例4: CompletePicking

        public ActionResult CompletePicking(string data)
        {
            var dbConn = new OrmliteConnection().openConn();
            if (userAsset.ContainsKey("Update") && userAsset["Update"])
            {
                try
                {
                    string[] separators = { "@@" };
                    var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in listdata)
                    {
                        if (dbConn.Select<DC_AD_Picking_Header>(s => s.Status == "Hoàn thành" && s.PickingNumber == item).Count() > 0)
                        {
                            return Json(new { success = false, message = item + " đã được hoàn thành trước đó." });
                        }

                        if (dbConn.Select<DC_AD_Picking_Header>(s =>s.Status != "Đang giao hàng" && s.PickingNumber==item).Count() > 0)
                        {
                            return Json(new { success = false, message = item + " vui lòng nhập kho trước khi hoàn thành." });
                        }

                        dbConn.Update<DC_AD_Picking_Header>(set: "Status = N'Hoàn thành', UpdatedBy ='" + currentUser.UserID + "', UpdatedAt= '"+DateTime.Now+"'", where: "PickingNumber = '" + item + "'");
                        foreach (var so in dbConn.Select<DC_AD_Picking_Detail>(s => s.PickingNumber == item).ToList())
                        {
                            dbConn.Update<SOHeader>(set: "Status = N'Hoàn thành'", where: "SONumber = '" + so.SONumber + "'");
                        }
                        //dbConn.Update<DC_AD_SO_Header>(set: "Status = N'Hoàn thành'", where: "SONumber = '" + item + "'");
                    }
                }
                catch (Exception e)
                {
                    return Json(new { success = false, message = e.Message });
                }
                return Json(new { success = true });
            }
            else
            {
                return Json(new { success = false, message = "Bạn không có quyền hủy." });
            }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:40,代码来源:AD_PickingListController.cs

示例5: Create

 //
 // GET: /DeliveryManage/Create
 public ActionResult Create(DC_LG_Transporter item)
 {
     IDbConnection db = new OrmliteConnection().openConn();
     try
     {
         if (//!string.IsNullOrEmpty(item.TransporterID) &&
             !string.IsNullOrEmpty(item.TransporterName)
             )
         {
             int n;
             var isExist = db.SingleOrDefault<DC_LG_Transporter>("TransporterID={0}",item.TransporterID);
             item.Weight = int.TryParse(item.Weight.ToString(),out n) ? item.Weight : 0;
             item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : "";
             if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null)
             {
                 if(isExist != null)
                     return Json(new { success = false, message = "Mã đơn vị vận chuyển đã tồn tại!" });
                 item.TransporterName = !string.IsNullOrEmpty(item.TransporterName) ? item.TransporterName : "";
                 item.CreatedAt = DateTime.Now;
                 item.UpdatedAt = DateTime.Now;
                 item.CreatedBy = currentUser.UserID;
                 item.UpdatedBy = currentUser.UserID;
                 db.Insert(item);
                 return Json(new { success = true, TransporterID = item.TransporterID, CreatedBy = item.CreatedBy, CreatedAt = item.CreatedAt });
             }
             else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
             {
                 item.TransporterName = !string.IsNullOrEmpty(item.TransporterName) ? item.TransporterName : "";
                 item.CreatedAt = item.CreatedAt;
                 item.UpdatedAt = DateTime.Now;
                 item.CreatedBy = currentUser.UserID;
                 item.UpdatedBy = currentUser.UserID;
                 db.Update(item);
                 return Json(new { success = true });
             }
             else
                 return Json(new { success = false, message = "Bạn không có quyền" });
         }
         else
         {
             return Json(new { success = false, message = "Chưa nhập giá trị" });
         }
     }
     catch (Exception e)
     {
         log.Error("Transporter - Create - " + e.Message);
         return Json(new { success = false, message = e.Message });
     }
     finally { db.Close(); }
 }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:52,代码来源:TransporterController.cs

示例6: Create

 //
 // GET: /DeliveryManage/Create
 public ActionResult Create(DC_Reason item)
 {
     IDbConnection db = new OrmliteConnection().openConn();
     try
     {
         if (!string.IsNullOrEmpty(item.ReasonID) && item.ReasonType!="None")
         {
             var isExist = db.GetByIdOrDefault<DC_Reason>(item.ReasonID);
             item.Description = !string.IsNullOrEmpty(item.Description) ? item.Description : "";
             if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.RowCreatedAt == null && item.RowCreatedBy == null)
             {
                 if (isExist != null)
                     return Json(new { success = false, message = "Mã lý do đã tồn tại!" });
                 item.ReasonType = !string.IsNullOrEmpty(item.ReasonType) ? item.ReasonType : "";
                 item.RowCreatedAt = DateTime.Now;
                 item.RowUpdatedAt = DateTime.Now;
                 item.RowCreatedBy = currentUser.UserID;
                 db.Insert<DC_Reason>(item);
                 return Json(new { success = true, ReasonID = item.ReasonID, RowCreatedBy = item.RowCreatedBy, RowCreatedAt = item.RowCreatedAt });
             }
             else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
             {
                 item.ReasonType = !string.IsNullOrEmpty(item.ReasonType) ? item.ReasonType : "";
                 item.RowCreatedAt = item.RowCreatedAt;
                 item.RowUpdatedAt = DateTime.Now;
                 item.RowCreatedBy = currentUser.UserID;
                 db.Update<DC_Reason>(item);
                 return Json(new { success = true });
             }
             else
                 return Json(new { success = false, message = "Bạn không có quyền" });
         }
         else
         {
             return Json(new { success = false, message = "Chưa nhập giá trị" });
         }
     }
     catch (Exception e)
     {
         log.Error("DeliveryUOMManage - Create - " + e.Message);
         return Json(new { success = false, message = e.Message });
     }
     finally { db.Close(); }
 }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:46,代码来源:ReasonController.cs

示例7: 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
            {
//.........这里部分代码省略.........
开发者ID:kenvinnguyen,项目名称:SES,代码行数:101,代码来源:AD_OrderController.cs

示例8: Create

        public ActionResult Create(FormCollection form)
        {
            IDbConnection db = new OrmliteConnection().openConn();
            try
            {
                if (!string.IsNullOrEmpty(form["RoleName"]))
                {
                    var item = new Auth_Role();
                    item.RoleName = form["RoleName"];
                    item.IsActive = form["IsActive"] != null ? Convert.ToBoolean(form["IsActive"]) : false;
                    item.Note = !string.IsNullOrEmpty(form["Note"]) ? form["Note"] : "";
                    if (userAsset.ContainsKey("Insert") && userAsset["Insert"] &&
                        string.IsNullOrEmpty(form["RoleID"]))    // Tạo mới
                    {
                        item.RowCreatedAt = DateTime.Now;
                        item.RowCreatedBy = currentUser.UserID;
                        db.Insert<Auth_Role>(item);
                        long lastID = db.GetLastInsertId();
                        if (lastID > 0)
                        {
                            // Thêm Role vào Auth_Action
                            db.ExecuteSql("EXEC p_Auth_Role_GenerateAction_By_RoleID " + lastID + "," + currentUser.UserID);
                        }
                        return Json(new { success = true, insert = true, RoleID = lastID, createdat = item.RowCreatedAt, createdby = item.RowCreatedBy });
                    }
                    else if (userAsset.ContainsKey("Insert") && userAsset["Insert"] &&
                            Convert.ToInt32(form["RoleID"]) > 0 &&
                            Convert.ToInt32(form["IsCopy"]) == 1)  // Sao chép
                    {
                        item.RoleID = Convert.ToInt32(form["RoleID"]);
                        item.RowCreatedAt = DateTime.Now;
                        item.RowCreatedBy = currentUser.UserID;
                        db.Insert<Auth_Role>(item);
                        long lastID = db.GetLastInsertId();
                        if (lastID > 0)
                        {
                            // Sao chép Action RoleID đã chọn vào RoleID vừa tạo
                            db.ExecuteSql("p_Auth_Role_CopyAction_By_RoleID " + item.RoleID + "," + lastID + "," + currentUser.UserID);
                        }
                        return Json(new { success = true, insert = true, RoleID = lastID, createdat = item.RowCreatedAt, createdby = item.RowCreatedBy });
                    }
                    else if (userAsset.ContainsKey("Update") && userAsset["Update"] &&
                            Convert.ToInt32(form["RoleID"]) > 0)    // Cập nhật
                    {
                        item.RoleID = Convert.ToInt32(form["RoleID"]);
                        item.RowCreatedAt = DateTime.Parse(form["RowCreatedAt"]);
                        item.RowCreatedBy = form["RowCreatedBy"];
                        item.RowUpdatedAt = DateTime.Now;
                        item.RowUpdatedBy = currentUser.UserID;
                        if (item.RowCreatedBy != "system")
                        {
                            db.Update<Auth_Role>(item);
                        }

                        return Json(new { success = true, RoleID = item.RoleID });
                    }
                    else
                        return Json(new { success = false, message = "Bạn không có quyền" });
                }
                else
                {
                    return Json(new { success = false, message = "Chưa nhập giá trị" });
                }
            }
            catch (Exception e)
            {
                log.Error("HOAdminAuthRole - Create - " + e.Message);
                return Json(new { success = false, message = e.Message });
            }
            finally { db.Close(); }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:71,代码来源:AD_RoleController.cs

示例9: Update

        //public ActionResult ReadDetail([DataSourceRequest] DataSourceRequest request, string SONumber)
        //{
        //    log4net.Config.XmlConfigurator.Configure();
        //    string whereCondition = "";
        //    if (request.Filters.Count > 0)
        //    {
        //        whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]);
        //    }
        //    var data = new DC_AD_SO_Detail().GetPage(request, whereCondition, SONumber);
        //    return Json(data);
        //}
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<Products> list, string SONumber)
        {
            var dbConn = new OrmliteConnection().openConn();
            try
            {
                if (list != null && ModelState.IsValid)
                {
                    foreach (var item in list)
                    {
                        if (item.Qty > 0)
                        {
                            //string SONumber = Request["SONumber"];
                            var header = new SOHeader();
                            var detail = new SODetail();

                            if (dbConn.Select<SODetail>(s => s.SONumber == SONumber && s.ItemCode == item.Code).Count() > 0)
                            {
                                dbConn.Update<SODetail>(set: "Qty = '" + item.Qty + "', TotalAmt = '" + item.Qty * item.Price + "'", where: "SONumber = '" + SONumber + "'");
                            }
                            else
                            {
                                var data = new SODetail();
                                data.ItemName = item.Name;
                                data.ItemCode = item.Code;
                                data.Note = "";
                                data.Price = item.VATPrice;
                                data.Qty = item.Qty;
                                data.SONumber = SONumber;
                                data.UnitID = item.Unit;
                                data.UnitName = dbConn.Select<INUnit>(s => s.UnitID == item.Unit).FirstOrDefault().UnitName;
                                data.TotalAmt = item.Qty * item.VATPrice;
                                data.Status = "";
                                data.CreatedAt = DateTime.Now;
                                data.CreatedBy = currentUser.UserID;
                                //data.UpdatedAt = DateTime.Parse("1900-01-01");
                                data.UpdatedAt = DateTime.Now;
                                data.UpdatedBy = "";
                                dbConn.Insert<SODetail>(data);
                            }
                            dbConn.Update<SOHeader>(set: "TotalQty ='" + dbConn.Select<SODetail>(s => s.SONumber == SONumber).Sum(s => s.Qty) + "', TotalAmt = '" + +dbConn.Select<SODetail>(s => s.SONumber == SONumber).Sum(s => s.TotalAmt) + "'", where: "SONumber ='" + SONumber + "'");

                        }
                        else
                        {
                            dbConn.Delete<SOHeader>(s => s.SONumber == SONumber);
                            ModelState.AddModelError("error", "Đơn hàng được tạo khi số lượng > 0");
                            return Json(list.ToDataSourceResult(request, ModelState));
                        }
                    }
                }
                dbConn.Close();
            }
            catch (Exception e)
            {
                dbConn.Close();
                ModelState.AddModelError("error", e.Message);
                return Json(list.ToDataSourceResult(request, ModelState));
            }
            return Json(new { sussess = true });
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:71,代码来源:OP_SalesOrderController.cs

示例10: Create

        public ActionResult Create(DC_Formula item)
        {
            IDbConnection db = new OrmliteConnection().openConn();
            try
            {
                if (!string.IsNullOrEmpty(item.FormulaName) && !string.IsNullOrEmpty(item.Formula))
                {
                    var isExist = db.SingleOrDefault<DC_Formula>("FormulaID={0}", item.FormulaID);
                    item.FormulaName = !string.IsNullOrEmpty(item.FormulaName) ? item.FormulaName : "";
                    item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : "";
                    item.Formula = !string.IsNullOrEmpty(item.Formula) ? item.Formula : "";

                    if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null)
                    {
                        if (isExist != null)
                            return Json(new { success = false, message = "Mã công thức đã tồn tại!" });

                        string id = "";
                        var checkID = db.SingleOrDefault<DC_Formula>("SELECT FormulaID,ID FROM DC_Formula ORDER BY ID DESC");
                        if (checkID != null)
                        {
                            var nextNo = int.Parse(checkID.FormulaID.Substring(2, checkID.FormulaID.Length - 2)) + 1;
                            id = "FM" + String.Format("{0:000000}", nextNo);
                        }
                        else
                        {
                            id = "FM000001";
                        }
                        item.FormulaID = id;
                        item.FormulaName = !string.IsNullOrEmpty(item.FormulaName) ? item.FormulaName : "";
                        item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : "";
                        item.Formula = !string.IsNullOrEmpty(item.Formula) ? item.Formula : "";
                        item.CreatedAt = DateTime.Now;
                        item.CreatedBy = currentUser.UserID;
                        item.UpdatedAt = DateTime.Parse("1900-01-01");
                        item.UpdatedBy = "";
                        db.Insert(item);
                        return Json(new { success = true, FormulaID = item.FormulaID, CreatedBy = item.CreatedBy, CreatedAt = item.CreatedAt });
                    }
                    else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
                    {
                        item.FormulaName = !string.IsNullOrEmpty(item.FormulaName) ? item.FormulaName : "";
                        item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : "";
                        item.Formula = !string.IsNullOrEmpty(item.Formula) ? item.Formula : "";
                        item.Status = item.Status;
                        item.CreatedAt = item.CreatedAt;
                        item.CreatedBy = currentUser.UserID;
                        item.UpdatedAt = DateTime.Now;
                        item.UpdatedBy = currentUser.UserID;
                        db.Update(item);
                        return Json(new { success = true });
                    }
                    else
                        return Json(new { success = false, message = "Bạn không có quyền" });
                }
                else
                {
                    return Json(new { success = false, message = "Chưa nhập đủ giá trị" });
                }
            }
            catch (Exception e)
            {
                log.Error("Formula" + item.FormulaID + " - Create - " + e.Message);
                return Json(new { success = false, message = e.Message });
            }
            finally { db.Close(); }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:67,代码来源:DeliveryFormulaController.cs

示例11: Create

        public ActionResult Create(Master_Announcement item)
        {
            //if (form.AllKeys.Contains("TextContent"))
            //{
            //    item.TextContent = form.Get("TextContent");
            //}

            //CHECK IS NULL VALUE
            if (string.IsNullOrEmpty(item.TextContent))
            {
                item.TextContent = "";
            }
            if (string.IsNullOrEmpty(item.HTMLContent))
            {
                item.HTMLContent = "";
            }
            if (string.IsNullOrEmpty(item.Title))
            {
                item.Title = "";
            }

            IDbConnection dbConn = new OrmliteConnection().openConn();

            try
            {
                    var isExist = dbConn.GetByIdOrDefault<Master_Announcement>(item.AnnouncementID);

                    if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null)
                    {
                        if (isExist != null)
                        {
                            return Json(new { success = false, message = "Đối tượng này đã tồn tại." });
                        }
                        item.CreatedAt = DateTime.Now;
                        item.CreatedBy = currentUser.UserID;

                        dbConn.Insert<Master_Announcement>(item);
                        long lastInsertId = dbConn.GetLastInsertId();
                        dbConn.Close();
                        return Json(new { success = true, AnnouncementID = lastInsertId, createdat = item.CreatedAt, createdby = item.CreatedBy });
                    }
                    else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
                    {
                        item.UpdatedAt = DateTime.Now;
                        item.CreatedBy = currentUser.UserID;
                        dbConn.Update<Master_Announcement>(item);
                        dbConn.Close();
                        return Json(new { success = true });
                    }
                    else
                        return Json(new { success = false, message = "You don't have permission" });
            }
            catch (Exception ex)
            {
                log.Error("AD_Announcement - Create - " + ex.Message);
                return Json(new { success = false, message = ex.Message });
            }
            finally
            {
                dbConn.Close();
            }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:62,代码来源:AD_AnnouncementController.cs

示例12: Create

        public ActionResult Create(Auth_User item)
        {
            IDbConnection db = new OrmliteConnection().openConn();
            try
            {
                if (!string.IsNullOrEmpty(item.UserID) &&
                    !string.IsNullOrEmpty(item.DisplayName) &&
                    !string.IsNullOrEmpty(item.FullName))
                {
                    var isExist = db.GetByIdOrDefault<Auth_User>(item.UserID);
                    item.Phone = !string.IsNullOrEmpty(item.Phone) ? item.Phone : "";
                    item.Email = !string.IsNullOrEmpty(item.Email) ? item.Email : "";
                    item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : "";
                    if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.RowCreatedAt == null && item.RowCreatedBy == null)
                    {
                        if(isExist != null)
                            return Json(new { success = false, message = "Người dùng đã tồn tại." });
                        item.Password = SqlHelper.GetMd5Hash("123456");
                        item.RowCreatedAt = DateTime.Now;
                        item.RowCreatedBy = currentUser.UserID;
                        db.Insert<Auth_User>(item);
                        return Json(new { success = true, UserID = item.UserID, RowCreatedAt = item.RowCreatedAt, RowCreatedBy = item.RowCreatedBy });
                    }
                    else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
                    {
                        item.Password = isExist.Password;
                        item.RowUpdatedAt = DateTime.Now;
                        item.RowUpdatedBy = currentUser.UserID;

                        if (isExist.RowCreatedBy != "system")
                        {
                            db.Update<Auth_User>(item);
                        }
                        else
                        {
                            return Json(new { success = false, message = "Dữ liệu này không cho chỉnh sửa liên hệ admin để biết thêm chi tiết" });
                        }
                        return Json(new { success = true });
                    }
                    else
                        return Json(new { success = false, message = "Bạn không có quyền" });
                }
                else
                {
                    return Json(new { success = false, message = "Chưa nhập giá trị" });
                }
            }
            catch (Exception e)
            {
                log.Error("AD_User - Create - " + e.Message);
                return Json(new { success = false, message = e.Message });
            }
            finally { db.Close(); }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:54,代码来源:AD_UserController.cs

示例13: 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 });
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:41,代码来源:AD_PickingListController.cs

示例14: PickingOut

 public ActionResult PickingOut(string data, string WHID, string WHLID)
 {
     var dbConn = new OrmliteConnection().openConn();
     try
     {
         string[] separators = { "@@" };
         var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
         string TransactionID = "";
         string datetimeSO = DateTime.Now.ToString("yyMMdd");
         var existSO = dbConn.SingleOrDefault<DC_AD_Transaction>("SELECT id, TransactionID FROM DC_AD_Transaction ORDER BY Id DESC");
         var detail = new DC_AD_Transaction();
         if (existSO != null)
         {
             var nextNo = Int32.Parse(existSO.TransactionID.Substring(8, 5)) + 1;
             TransactionID = "TS" + datetimeSO + String.Format("{0:00000}", nextNo);
         }
         else
         {
             TransactionID = "TS" + datetimeSO + "00001";
         }
         foreach (var item in listdata)
         {
             if (dbConn.Select<DC_AD_Picking_Header>(s => s.Status != "Mới" && s.PickingNumber == item).Count() > 0)
             {
                 return Json(new { success = false, message = item + " đã được nhập kho rồi." });
             }
             foreach (var po in dbConn.Select<DC_AD_Picking_Detail>(s => s.PickingNumber == item).ToList())
             {
                 detail.TransactionID = TransactionID;
                 detail.TransactionType = "Out";
                 detail.TransactionDate = DateTime.Now;
                 detail.RefID = item;
                 detail.ItemCode = !string.IsNullOrEmpty(po.ItemCode) ? po.ItemCode : "";
                 detail.ItemName = !string.IsNullOrEmpty(po.ItemName) ? po.ItemName : "";
                 detail.UnitID = !string.IsNullOrEmpty(po.UnitID) ? po.UnitID : "";
                 detail.UnitName = !string.IsNullOrEmpty(po.UnitName) ? po.UnitName : "";
                 detail.Qty = po.Qty != null ? po.Qty : 0;
                 detail.Price = po.Price != null ? po.Price : 0;
                 detail.TotalAmt = po.TotalAmt != null ? po.TotalAmt : 0;
                 detail.WHID = !string.IsNullOrEmpty(WHID) ? WHID : "";
                 detail.WHLID = !string.IsNullOrEmpty(WHLID) ? WHLID : "";
                 detail.Note = !string.IsNullOrEmpty(po.Note) ? po.Note : "";
                 detail.Status = "Đang giao hàng";
                 detail.CreatedBy = currentUser.UserID;
                 detail.CreatedAt = DateTime.Now;
                 detail.UpdatedBy = "";
                 detail.UpdatedAt = DateTime.Parse("1900-01-01");
                 detail.PrinterID = dbConn.Select<DC_AD_Picking_Header>(s => s.PickingNumber == item).FirstOrDefault().PrinterID;
                 detail.PrinterName = dbConn.Select<DC_AD_Picking_Header>(s => s.PickingNumber == item).FirstOrDefault().PrinterName;
                 dbConn.Insert<DC_AD_Transaction>(detail);
                 dbConn.Update<SOHeader>(set: "Status = N'Đang giao hàng'", where: "SONumber = '" + po.SONumber + "'");
             }
             dbConn.Update<DC_AD_Picking_Header>(set: "Status = N'Đang giao hàng'", where: "PickingNumber = '" + item + "'");
         }
     }
     catch (Exception e)
     {
         return Json(new { success = false, message = e.Message });
     }
     return Json(new { success = true });
 }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:61,代码来源:AD_PickingListController.cs

示例15: 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));
            }
        }
开发者ID:kenvinnguyen,项目名称:SES,代码行数:58,代码来源:OP_SalesOrderController.cs


注:本文中的SES.Service.OrmliteConnection.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。