示例#1
0
        public ActionResult Position_Update([DataSourceRequest] DataSourceRequest request,
                                            [Bind(Prefix = "models")] IEnumerable <ERPAPD_Employee> listEmplyee)
        {
            IEnumerable <ERPAPD_Employee> u = new ERPAPD_Employee[] { };

            if (asset.Create)
            {
                if (listEmplyee != null && ModelState.IsValid)
                {
                    var w = new CRM_Position();
                    foreach (var team in listEmplyee)
                    {
                        //var list = CRM_Position.GetCRM_Position(team.PositionID);
                        //list.LastUpdatedUser = currentUser.UserName;
                        //list.LastUpdatedDateTime = DateTime.Now;
                        //list.PositionName = team.PositionName;
                        //list.Active = team.Active;
                        //list.Update();
                    }
                    return(Json(new { success = true }));
                }
                ModelState.AddModelError("", "Model not valid");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
            else
            {
                ModelState.AddModelError("", "You don't have permission to create record");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
        }
示例#2
0
        public ActionResult Create22([DataSourceRequest] DataSourceRequest request,
                                     [Bind(Prefix = "models")] IEnumerable <ERPAPD_Employee> listEmplyee)
        {
            IEnumerable <ERPAPD_Employee> u = new ERPAPD_Employee[] { };
            var dbConn = Helpers.OrmliteConnection.openConn();

            if (asset.Create)
            {
                if (listEmplyee != null && ModelState.IsValid)
                {
                    var w = new ERPAPD_Employee();
                    if (w.Name == null)
                    {
                        w.Name = "";
                    }
                    foreach (var team in listEmplyee)
                    {
                        //w.RowCreatedAt = DateTime.Now;
                        //w.RowCreatedUser = currentUser.UserName;
                        //w.RowUpdatedUser = "";
                        //w.RowUpdatedAt = DateTime.Parse("1900-01-01");
                        //dbConn.Insert(w);
                    }
                    return(Json(new { success = true }));
                }
                ModelState.AddModelError("", "Model not valid");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
            else
            {
                ModelState.AddModelError("", "You don't have permission to create record");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
        }
示例#3
0
 public ActionResult Create(ERPAPD_Employee item)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
         using (var dbTrans = dbConn.OpenTransaction(IsolationLevel.ReadCommitted))
             if (asset.Create && ModelState.IsValid)
             {
                 try
                 {
                     string datetimeEmp = DateTime.Now.ToString("yyyyMMdd");
                     var    EmployID    = "";
                     var    existEm     = dbConn.SingleOrDefault <ERPAPD_Employee>("SELECT RowID, PKEmployeeID FROM ERPAPD_Employee ORDER BY RowID DESC");
                     if (existEm != null)
                     {
                         var nextNo = Int32.Parse(existEm.PKEmployeeID.Substring(12, 4)) + 1;
                         EmployID = "NVKD" + datetimeEmp + String.Format("{0:0000}", nextNo);
                     }
                     else
                     {
                         EmployID = "NVKD" + datetimeEmp + "0001";
                     }
                     if (!item.IsActive)
                     {
                         item.Status = 0;
                     }
                     else
                     {
                         item.Status = 1;
                     }
                     item.PKEmployeeID   = EmployID;
                     item.Display        = 1;
                     item.RowCreatedAt   = DateTime.Now;
                     item.RowCreatedUser = currentUser.UserName;
                     item.RowUpdatedAt   = DateTime.Parse("1900-01-01");
                     item.DateOff        = DateTime.Parse("1900-01-01");
                     item.FKUnit         = item.FKUnit;
                     item.RowUpdatedUser = "";
                     dbConn.Insert(item);
                     dbTrans.Commit();
                     return(Json(new { error = false, message = Resources.Multi.Success }));
                 }
                 catch (Exception ex)
                 {
                     dbTrans.Rollback();
                     return(Json(new { error = true, message = ex.Message }));
                 }
             }
             else
             {
                 if (!asset.Create)
                 {
                     return(Json(new { error = true, message = "Không có quyền tạo mới." }));
                 }
                 string message = "";
                 foreach (ModelState modelState in ViewData.ModelState.Values)
                 {
                     foreach (ModelError error in modelState.Errors)
                     {
                         message += error.ErrorMessage + " ";
                     }
                 }
                 return(Json(new { error = true, message = message }));
             }
 }
示例#4
0
 public ActionResult Edit(ERPAPD_Employee item)
 {
     using (var dbConn = Helpers.OrmliteConnection.openConn())
         using (var dbTrans = dbConn.OpenTransaction(IsolationLevel.ReadCommitted))
             if (asset.Update && ModelState.IsValid)
             {
                 try
                 {
                     var existEm = dbConn.SingleOrDefault <ERPAPD_Employee>("SELECT * FROM ERPAPD_Employee WHERE PKEmployeeID='" + item.PKEmployeeID + "'");
                     if (!item.IsActive)
                     {
                         existEm.Status = 0;
                     }
                     else
                     {
                         existEm.Status = 1;
                     }
                     if (!item.isDisplay)
                     {
                         existEm.Display = 0;
                     }
                     else
                     {
                         existEm.Display = 1;
                     }
                     if (item.isStatusOff)
                     {
                         existEm.StatusOff = 1;
                         existEm.DateOff   = DateTime.Now;
                     }
                     existEm.TelePhone      = item.TelePhone;
                     existEm.TelHome        = item.TelHome;
                     existEm.TelLocal       = item.TelLocal;
                     existEm.TelMobile      = item.TelMobile;
                     existEm.Address        = item.Address;
                     existEm.BirthDay       = item.BirthDay;
                     existEm.Email          = item.Email;
                     existEm.EmployeeLink   = item.EmployeeLink;
                     existEm.Fax            = item.Fax;
                     existEm.FKPosition     = item.FKPosition;
                     existEm.Name           = item.Name;
                     existEm.UserName       = item.UserName;
                     existEm.RowUpdatedAt   = DateTime.Now;
                     existEm.RowUpdatedUser = currentUser.UserName;
                     existEm.FKUnit         = item.FKUnit;
                     dbConn.Update(existEm);
                     dbTrans.Commit();
                     return(Json(new { error = false, message = Resources.Multi.Success }));
                 }
                 catch (Exception ex)
                 {
                     dbTrans.Rollback();
                     return(Json(new { error = true, message = ex.Message }));
                 }
             }
             else
             {
                 if (!asset.Create)
                 {
                     return(Json(new { error = true, message = "Không có quyền tạo mới." }));
                 }
                 string message = "";
                 foreach (ModelState modelState in ViewData.ModelState.Values)
                 {
                     foreach (ModelError error in modelState.Errors)
                     {
                         message += error.ErrorMessage + " ";
                     }
                 }
                 return(Json(new { error = true, message = message }));
             }
 }