Пример #1
0
        public void CreateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
        {
            string vsMsgErr = "";
            try
            {
                using (var db = new DBMAINContext())
                {
                    #region User Area
                        User oModel = new User();
                        //Map Form Data
                        //Mapper.CreateMap<User_DetailCPARVM, User>();
                        //oModel = Mapper.Map<User_DetailCPARVM, User>(poViewModel);
                        //Set Field Header
                        oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        //Set DTA_STS
                        oModel.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.CREATE);
                        //Set BP_STS (Active)
                        oModel.setActivate();
                        //Set model from Viewmodel
                        oModel.USR_ID = poViewModel.USR_ID;
                        oModel.USR_NM1 = poViewModel.USR_NM1;
                        //Encrypt password
                        oModel.USR_PSWD = hlpObf.randomEncrypt(poViewModel.USR_PSWD);
                    #endregion

                    #region Employee Area
                        Employee oModelEmployee = new Employee();
                        //Set Field Header
                        oModelEmployee.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        //Set DTA_STS
                        oModelEmployee.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.CREATE);
                        //Set RES_TYPE
                        oModelEmployee.setRES_TYPE();
                        //Set BP_STS
                        oModelEmployee.setActivate();
                        //Set model from Viewmodel
                        oModelEmployee.RES_NM1 = poViewModel.USR_NM1;
                        oModelEmployee.DEPT_RUID = poViewModel.DEPT_RUID;
                        //Set Image file name
                        if (poFileimage != null)
                        {
                            oModelEmployee.IMG_SRC = Utility_FileUploadDownload.setImage(oModelEmployee.RUID);
                            Utility_FileUploadDownload.saveImage_Employee(poFileimage, oModelEmployee.IMG_SRC);
                        } //End if (poFileimage != null)
                    #endregion

                    //Set RES_RUID in User Table
                    oModel.RES_RUID = oModelEmployee.RUID;
                    //Process CRUD
                    db.Users.Add(oModel);
                    db.Employees.Add(oModelEmployee);
                    //Save to Database
                    db.SaveChanges();
                    this.RUID = oModel.RUID;
                } //End using
            } //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        } //End public void CreateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
Пример #2
0
        } //End public void CreateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
        public void UpdateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
        {
            string vsMsgErr = "";
            try
            {
                using (var db = new DBMAINContext())
                {
                    #region User Area
                        User oModel = db.Users.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                        //Set Field Header
                        oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                        //Set DTA_STS
                        oModel.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.UPDATE);
                        //Set BP_STS (Active)
                        oModel.setActivate();
                        //Set model from Viewmodel
                        oModel.USR_NM1 = poViewModel.USR_NM1;
                        oModel.USR_PSWD = hlpObf.randomEncrypt(poViewModel.USR_PSWD);
                    #endregion

                    #region Employee Area
                        Employee oModelEmployee = db.Employees.AsNoTracking().SingleOrDefault(fld => fld.RUID == oModel.RES_RUID);
                        //Set Field Header
                        oModelEmployee.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                        //Set DTA_STS
                        oModelEmployee.DTA_STS = oModel.setDTA_STS(hlpFlags_CRUDOption.UPDATE);
                        //Set RES_TYPE
                        oModelEmployee.setRES_TYPE();
                        //Set model from Viewmodel
                        oModelEmployee.RES_NM1 = poViewModel.USR_NM1;
                        oModelEmployee.DEPT_RUID = poViewModel.DEPT_RUID;

                        //Set Image file name
                        if (poFileimage != null)
                        {
                            oModelEmployee.IMG_SRC = Utility_FileUploadDownload.setImage(oModelEmployee.RUID);
                            Utility_FileUploadDownload.saveImage_Employee(poFileimage, oModelEmployee.IMG_SRC);
                        } //End if (poFileimage != null)

                    #endregion

                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.Entry(oModelEmployee).State = EntityState.Modified;
                    //Save to Database
                    db.SaveChanges();
                    this.RUID = oModel.RUID;
                } //End using
            } //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        } //End public void UpdateCPAR(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
Пример #3
0
        } //End public static List<User_ListVM> getDatalist()
        public List<User_ListVM> getDatalist(User_DetailCPARVM poViewModel)
        {
            List<User_ListVM> oReturn;


            using (var db = new DBMAINContext())
            {
                List<string> sNotIn = new List<string>();
                sNotIn.Add(valDFLT.USR_IDSYSTEM); sNotIn.Add(valDFLT.USR_IDGENERAL); sNotIn.Add(valDFLT.USR_IDDEMO);

                var oQRY = from tb in db.User_infos
                           where !sNotIn.Contains(tb.USR_ID)
                           select new User_ListVM
                           {
                               RUID = tb.RUID,
                               DTA_STS = tb.DTA_STS,
                               BP_STS = tb.BP_STS,
                               ROLE_RUID = tb.ROLE_RUID,
                               ROLE_NM = tb.ROLE_NM,
                               USR_ID = tb.USR_ID,
                               USR_NM1 = tb.USR_NM1,
                               RES_NM1 = tb.RES_NM1,
                               DEPT_NM = tb.DEPT_NM,
                               BRNCH_NM = tb.BRNCH_NM,
                               JOB_TITLE_NM = tb.JOB_TITLE_NM,
                               IMG_SRC = tb.IMG_SRC,
                               RES_RUID = tb.RES_RUID
                           };
                if ((poViewModel.ROLE_RUID != "") && (poViewModel.ROLE_RUID != null)) { oQRY = oQRY.Where(fld => fld.ROLE_RUID == poViewModel.ROLE_RUID); }

                if ((poViewModel.FILTER_ROLE != "") && (poViewModel.FILTER_ROLE != null)) { oQRY = oQRY.Where(fld => fld.ROLE_NM.ToUpper().Contains(poViewModel.FILTER_ROLE.ToUpper())); }
                if ((poViewModel.FILTER_DEPARTEMEN != "") && (poViewModel.FILTER_DEPARTEMEN != null)) { oQRY = oQRY.Where(fld => fld.DEPT_NM.ToUpper().Contains(poViewModel.FILTER_DEPARTEMEN.ToUpper())); }
                if ((poViewModel.FILTER_NAMA != "") && (poViewModel.FILTER_NAMA != null)) { oQRY = oQRY.Where(fld => fld.USR_NM1.ToUpper().Contains(poViewModel.FILTER_NAMA.ToUpper())); }

                oReturn = oQRY.OrderBy(fld => fld.USR_ID).ToList();
            } //End using (var = new DbContext())
            return oReturn;
        } //End public List<User_ListVM> getDatalist(User_DetailCPARVM poViewModel = null)
Пример #4
0
 //Constructor 2
 public User_Validation(User_DetailCPARVM poViewModel, HttpPostedFileBase poFileimage)
 {
     oViewModelCPAR = poViewModel;
 } //End public User_Validation()