Esempio n. 1
0
        public ResponseData SaveRoleUser(int roleid, string users)
        {
            ResponseData result = new Models.ResponseData();

            using (SATEntities db = new SATEntities())
            {
                try
                {
                    if (!string.IsNullOrEmpty(users))
                    {
                        string[] user = users.Split(',');
                        foreach (var userid in user)
                        {
                            tb_User_Role model = new tb_User_Role();
                            model.RoleID     = roleid;
                            model.UserID     = Convert.ToInt32(userid);
                            model.CreateBy   = UtilityService.User.UserID;
                            model.CreateDate = DateTime.Now;
                            model.ModifyBy   = UtilityService.User.UserID;
                            model.ModifyDate = DateTime.Now;
                            db.tb_User_Role.Add(model);
                            db.SaveChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    result.MessageCode = "";
                    result.MessageText = ex.Message;
                }
                return(result);
            }
        }
Esempio n. 2
0
 public ResponseData AddByEntity(ActionTypeViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Action_Type model = new tb_Action_Type();
             model.ActID      = data.ActID;
             model.ActName    = data.ActName;
             model.ActType    = data.ActType;
             model.ActPos     = data.ActPos;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Action_Type.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 3
0
        public ResponseData AddByEntity(PositionRateViewModel data)
        {
            using (SATEntities db = new SATEntities())
            {
                ResponseData result = new Models.ResponseData();
                try
                {
                    int maxID = db.tb_Man_Power.Where(m => m.TypeID == data.TypeID).Max(m => (int)m.MpID);

                    tb_Man_Power model = new tb_Man_Power();
                    model.MpID       = maxID;
                    model.TypeID     = data.TypeID;
                    model.DivID      = data.DivID;
                    model.DepID      = data.DepID;
                    model.SecID      = data.SecID;
                    model.PoID       = data.PoID;
                    model.DisID      = data.DisID;
                    model.UserID     = data.UserID;
                    model.EduID      = data.EduID;
                    model.CreateBy   = UtilityService.User.UserID;
                    model.CreateDate = DateTime.Now;
                    model.ModifyBy   = UtilityService.User.UserID;
                    model.ModifyDate = DateTime.Now;
                    db.tb_Man_Power.Add(model);
                    db.SaveChanges();
                    result.ID = model.MpID;
                }
                catch (Exception ex)
                {
                    result.MessageCode = "";
                    result.MessageText = ex.Message;
                }
                return(result);
            }
        }
Esempio n. 4
0
 public ResponseData AddByEntity(InsigniaViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Insignia model = new tb_Insignia();
             model.InsID        = data.InsID;
             model.InsFullName  = data.InsFullName;
             model.InsShortName = data.InsShortName;
             model.InsStatus    = (data.Status == "1") ? true : false;
             model.CreateBy     = UtilityService.User.UserID;
             model.CreateDate   = DateTime.Now;
             model.ModifyBy     = UtilityService.User.UserID;
             model.ModifyDate   = DateTime.Now;
             db.tb_Insignia.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 5
0
 public ResponseData UpdateByEntity(PositionRateViewModel newdata)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             var model = db.tb_Man_Power.Single(x => x.MpID == newdata.MpID);
             model.DivID      = newdata.DivID;
             model.DepID      = newdata.DepID;
             model.SecID      = newdata.SecID;
             model.PoID       = newdata.PoID;
             model.DisID      = newdata.DisID;
             model.UserID     = newdata.UserID;
             model.EduID      = newdata.EduID;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             result.MessageCode = "";
             result.MessageText = ex.Message;
         }
         return(result);
     }
 }
Esempio n. 6
0
        public JsonResult SaveInsignia(UserInsigniaViewModel data, HttpPostedFileBase fileUpload)
        {
            ResponseData result = new Models.ResponseData();

            if (fileUpload != null && fileUpload.ContentLength > 0)
            {
                //if (fileUpload.ContentLength > 10240)
                //{

                //}

                //var supportedTypes = new[] { "jpg", "jpeg", "png" };
                //var fileExt = System.IO.Path.GetExtension(fileUpload.FileName).Substring(1);
                //if (!supportedTypes.Contains(fileExt))
                //{

                //}
            }

            if (data.UiID != 0)
            {
                result = new EmployeeRepository().UpdateInsigniaByEntity(data, fileUpload);
            }
            else
            {
                result = new EmployeeRepository().AddInsigniaByEntity(data, fileUpload);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
 public ResponseData AddByEntity(LeaveTypeViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Leave_Type model = new tb_Leave_Type();
             model.LevID        = data.LevID;
             model.LevYear      = data.LevYear;
             model.LevName      = data.LevName;
             model.LevStartDate = Convert.ToDateTime(data.LevStartDateText);
             model.LevEndDate   = Convert.ToDateTime(data.LevEndDateText);
             model.LevMax       = data.LevMax;
             model.SexID        = data.SexID;
             model.CreateBy     = UtilityService.User.UserID;
             model.CreateDate   = DateTime.Now;
             model.ModifyBy     = UtilityService.User.UserID;
             model.ModifyDate   = DateTime.Now;
             db.tb_Leave_Type.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 8
0
 public ResponseData AddByEntity(DepartmentViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Department model = new tb_Department();
             model.DepID      = data.DepID;
             model.DepName    = data.DepName;
             model.DepStatus  = (data.Status == "1") ? true : false;
             model.DivID      = (int)data.DivID;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Department.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 9
0
        public JsonResult SaveSysConfig(List <SysConfigViewModel> model)
        {
            ResponseData result = new Models.ResponseData();

            result = new SysConfigRepository().UpdateByEntity(model);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 10
0
 public ResponseData AddByEntity(CapabilityDetailViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Capability_Detail model = new tb_Capability_Detail();
             model.CapDID     = data.CapDID;
             model.CapDName   = data.CapDName;
             model.CapDDesc   = data.CapDDesc;
             model.CapID      = data.CapID;
             model.Score1     = data.Score1;
             model.Score2     = data.Score2;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Capability_Detail.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 11
0
 public ResponseData AddByEntity(CapabilityViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Capability model = new tb_Capability();
             model.CapID      = data.CapID;
             model.CapYear    = data.CapYear;
             model.CapTID     = data.CapTID;
             model.CapGID     = data.CapGID;
             model.CapGTID    = data.CapGTID;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Capability.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 12
0
        public ResponseData DeleteLevelTransfer(int id)
        {
            ResponseData result = new Models.ResponseData();
            using (SATEntities db = new SATEntities())
            {
                using (var transection = db.Database.BeginTransaction())
                {
                    try
                    {
                        var listdelete = db.tb_Move_Level_Detail.Where(x => x.MlID == id).ToList();
                        db.tb_Move_Level_Detail.RemoveRange(listdelete);
                        db.SaveChanges();

                        var itemdelete = db.tb_Move_Level_Head.Where(x => x.MlID == id).FirstOrDefault();
                        db.tb_Move_Level_Head.Remove(itemdelete);
                        db.SaveChanges();

                        transection.Commit();
                    }
                    catch (Exception ex)
                    {
                        transection.Rollback();
                        result.MessageCode = "";
                        result.MessageText = ex.Message;
                    }
                    return result;
                }
            }
        }
Esempio n. 13
0
 public ResponseData AddByEntity(SalaryViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Salary model = new tb_Salary();
             model.SaID       = data.SaID;
             model.SaLevel    = data.SaLevel;
             model.SaStep     = data.SaStep;
             model.SaRate     = data.SaRate;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Salary.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 14
0
 public ResponseData AddByEntity(PositionViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Position model = new tb_Position();
             model.PoID       = data.PoID;
             model.PoCode     = data.PoCode;
             model.PoName     = data.PoName;
             model.PoStatus   = (data.Status == "1") ? true : false;
             model.TypeID     = data.TypeID;
             model.CreateBy   = UtilityService.User.UserID;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = UtilityService.User.UserID;
             model.ModifyDate = DateTime.Now;
             db.tb_Position.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 15
0
 public ResponseData AddRoleByEntity(RoleViewModel data)
 {
     using (SATEntities db = new SATEntities())
     {
         ResponseData result = new Models.ResponseData();
         try
         {
             tb_Role model = new tb_Role();
             model.RoleID     = data.RoleID;
             model.RoleName   = data.RoleName;
             data.RoleDesc    = data.RoleDesc;
             model.RoleStatus = (data.Status == "1") ? true : false;
             model.CreateBy   = data.ModifyBy;
             model.CreateDate = DateTime.Now;
             model.ModifyBy   = data.ModifyBy;
             model.ModifyDate = DateTime.Now;
             db.tb_Role.Add(model);
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
         return(result);
     }
 }
Esempio n. 16
0
        public JsonResult SubmitCapabilityDetail(List <CapabilityDetailViewModel> model)
        {
            ResponseData result = new Models.ResponseData();

            result = new CapabilityDetailRepository().SubmitByEntity(model);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 17
0
        public ResponseData SaveRoleMenu(List <RoleMenuViewModel> model)
        {
            ResponseData result = new Models.ResponseData();

            using (SATEntities db = new SATEntities())
            {
                try
                {
                    if (model != null)
                    {
                        foreach (var item in model)
                        {
                            if (item.MenuType == "M" || (item.ParentID != 0 && (item.MenuType == "T" || item.MenuType == "R")))
                            {
                                var data = db.tb_Menu_Role.Where(m => m.RoleID == item.RoleID && m.MenuID == item.MenuID).FirstOrDefault();
                                if (data != null)
                                {
                                    data.R_View     = item.R_View;
                                    data.R_Add      = item.R_Add;
                                    data.R_Edit     = item.R_Edit;
                                    data.R_Delete   = item.R_Delete;
                                    data.ModifyBy   = UtilityService.User.UserID;
                                    data.ModifyDate = DateTime.Now;
                                    db.SaveChanges();
                                }
                                else
                                {
                                    tb_Menu_Role obj = new tb_Menu_Role();
                                    obj.RoleID     = item.RoleID;
                                    obj.MenuID     = item.MenuID;
                                    obj.R_View     = item.R_View;
                                    obj.R_Add      = item.R_Add;
                                    obj.R_Edit     = item.R_Edit;
                                    obj.R_Delete   = item.R_Delete;
                                    obj.CreateBy   = UtilityService.User.UserID;
                                    obj.CreateDate = DateTime.Now;
                                    obj.ModifyBy   = UtilityService.User.UserID;
                                    obj.ModifyDate = DateTime.Now;
                                    db.tb_Menu_Role.Add(obj);
                                    db.SaveChanges();
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    result.MessageCode = "";
                    result.MessageText = ex.Message;
                }
                return(result);
            }
        }
Esempio n. 18
0
        public JsonResult SavePositionTransfer(PositionTransferViewModel data)
        {
            ResponseData result = new Models.ResponseData();

            if (data.MopID != 0)
            {
                result = new PositionTransferRepository().UpdateByEntity(data);
            }
            else
            {
                result = new PositionTransferRepository().AddByEntity(data);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 19
0
        public JsonResult SaveCertificate(UserCertificateViewModel data)
        {
            ResponseData result = new Models.ResponseData();

            if (data.UcID != 0)
            {
                result = new EmployeeRepository().UpdateCertificateByEntity(data);
            }
            else
            {
                result = new EmployeeRepository().AddCertificateByEntity(data);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 20
0
        public JsonResult SaveHistory(UserHistoryViewModel data)
        {
            ResponseData result = new Models.ResponseData();

            if (data.UhID != 0)
            {
                result = new EmployeeRepository().UpdateHistoryByEntity(data);
            }
            else
            {
                result = new EmployeeRepository().AddHistoryByEntity(data);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 21
0
        public JsonResult SavePosition(UserPositionViewModel data, HttpPostedFileBase fileUpload)
        {
            ResponseData result = new Models.ResponseData();

            if (data.UpID != 0)
            {
                result = new EmployeeRepository().UpdatePositionByEntity(data, fileUpload);
            }
            else
            {
                result = new EmployeeRepository().AddPositionByEntity(data, fileUpload);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 22
0
        public JsonResult SaveExcellent(UserExcellentViewModel data)
        {
            ResponseData result = new Models.ResponseData();

            if (data.UeID != 0)
            {
                result = new EmployeeRepository().UpdateExcellentByEntity(data);
            }
            else
            {
                result = new EmployeeRepository().AddExcellentByEntity(data);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 23
0
        public JsonResult SaveTraining(UserTrainningViewModel data)
        {
            ResponseData result = new Models.ResponseData();

            if (data.UtID != 0)
            {
                result = new EmployeeRepository().UpdateTrainingByEntity(data);
            }
            else
            {
                result = new EmployeeRepository().AddTrainingByEntity(data);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 24
0
        public JsonResult SaveCapabilityDetail(CapabilityDetailViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.CapID != 0)
            {
                result = new CapabilityDetailRepository().UpdateByEntity(model);
            }
            else
            {
                result = new CapabilityDetailRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 25
0
        public JsonResult SaveInsignia(InsigniaViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.InsID != 0)
            {
                result = new InsigniaRepository().UpdateByEntity(model);
            }
            else
            {
                result = new InsigniaRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 26
0
        public JsonResult SaveNationality(NationalityViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.NatID != 0)
            {
                result = new NationalityRepository().UpdateByEntity(model);
            }
            else
            {
                result = new NationalityRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 27
0
        public JsonResult SaveReligion(ReligionViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.RelD != 0)
            {
                result = new ReligionRepository().UpdateByEntity(model);
            }
            else
            {
                result = new ReligionRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 28
0
        public JsonResult SaveHoliday(HolidayViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.HolID != 0)
            {
                result = new HolidayRepository().UpdateByEntity(model);
            }
            else
            {
                result = new HolidayRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 29
0
        public JsonResult SaveDepartment(DepartmentViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.DepID != 0)
            {
                result = new DepartmentRepository().UpdateByEntity(model);
            }
            else
            {
                result = new DepartmentRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 30
0
        public JsonResult SaveLeaveType(LeaveTypeViewModel model)
        {
            ResponseData result = new Models.ResponseData();

            if (model.LevID != 0)
            {
                result = new LeaveTypeRepository().UpdateByEntity(model);
            }
            else
            {
                result = new LeaveTypeRepository().AddByEntity(model);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }