Пример #1
0
        private void loginLogic()
        {
            if (txtUserNo.Text.Trim() == "")
            {
                MessageBox.Show("Please fill the UserNo");
            }
            else if (txtPassword.Text.Trim() == "")
            {
                MessageBox.Show("Please fill the Password box");
            }
            else
            {
                string password = txtPassword.Text;
                if (Convert.ToInt32(txtUserNo.Text) > 6)
                {
                    password = PasswordEncryption.CreateMD5Hash(password);
                }
                List <EMPLOYEE> employeeList = EmployeeBLL.GetEmployees(Convert.ToInt32(txtUserNo.Text), password);

                if (employeeList.Count == 0)
                {
                    MessageBox.Show("Wrong username or password!");
                }
                else
                {
                    EMPLOYEE employee = new EMPLOYEE();
                    employee = employeeList.First();
                    UserStatic.EmployeeID = employee.ID;
                    UserStatic.UserNo     = employee.UserNo;
                    UserStatic.isAdmin    = employee.isAdmin;
                    FrmMain frm = new FrmMain();
                    this.Hide();
                    frm.ShowDialog();
                }
            }
        }
Пример #2
0
        public IHttpActionResult DeleteEmp(int id)
        {
            INF370Entities db = new INF370Entities();

            db.Configuration.ProxyCreationEnabled = false;

            try
            {
                EMPLOYEE employeeDetails = db.EMPLOYEEs.Find(id);
                if (employeeDetails == null)
                {
                    return(NotFound());
                }

                db.EMPLOYEEs.Remove(employeeDetails);
                db.SaveChanges();

                return(Ok(employeeDetails));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #3
0
        public IHttpActionResult PostOwner(EMPLOYEE data)
        {
            INF370Entities db = new INF370Entities();

            db.Configuration.ProxyCreationEnabled = false;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                db.EMPLOYEEs.Add(data);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(null);
            }



            return(Ok(data));
        }
Пример #4
0
        /// <summary>
        /// 将EMPLOYEE记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.EMPLOYEE)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.EMPLOYEE</returns>
        public DataAccess.Model.EMPLOYEE Transform(EMPLOYEE model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new DataAccess.Model.EMPLOYEE
            {
                Id = model.Id,
                EMP_ID = model.EMP_ID,
                EMP_NAME = model.EMP_NAME,
                EMP_Birthday = model.EMP_Birthday,
                EMP_ADD = model.EMP_ADD,
                EMP_TEL = model.EMP_TEL,
                EMP_ZIP = model.EMP_ZIP,
                EMP_EMAIL = model.EMP_EMAIL,
                EMP_MOBILE = model.EMP_MOBILE,
                EMP_MEMO = model.EMP_MEMO,
                EMP_ENABLE = model.EMP_ENABLE,
                EMP_SEX = model.EMP_SEX,
                EMP_CodeID = model.EMP_CodeID,
                EMP_LEVEL = model.EMP_LEVEL,
                EMP_PASSWORD = model.EMP_PASSWORD,
                EMP_BDATE = model.EMP_BDATE,
                EMP_EDATE = model.EMP_EDATE,
                EMP_WAGE = model.EMP_WAGE,
                EMP_Education = model.EMP_Education,
                CRT_DATETIME = model.CRT_DATETIME,
                CRT_USER_ID = model.CRT_USER_ID,
                MOD_DATETIME = model.MOD_DATETIME,
                MOD_USER_ID = model.MOD_USER_ID,
                LAST_UPDATE = model.LAST_UPDATE,
                STATUS = model.STATUS,
            });
        }
Пример #5
0
        public int CalculateAssessableIncome(EMPLOYEE e, DateTime month)
        {
            int taxable = CalculateTaxableIncome(e, month);

            if (CheckLowerThan3Month(e.CONTRACT.DateStartWork, e.CONTRACT.ContractExpirationDate))
            {
                if (taxable < db.PARAMETERs.Find("ThuNhapChiuThueToiThieuHDDuoi3Thang").Value)
                {
                    return(0);
                }
                return(taxable);
            }
            int deduction = (int)db.PARAMETERs.Find("MucGiamTruNguoiPhuThuoc").Value *e.DependentDeduction + CalculateTotalInsurancePay(e, month);

            if (e.SelfDeduction == true)
            {
                deduction += (int)db.PARAMETERs.Find("MucGiamTruBanThan").Value;
            }
            if (taxable > deduction)
            {
                return(taxable - deduction);
            }
            return(0);
        }
        public IHttpActionResult GetEmployeeById(string EMPLOYEEID)
        {
            db.Configuration.ProxyCreationEnabled = false;

            EMPLOYEE objEmp = new EMPLOYEE();
            int      ID     = Convert.ToInt32(EMPLOYEEID);

            try
            {
                objEmp = db.EMPLOYEEs.Find(ID);
                if (objEmp == null)
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                dynamic User = new ExpandoObject();
                User.Message = "Something went wrong !";
                return(User);
            }

            return(Ok(objEmp));
        }
Пример #7
0
        public ActionResult AutoLogin()
        {
            string errorMsg = "";

            //从微信获取传入参数

            #region 从微信平台引入的自动登陆
            string code  = Request["code"];
            string state = Request["state"];
            Logger.Write("code:" + code + "|state:" + state);

            EnterpriceService.MfWeiXinEmpServiceSoapClient wsc = new EnterpriceService.MfWeiXinEmpServiceSoapClient();


            string userId = "";
            int    result = 0;

            try
            {
                result = wsc.GetUserId(Identify, code, ref userId);
            }
            catch (Exception)
            {
                Logger.Write("企业微信调用失败");
            }

            Logger.Write("result:" + result + "|userid:" + userId);
            #endregion

            #region 从ODS平台引入的自动登陆
            if (string.IsNullOrEmpty(userId))
            {
                userId = Public.Common.Decryption(Request["uc"].ToString());
                string passWord = Request["up"].ToString();
                Logger.Write("userId:" + userId + "|passWord:"******"Login", "Account"));
            }


            try
            {
                EMPLOYEE employee = DbContext.EMPLOYEE.Where(m => m.NO == userId).FirstOrDefault();
                if (employee == null)
                {
                    errorMsg = "工号不存在!";
                }
                else
                {
                    if (employee.LEAVE == "1" || employee.AVAILABLE == "0")
                    {
                        errorMsg = "此账号不可用!";
                    }
                }


                if (string.IsNullOrEmpty(errorMsg))
                {
                    var query = (from a in DbContext.EMPLOYEE
                                 join b in DbContext.SHOP on a.SHOPCODE equals b.CODE
                                 into temp
                                 from b in temp.DefaultIfEmpty()
                                 join c in DbContext.DEPARTMENT on a.DEPID equals c.ID
                                 where a.NO == userId
                                 select new
                    {
                        IsUcStar = a.IS_UCSTAR,
                        EmployeeNo = a.NO,
                        CompanyCode = c.COMPANYCODE,

                        DepartmentID = a.DEPID,
                        ShopCode = a.SHOPCODE,
                        ShopName = (b == null ? "" : b.NAME),
                        ShopType = (b == null ? "" : b.SHOP_PROPERTY),
                        Oversea = (b == null ? 0 : b.OVERSEA),
                        EmployeeName = a.NAME,
                        DepartmentName = (c == null ? "" : c.NAME)
                    }).FirstOrDefault();


                    //获取当前员工可操作的店柜
                    UIVALUE uiValue = DbContext.UIVALUE.Where(m => m.EMPLOYEENO == query.EmployeeNo && m.VALUETYPE == 4).FirstOrDefault();
                    string  uivalue = (uiValue == null || string.IsNullOrEmpty(uiValue.VALUE)) ? "" : uiValue.VALUE;
                    var     Shops   = (from m in DbContext.SHOP
                                       join d in DbContext.DEPARTMENT on m.DEPARTMENTID equals d.ID
                                       where uivalue.Contains(m.CODE)
                                       select new
                    {
                        shopCode = m.CODE,
                        shopName = m.NAME,
                        currency = m.CURRENCY.CODE,
                        departmentName = d.NAME,
                        departmentId = d.ID,
                        property = m.SHOP_PROPERTY,
                        oversea = m.OVERSEA
                    }).Union(
                        from x in DbContext.SHOP
                        join y in DbContext.DEPARTMENT on x.DEPARTMENTID equals y.ID
                        where (string.IsNullOrEmpty(query.ShopCode) ? false : x.CODE == query.ShopCode)
                        select new
                    {
                        shopCode       = x.CODE,
                        shopName       = x.NAME,
                        currency       = x.CURRENCY.CODE,
                        departmentName = y.NAME,
                        departmentId   = y.ID,
                        property       = x.SHOP_PROPERTY,
                        oversea        = x.OVERSEA
                    }
                        ).OrderBy(s => s.shopCode).ToList();


                    DEPARTMENT root         = GetRootDepartment(employee.DEPARTMENT);
                    var        CompanyName  = DbContext.COMPANY.Where(c => c.CODE == root.COMPANYCODE).Select(x => x.NAME).FirstOrDefault();
                    string     employeeInfo = "{CompanyCode:'" + query.CompanyCode
                                              + "',CompanyName:'" + HttpUtility.UrlEncode(CompanyName)
                                              + "',DepartmentID:'" + query.DepartmentID
                                              + "',ShopCode:'" + (string.IsNullOrEmpty(query.ShopCode) ? "" : query.ShopCode)
                                              + "',ShopName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(query.ShopName) ? "" : query.ShopName), System.Text.Encoding.UTF8)
                                              + "',ShopType:'" + (string.IsNullOrEmpty(query.ShopType) ? "" : query.ShopType)
                                              + "',EmployeeNo:'" + query.EmployeeNo
                                              + "',Oversea:'" + query.Oversea
                                              + "',IsUcStar:'" + query.IsUcStar.ToString()
                                              + "',EmployeeName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(query.EmployeeName) ? "" : query.EmployeeName), System.Text.Encoding.UTF8)
                                              + "',DepartmentName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(query.DepartmentName) ? "" : query.DepartmentName), System.Text.Encoding.UTF8)
                                              + "',RootDepartmentName:'" + HttpUtility.UrlEncode((string.IsNullOrEmpty(root.NAME) ? "" : root.NAME), System.Text.Encoding.UTF8)
                                              + "',RootDepartmentID:'" + root.ID
                                              + "',COST_ACCOUNT:'" + (string.IsNullOrEmpty(root.COST_ACCOUNT) ? "" : root.COST_ACCOUNT)
                                              + "',IsHeadOffice:'" + (root.IsHeadOffice ? "1" : "0") //是否总部人员,1表示是
                                              + "',BankCardNo:'" + HttpUtility.UrlEncode("********", System.Text.Encoding.UTF8)
                                              + "',WebSocketConnection:'" + System.Web.Configuration.WebConfigurationManager.AppSettings["WebSocketConnection"]
                                              + "',UPCODE:'" + Common.Encryption(query.EmployeeNo)
                                              + "'}";

                    Marisfrolg.Public.CookieHelper.RemoveEmployeeInfo();
                    Marisfrolg.Public.CookieHelper.SetEmplyeeInfo(employeeInfo);

                    //操作日志
                    Marisfrolg.Public.Common.OperationLog(Common.GetClientComputerName(), employee.NO, employee.NO, this.GetType().ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, "Employee", "员工登陆", "", "");
                    DbContext.SaveChanges();
                    errorMsg = "success";
                }
            }
            catch (System.Data.Common.DbException ex)
            {
                Logger.Write("登陆失败:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name + ",登陆账号:" + userId);
                errorMsg = "数据库连接失败!";
            }
            catch (Exception ex)
            {
                Logger.Write("登陆失败:" + ex.ToString() + "," + System.Reflection.MethodBase.GetCurrentMethod().Name + ",登陆账号:" + userId);
                errorMsg = "系统错误!";
            }


            return(RedirectToAction("Index"));
            //return RedirectToAction("Index", "Home");
        }
Пример #8
0
        public async Task <ActionResult> Edit([Bind(Include = "EmployeeID,EmployeeName,Image,Sex,DoB,Birthplace,HomeTown,Nation,IdNumber,Phone,Email,City,Ward,Dictrict,Street,RoomID,PositionID,ContractID,HealthInsurance,HealthInsuranceID,DeductionPersonal,DeductionDependent,EducationName,MajorID,Date,Place,CertificateName,TypeCertificate,CertificateDate,CertificatePlace,ContractID,ContractType,DateStartWork,ContractExpirationDate,BasicSalary,Password")] EmployeeViewModel employee)
        {
            List <SelectListItem> city            = new List <SelectListItem>();
            List <SelectListItem> ward            = new List <SelectListItem>();
            List <SelectListItem> dictrict        = new List <SelectListItem>();
            List <SelectListItem> nation          = new List <SelectListItem>();
            List <SelectListItem> contractType    = new List <SelectListItem>();
            List <SelectListItem> education       = new List <SelectListItem>();
            List <SelectListItem> typecertificate = new List <SelectListItem>();
            var Directory = AppDomain.CurrentDomain.BaseDirectory;
            //path of folder
            var path     = Directory + "./File_Text/";
            var encoding = Encoding.UTF8;

            string[] lines1 = System.IO.File.ReadAllLines(path + "City.txt", encoding);
            string[] lines2 = System.IO.File.ReadAllLines(path + "Ward.txt", encoding);
            string[] lines3 = System.IO.File.ReadAllLines(path + "Dictrict.txt", encoding);
            string[] lines4 = System.IO.File.ReadAllLines(path + "Nation.txt", encoding);
            string[] lines5 = System.IO.File.ReadAllLines(path + "ContractType.txt", encoding);
            string[] lines6 = System.IO.File.ReadAllLines(path + "Education.txt", encoding);
            string[] lines7 = System.IO.File.ReadAllLines(path + "TypeCertificate.txt", encoding);
            foreach (string line in lines1)
            {
                city.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines2)
            {
                ward.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines3)
            {
                dictrict.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines4)
            {
                nation.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines5)
            {
                contractType.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines6)
            {
                education.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines7)
            {
                typecertificate.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            SelectList citylist         = new SelectList(city, "Value", "Text");
            SelectList wardlist         = new SelectList(ward, "Value", "Text");
            SelectList dictrictlist     = new SelectList(dictrict, "Value", "Text");
            SelectList nationlist       = new SelectList(nation, "Value", "Text");
            SelectList contracttypelist = new SelectList(contractType, "Value", "Text");
            SelectList educationlist    = new SelectList(education, "Value", "Text");
            SelectList certificatelist  = new SelectList(typecertificate, "Value", "Text");

            // Set vào ViewBag
            ViewBag.Birthplace      = citylist;
            ViewBag.HomeTown        = citylist;
            ViewBag.nationList      = nationlist;
            ViewBag.ContractType    = contracttypelist;
            ViewBag.City            = citylist;
            ViewBag.Ward            = wardlist;
            ViewBag.Dictrict        = dictrictlist;
            ViewBag.EducationName   = educationlist;
            ViewBag.PositionID      = new SelectList(db.POSITIONs, "PositionID", "PositionName");
            ViewBag.RoomID          = new SelectList(db.ROOMs, "RoomID", "RoomName");
            ViewBag.MajorID         = new SelectList(db.MAJORs, "MajorID", "MajorName");
            ViewBag.TypeCertificate = certificatelist;
            if (employee.ContractExpirationDate < employee.DateStartWork)
            {
                ModelState.AddModelError("ContractExpirationDate", "Ngày kết thúc phải lớn hơn ngày bắt đầu");
            }
            var Parameter = db.PARAMETERs.ToList();
            var tuoi      = DateTime.Now.Year - employee.DoB.Year;

            if (employee.Sex == "Nam")
            {
                if (tuoi < Parameter[19].Value) //tuoi toi thieu nam
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
                if (tuoi > Parameter[17].Value) //tuoi toi da nam
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
            }
            else
            {
                if (tuoi < Parameter[17].Value) //tuoi toi thieu nu
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
                if (tuoi > Parameter[18].Value) //tuoi toi da nu
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
            }
            if (ModelState.IsValid)
            {
                EMPLOYEE eMPLOYEE = new EMPLOYEE();
                eMPLOYEE.EmployeeID   = employee.EmployeeID;
                eMPLOYEE.EmployeeName = FormatProperCase(employee.EmployeeName); //Chuan hoa chuoi
                if (employee.ImageFile != null)
                {
                    employee.ImageFile.SaveAs(Server.MapPath("/images") + "/" + employee.EmployeeID + ".jpg");
                }
                eMPLOYEE.Sex                = employee.Sex;
                eMPLOYEE.DoB                = (DateTime)employee.DoB;
                eMPLOYEE.Birthplace         = employee.Birthplace;
                eMPLOYEE.HomeTown           = employee.HomeTown;
                eMPLOYEE.Nation             = employee.Nation;
                eMPLOYEE.IdNumber           = employee.IdNumber;
                eMPLOYEE.Phone              = employee.Phone;
                eMPLOYEE.Email              = employee.Email;
                eMPLOYEE.City               = employee.City;
                eMPLOYEE.Ward               = employee.Ward;
                eMPLOYEE.Dictrict           = employee.Dictrict;
                eMPLOYEE.Street             = employee.Street;
                eMPLOYEE.RoomID             = employee.RoomID;
                eMPLOYEE.PositionID         = employee.PositionID;
                eMPLOYEE.ContractID         = employee.ContractID;
                eMPLOYEE.FreeInsurance      = Convert.ToBoolean(employee.HealthInsurance);
                eMPLOYEE.HealthInsuranceID  = employee.HealthInsuranceID;
                eMPLOYEE.SelfDeduction      = Convert.ToBoolean(employee.DeductionPersonal);
                eMPLOYEE.DependentDeduction = employee.DeductionDependent;
                db.Entry(eMPLOYEE).State    = EntityState.Modified;
                //Trinh do
                EDUCATIONDETAIL eDUCATIONDETAIL = new EDUCATIONDETAIL();
                eDUCATIONDETAIL.EmployeeID    = employee.EmployeeID;
                eDUCATIONDETAIL.EducationName = employee.EducationName;
                if (eDUCATIONDETAIL.EducationName == "10" || eDUCATIONDETAIL.EducationName == "11" || eDUCATIONDETAIL.EducationName == "12")
                {
                    eDUCATIONDETAIL.MajorID = "M09";
                }
                else
                {
                    eDUCATIONDETAIL.MajorID = employee.MajorID;
                }
                eDUCATIONDETAIL.Date  = employee.Date;
                eDUCATIONDETAIL.Place = employee.Place;

                //Chung chi
                CERTIFICATEDETAIL cERTIFICATEDETAIL = new CERTIFICATEDETAIL();
                cERTIFICATEDETAIL.EmployeeID       = employee.EmployeeID;
                cERTIFICATEDETAIL.CertificateName  = employee.CertificateName;
                cERTIFICATEDETAIL.CertificateDate  = employee.CertificateDate;
                cERTIFICATEDETAIL.CertificatePlace = employee.CertificatePlace;
                cERTIFICATEDETAIL.TypeCertificate  = employee.TypeCertificate;

                //Hop dong
                CONTRACT cONTRACT = new CONTRACT();
                cONTRACT.ContractID               = employee.ContractID;
                cONTRACT.ContractType             = employee.ContractType;
                cONTRACT.DateStartWork            = (DateTime)employee.DateStartWork;
                cONTRACT.ContractExpirationDate   = (DateTime)employee.ContractExpirationDate;
                cONTRACT.BasicSalary              = employee.BasicSalary;
                db.Entry(eDUCATIONDETAIL).State   = EntityState.Modified;
                db.Entry(cERTIFICATEDETAIL).State = EntityState.Modified;
                db.Entry(cONTRACT).State          = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(employee));
        }
Пример #9
0
        // GET: EMPLOYEEs/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EMPLOYEE eMPLOYEE = await db.EMPLOYEEs.FindAsync(id);

            if (eMPLOYEE == null)
            {
                return(HttpNotFound());
            }
            EmployeeViewModel     employee        = new EmployeeViewModel();
            List <SelectListItem> city            = new List <SelectListItem>();
            List <SelectListItem> ward            = new List <SelectListItem>();
            List <SelectListItem> dictrict        = new List <SelectListItem>();
            List <SelectListItem> nation          = new List <SelectListItem>();
            List <SelectListItem> contractType    = new List <SelectListItem>();
            List <SelectListItem> education       = new List <SelectListItem>();
            List <SelectListItem> typecertificate = new List <SelectListItem>();
            var Directory = AppDomain.CurrentDomain.BaseDirectory;
            //path of folder
            var path     = Directory + "./File_Text/";
            var encoding = Encoding.UTF8;

            string[] lines1 = System.IO.File.ReadAllLines(path + "City.txt", encoding);
            string[] lines2 = System.IO.File.ReadAllLines(path + "Ward.txt", encoding);
            string[] lines3 = System.IO.File.ReadAllLines(path + "Dictrict.txt", encoding);
            string[] lines4 = System.IO.File.ReadAllLines(path + "Nation.txt", encoding);
            string[] lines5 = System.IO.File.ReadAllLines(path + "ContractType.txt", encoding);
            string[] lines6 = System.IO.File.ReadAllLines(path + "Education.txt", encoding);
            string[] lines7 = System.IO.File.ReadAllLines(path + "TypeCertificate.txt", encoding);
            foreach (string line in lines1)
            {
                city.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines2)
            {
                ward.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines3)
            {
                dictrict.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines4)
            {
                nation.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines5)
            {
                contractType.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines6)
            {
                education.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines7)
            {
                typecertificate.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            SelectList citylist         = new SelectList(city, "Value", "Text");
            SelectList wardlist         = new SelectList(ward, "Value", "Text");
            SelectList dictrictlist     = new SelectList(dictrict, "Value", "Text");
            SelectList nationlist       = new SelectList(nation, "Value", "Text");
            SelectList contracttypelist = new SelectList(contractType, "Value", "Text");
            SelectList educationlist    = new SelectList(education, "Value", "Text");
            SelectList certificatelist  = new SelectList(typecertificate, "Value", "Text");

            // Set vào ViewBag
            ViewBag.Birthplace      = citylist;
            ViewBag.HomeTown        = citylist;
            ViewBag.nationList      = nationlist;
            ViewBag.ContractType    = contracttypelist;
            ViewBag.City            = citylist;
            ViewBag.Ward            = wardlist;
            ViewBag.Dictrict        = dictrictlist;
            ViewBag.EducationName   = educationlist;
            ViewBag.PositionID      = new SelectList(db.POSITIONs, "PositionID", "PositionName");
            ViewBag.RoomID          = new SelectList(db.ROOMs, "RoomID", "RoomName");
            ViewBag.MajorID         = new SelectList(db.MAJORs, "MajorID", "MajorName");
            ViewBag.TypeCertificate = certificatelist;

            employee.EmployeeID         = eMPLOYEE.EmployeeID;
            employee.EmployeeName       = eMPLOYEE.EmployeeName;
            employee.Image              = eMPLOYEE.Image;
            employee.Sex                = eMPLOYEE.Sex;
            employee.DoB                = eMPLOYEE.DoB;
            employee.Birthplace         = eMPLOYEE.Birthplace;
            employee.HomeTown           = eMPLOYEE.HomeTown;
            employee.Nation             = eMPLOYEE.Nation;
            employee.IdNumber           = eMPLOYEE.IdNumber;
            employee.Phone              = eMPLOYEE.Phone;
            employee.Email              = eMPLOYEE.Email;
            employee.City               = eMPLOYEE.City;
            employee.Ward               = eMPLOYEE.Ward;
            employee.Dictrict           = eMPLOYEE.Dictrict;
            employee.Street             = eMPLOYEE.Street;
            employee.RoomID             = eMPLOYEE.RoomID;
            employee.PositionID         = eMPLOYEE.PositionID;
            employee.ContractID         = eMPLOYEE.ContractID;
            employee.HealthInsurance    = eMPLOYEE.FreeInsurance;
            employee.HealthInsuranceID  = eMPLOYEE.HealthInsuranceID;
            employee.DeductionPersonal  = eMPLOYEE.SelfDeduction;
            employee.DeductionDependent = (int)eMPLOYEE.DependentDeduction;
            List <EDUCATIONDETAIL> eDUCATIONDETAIL = db.EDUCATIONDETAILs.SqlQuery("Select * from EDUCATIONDETAIL where employeeID = '" + id + "'").ToList();
            CONTRACT cONTRACT = await db.CONTRACTs.FindAsync(eMPLOYEE.ContractID);

            List <CERTIFICATEDETAIL> cERTIFICATEDETAIL = db.CERTIFICATEDETAILs.SqlQuery("Select * from CERTIFICATEDETAIL where employeeID = '" + id + "'").ToList();
            USER uSER = await db.USERS.FindAsync(id);

            //Trinh do
            employee.EducationName = eDUCATIONDETAIL[0].EducationName;
            employee.MajorID       = eDUCATIONDETAIL[0].MajorID;
            employee.Date          = eDUCATIONDETAIL[0].Date;
            employee.Place         = eDUCATIONDETAIL[0].Place;
            //Chung chi
            employee.CertificateName  = cERTIFICATEDETAIL[0].CertificateName;
            employee.TypeCertificate  = cERTIFICATEDETAIL[0].TypeCertificate;
            employee.CertificateDate  = cERTIFICATEDETAIL[0].CertificateDate;
            employee.CertificatePlace = cERTIFICATEDETAIL[0].CertificatePlace;
            //Hop dong
            employee.ContractID             = cONTRACT.ContractID;
            employee.ContractType           = cONTRACT.ContractType;
            employee.DateStartWork          = cONTRACT.DateStartWork;
            employee.ContractExpirationDate = cONTRACT.ContractExpirationDate;
            employee.BasicSalary            = cONTRACT.BasicSalary;
            //Tai khoan
            employee.Password = uSER.Password;
            return(View(employee));
        }
Пример #10
0
        public ActionResult SaveEmp(EMPLOYEE CuObj, FormCollection form)
        {
            JsonSMsg rMsg = new JsonSMsg();

            try
            {
                //CuObj.NAME = CuObj.NAME.ToString();
                //CuObj.MOBILE = CuObj.MOBILE.ToString();
                CuObj.USERID = CuObj.MOBILE.ToString();
                CuObj.EwmId  = _service.GetEwmId() + 1;
                string deptId       = form["DeptId"];
                string parentDeptId = form["ParentDeptId"];
                //设置StoreName(所属部门),AreaName(部门所属区域) 的值
                if (deptJArray == null)
                {
                    setDeptJArray();
                }
                foreach (JObject dept in deptJArray)
                {
                    if (dept["id"].ToString() == deptId)
                    {
                        CuObj.StoreName = dept["name"].ToString();
                    }
                    if (dept["id"].ToString() == parentDeptId)
                    {
                        CuObj.AreaName = dept["name"].ToString();
                    }
                }

                WeiPage wp  = new WeiPage();
                string  url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + wp.Token(AppConfig.FWHOriginalID);
                //这里需要修改
                string d = @"{ ""action_name"": ""QR_LIMIT_SCENE"", ""action_info"": {""scene"": {""scene_id"": {0}}}
        
        }";
                d = d.Replace("{0}", CuObj.EwmId.ToString());
                string mes = WeiPage.HttpXmlPostRequest(url, d, Encoding.UTF8);
                //Response.Write(mes);
                string[] b      = mes.Split('\"');
                string   ticket = Server.UrlEncode(b[3]);
                //CuObj.Id = num;
                CuObj.EwmUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + ticket;
                //CuObj.MdSel = "qrscene_" + num.ToString();
                int num = _service.SaveEMPLOYEE(CuObj);
                if (num > 0)
                {
                    rMsg.Status  = 0;
                    rMsg.Message = "保存成功";
                }
                else
                {
                    rMsg.Status  = -1;
                    rMsg.Message = "保存失败";
                }
            }
            catch (Exception ex)
            {
                rMsg.Status  = -1;
                rMsg.Message = ex.Message;
            }
            return(Json(rMsg));
        }
Пример #11
0
        /// <summary>
        /// 根据员工ID和公司ID查询考勤记录表 weirui 2012-12-6 add
        /// </summary>
        /// <param name="ownerId"></param>
        /// <param name="ownerCompanyId"></param>
        /// <returns></returns>
        public List <AbnormalAttendanceeEntity> ListEMPLOYEEABNORMRECORD(string ownerId, string ownerCompanyId, string startDate, string endDate)
        {
            List <AbnormalAttendanceeEntity> listEMPLOYEE = new List <AbnormalAttendanceeEntity>();

            DateTime startDates = DateTime.Parse(startDate);
            DateTime endDates   = DateTime.Parse(endDate);

            try
            {
                //根据

                //根据公司ID查询此公司的员工信息 目标集合
                var companyInfo = from t in dal.GetObjects <T_HR_EMPLOYEE>()
                                  where t.EMPLOYEESTATE != "2" &&
                                  t.OWNERCOMPANYID == ownerCompanyId
                                  select t;
                //表示选择人员查询,数据过滤
                if (!string.IsNullOrEmpty(ownerId))
                {
                    companyInfo = from t in companyInfo
                                  where t.EMPLOYEEID == ownerId
                                  select t;
                    //companyInfo.Where(c => c.EMPLOYEEID == ownerId);
                }

                //查询异常考勤记录表
                var q = from t in dal.GetObjects <T_HR_EMPLOYEEABNORMRECORD>()
                        join p in dal.GetObjects <T_HR_ATTENDANCERECORD>()
                        on t.T_HR_ATTENDANCERECORD.ATTENDANCERECORDID equals p.ATTENDANCERECORDID
                        where t.OWNERCOMPANYID == ownerCompanyId &&
                        t.ABNORMALDATE >= startDates &&
                        t.ABNORMALDATE <= endDates
                        select t;


                //已目标值为基础 左连接
                var enployeeInfo = from t in companyInfo
                                   join y in q
                                   on t.EMPLOYEEID equals y.OWNERID into EMPLOYEE
                                   from n in EMPLOYEE.DefaultIfEmpty()
                                   select new AbnormalAttendanceeEntity
                {
                    //员工名字
                    cname = t.EMPLOYEECNAME,
                    //员工ID
                    EMPLOYEEID = t.EMPLOYEEID,
                    //异常类型
                    ABNORMCATEGORY = n.ABNORMCATEGORY,
                    //异常时长
                    ABNORMALTIME = n.ABNORMALTIME
                };

                if (enployeeInfo.Count() > 0)
                {
                    return(enployeeInfo.ToList());
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #12
0
        public void insertOrUpdateEmployee(string name, string address, DateTime birthday, DateTime approveDt, DateTime sevDt, string idno, string gender, string workStatus, string phone, string position)
        {
            String error = "";

            try {
                if (!checkValidName(name))
                {
                    error += "Tên rỗng hoặc không hợp lệ \n";//"Name is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidAddress(address))
                {
                    error += "Địa chỉ rỗng hoặc không hợp lệ \n";//"Address is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidBirthday(birthday))
                {
                    error += "Ngày sinh rỗng hoặc không hợp lệ \n";//"Birthday is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidApproveDT(birthday, approveDt))
                {
                    error += "Ngày vào làm rỗng hoặc không hợp lệ \n";//"Approve Date is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidIDNo(idno))
                {
                    error += "CMND rỗng hoặc không hợp lệ ( >=10 số )\n";
                    throw new Exception();
                }
                if (!checkValidGender(gender))
                {
                    error += "Giới tính không hợp lệ \n";//"Gender is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidWorkStatus(workStatus))
                {
                    error += "Trạng thái không hợp lệ \n";//"workStatus is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidSevDT(approveDt, sevDt, workStatus))
                {
                    error += "Ngày nghỉ việc làm rỗng hoặc không hợp lệ \n";//"Sev Date is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidPhone(phone))
                {
                    error += "Số điện thoại không hợp lệ \n";//"Sev Date is empty or invalid\n";
                    throw new Exception();
                }
                if (!checkValidPosition(position))
                {
                    error += "Vị trí làm việc không hợp lệ \n";//"Sev Date is empty or invalid\n";
                    throw new Exception();
                }

                emp.EMP_NAME      = name;
                emp.BIRTHDAY      = birthday;
                emp.APPROVE_DATE  = approveDt;
                emp.ADDRESS       = address;
                emp.GENDER        = gender;
                emp.ID_CARD_NO    = idno;
                emp.PHONE         = phone;
                emp.POSITION      = position;
                emp.SEV_DATE      = sevDt;
                emp.WORK_STATUS   = workStatus;
                emp.RECORD_STATUS = (char)RECORD_STATUS.ACTIVE + "";
                if (!isUpdated)
                {
                    if (model.addEmployee(emp))
                    {
                        empAddingView.showMessageBox(Resources.MB_SUCCESS, MessageBoxIcon.Information);
                        emp = new EMPLOYEE();
                        empAddingView.refreshAll();
                    }
                    else
                    {
                        empAddingView.showMessageBox(Resources.MB_FAILURE, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (model.updateEmployee(emp))
                    {
                        empAddingView.showMessageBox(Resources.MB_SUCCESS, MessageBoxIcon.Information);
                        empAddingView.backPreviousForm();
                    }
                    else
                    {
                        empAddingView.showMessageBox(Resources.MB_FAILURE, MessageBoxIcon.Information);
                    }
                }
            }catch (Exception e)
            {
                empAddingView.showMessageBox(error, MessageBoxIcon.Error);
            }
        }
Пример #13
0
 public int SaveEMPLOYEE(EMPLOYEE sys)
 {
     return(_set.SaveEMPLOYEE(sys));
 }
Пример #14
0
 public void EMPLOYEE_INSERT(EMPLOYEE EMP)
 {
     EMPDAO.EMPLOYEE_INSERT(EMP);
 }
Пример #15
0
 public void EMPLOYEE_DELETE(EMPLOYEE EMP)
 {
     EMPDAO.EMPLOYEE_DELETE(EMP);
 }
Пример #16
0
        public void displayUsers()
        {
            Button btnAdd;

            try
            {
                userList = handler.userList();

                tblUsers.CssClass = "table table-light table-hover";

                TableRow row = new TableRow();
                row.Height = 50;
                tblUsers.Rows.Add(row);

                TableCell userImage = new TableCell();
                userImage.Width = 300;
                tblUsers.Rows[0].Cells.Add(userImage);

                TableCell fullName = new TableCell();
                fullName.Text      = "Full Name";
                fullName.Width     = 300;
                fullName.Font.Bold = true;
                tblUsers.Rows[0].Cells.Add(fullName);

                TableCell userType = new TableCell();
                userType.Text      = "User Type";
                userType.Width     = 200;
                userType.Font.Bold = true;
                tblUsers.Rows[0].Cells.Add(userType);

                TableCell adLine1 = new TableCell();
                adLine1.Text      = "AddressLine 1";
                adLine1.Width     = 200;
                adLine1.Font.Bold = true;
                tblUsers.Rows[0].Cells.Add(adLine1);

                TableCell adLine2 = new TableCell();
                adLine2.Text      = "AddressLine 2";
                adLine2.Width     = 200;
                adLine2.Font.Bold = true;
                tblUsers.Rows[0].Cells.Add(adLine2);

                int i = 1;

                foreach (SP_UserList u in userList)
                {
                    TableRow r = new TableRow();
                    tblUsers.Rows.Add(r);

                    TableCell uImage = new TableCell();
                    uImage.Width = 150;
                    uImage.Text  = "<img src=" + u.UserImage +
                                   " alt='User Profile Picture' " +
                                   "width='80' height='80' />";
                    tblUsers.Rows[i].Cells.Add(uImage);

                    TableCell fName = new TableCell();
                    fName.Text      = u.FullName.ToString();
                    fName.Width     = 300;
                    fName.Font.Bold = true;
                    tblUsers.Rows[i].Cells.Add(fName);

                    TableCell uTypeCell = new TableCell();
                    uTypeCell.Height = 100;
                    RadioButtonList uTypeList = new RadioButtonList();
                    uTypeList.ClientIDMode = ClientIDMode.AutoID;
                    uTypeList.Items.Add("R");
                    uTypeList.Items.Add("S");
                    uTypeList.CellPadding     = 10;
                    uTypeList.RepeatDirection = RepeatDirection.Horizontal;
                    uTypeList.DataBind();
                    uTypeCell.Controls.Add(uTypeList);
                    tblUsers.Rows[i].Cells.Add(uTypeCell);

                    TableCell a1          = new TableCell();
                    TextBox   txtAddLine1 = new TextBox();
                    txtAddLine1.ClientIDMode = ClientIDMode.AutoID;
                    txtAddLine1.CssClass     = "form-control";
                    a1.Controls.Add(txtAddLine1);
                    tblUsers.Rows[i].Cells.Add(a1);


                    TableCell a2          = new TableCell();
                    TextBox   txtAddLine2 = new TextBox();
                    txtAddLine2.ClientIDMode = ClientIDMode.AutoID;
                    txtAddLine2.CssClass     = "form-control";
                    a2.Controls.Add(txtAddLine2);
                    tblUsers.Rows[i].Cells.Add(a2);


                    TableCell buttonCell = new TableCell();
                    buttonCell.Width  = 300;
                    buttonCell.Height = 100;
                    btnAdd            = new Button();
                    btnAdd.Text       = "Add";
                    btnAdd.CssClass   = "btn btn-primary";
                    btnAdd.Click     += (ss, ee) =>
                    {
                        try
                        {
                            emp = new EMPLOYEE();

                            emp.EmployeeID   = u.UserID.ToString();
                            emp.AddressLine1 = txtAddLine1.Text;
                            emp.AddressLine2 = txtAddLine2.Text;
                            emp.Type         = uTypeList.SelectedValue.ToString();

                            if ((txtAddLine1.Text.ToString() == string.Empty) || (txtAddLine2.Text.ToString() == string.Empty) || (uTypeList.SelectedValue.ToString() == string.Empty))
                            {
                                valLabel.Text    = "<p style='font-size:14px;color:red;'>&nbsp;*Please enter all fields</p>";
                                valLabel.Visible = true;
                                buttonCell.Controls.Add(valLabel);
                            }

                            if (txtAddLine1.Text.ToString() != string.Empty && txtAddLine2.Text.ToString() != string.Empty && uTypeList.SelectedValue.ToString() != string.Empty)
                            {
                                /*
                                 * if (handler.addEmployee(emp))
                                 * {
                                 *  Response.Write("<script>alert('Employee Added');</script>");
                                 *  Response.Redirect(Request.RawUrl);
                                 * }
                                 * else
                                 * {
                                 *  //Response.Write("<script>alert('Error. Please try again');</script>");
                                 *  phAddErr.Visible = true;
                                 *  lblAddErr.Text = "An error has occured.Please try again or report to management.<br/>"
                                 + "Sorry for the inconvenience.";
                                 + }
                                 */
                            }
                        }
                        catch (Exception err)
                        {
                            //Response.Write("<script>alert('Our apologies. An error has occured.')</script>");
                            phAddErr.Visible = true;
                            lblAddErr.Text   = "An error has occured.We are unable to add the employee at this point in time.<br/>"
                                               + "Sorry for the inconvenience.Please report to management or the administrator."
                                               + "<br/>Error: " + err.ToString();
                            //add error to the error log and then display response tab to say that an error has occured
                            function.logAnError(err.ToString());
                        }
                    };
                    //add button to cell
                    buttonCell.Controls.Add(btnAdd);
                    //add cell to row
                    tblUsers.Rows[i].Cells.Add(buttonCell);

                    i++;
                }
            }
            catch (Exception E)
            {
                phUsersErr.Visible = true;
                errorHeader.Text   = "Error displaying users";
                errorMessage.Text  = "It seems there is a problem communicating with the database."
                                     + "Please report problem to admin or try again later.";
                function.logAnError(E.ToString());
            }
        }
Пример #17
0
        public ActionResult Create(USERPERMISSION userpermission, string type = "")
        {
            if (ModelState.IsValid)
            {
                USERPERMISSION userpermissionFound = db.USERPERMISSIONs.SingleOrDefault(u => u.USERID == userpermission.USERID);

                if (userpermissionFound != null)
                {
                    if (userpermission.BONDERID != null)
                    {
                        if (userpermission.ROLENAME == "Bonder")
                        {
                            BONDER bonder = db.BONDERs.SingleOrDefault(u => u.BONDERSLNO == userpermission.BONDERID);
                            userpermission.BONDER = bonder;
                        }
                        else
                        {
                            userpermission.BONDERID = null;
                        }
                    }
                    else if (userpermission.EMPLOYID != null)
                    {
                        EMPLOYEE employee = db.EMPLOYEEs.SingleOrDefault(u => u.EMPLOYEESLNO == userpermission.EMPLOYID);
                        userpermission.EMPLOYEE = employee;
                    }
                    if (userpermissionFound.EMPLOYID == null && userpermission.EMPLOYID != null)
                    {
                        userpermission.BONDER   = null;
                        userpermission.BONDERID = null;
                    }
                    if (userpermissionFound.BONDERID == null && userpermission.BONDERID != null)
                    {
                        userpermission.EMPLOYEE = null;
                        userpermission.EMPLOYID = null;
                    }
                    if (userpermission.USERID > 0)
                    {
                        APPUSER appuser = db.APPUSERs.SingleOrDefault(u => u.ID == userpermission.USERID);
                        userpermission.APPUSER      = appuser;
                        userpermissionFound.APPUSER = appuser;
                    }


                    ((IObjectContextAdapter)db).ObjectContext.Detach(userpermissionFound);
                    USERPERMISSION userpermissionFnd = db.USERPERMISSIONs.Find(userpermissionFound.ID);
                    db.USERPERMISSIONs.Remove(userpermissionFnd);
                    db.SaveChanges();
                    //db.Entry(userpermission).State = EntityState.Modified;
                    if (type.Equals("Operation Admin"))
                    {
                        userpermission.BONDER   = null;
                        userpermission.BONDERID = null;
                    }
                    else if (type.Equals("Bonder"))
                    {
                        userpermission.EMPLOYEE = null;
                        userpermission.EMPLOYID = null;
                    }
                    db.USERPERMISSIONs.Add(userpermission);
                    db.SaveChanges();
                }
                else
                {
                    if (type.Equals("Operation Admin"))
                    {
                        userpermission.BONDER   = null;
                        userpermission.BONDERID = null;
                    }
                    else if (type.Equals("Bonder"))
                    {
                        userpermission.EMPLOYEE = null;
                        userpermission.EMPLOYID = null;
                    }
                    db.USERPERMISSIONs.Add(userpermission);
                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "AppUser", null));
            }

            ViewBag.USERID   = new SelectList(db.APPUSERs, "ID", "USERNAME", userpermission.USERID);
            ViewBag.BONDERID = new SelectList(db.BONDERs, "BONDERSLNO", "BONDERNAME", userpermission.BONDERID);
            ViewBag.EMPLOYID = new SelectList(db.EMPLOYEEs, "EMPLOYEESLNO", "EMPLOYEENAME", userpermission.EMPLOYID);
            return(View(userpermission));
        }
Пример #18
0
 public REQ_COMMAND()
 {
     OPERATOR = EMPLOYEE.CreateInstance();
 }
Пример #19
0
 public EmployeePresenter()
 {
     emp        = new EMPLOYEE();
     this.model = new EmployeeModel();
 }
Пример #20
0
        public int SaveEmployee(string accessToken, EMPLOYEE entity, DeptInfo dept, ref string errMsg)
        {
            using (TransScope scope = new TransScope())
            {
                int        wxGroupId = 0, deptId = dept.ID;
                GROUP_INFO groupInfo = null;
                if (entity.ID > 0)
                {
                    var rel = _empRepo.GetGroupIdByEmpID(entity.ID);
                    deptId = rel;
                }
                groupInfo = _groupRepo.Get(deptId);
                if (groupInfo == null)
                {
                    return(0);
                }
                wxGroupId = groupInfo.WX_GROUP_ID;
                List <int> department = new List <int>()
                {
                    wxGroupId
                };
                string gender = entity.GENDER.HasValue ? entity.GENDER.Value.ToString() : null;

                int rows = 0;
                if (entity.ID == 0)
                {
                    var response = WXQYClientServiceApi.Create().CreateUser(accessToken, entity.USERID, entity.NAME, department, entity.POSITION, entity.MOBILE, gender, entity.EMAIL, entity.WECHAT_ID);
                    if (response != null && response.ErrorCode == 0)
                    {
                        //同步头像
                        UserInfo user = WXQYClientServiceApi.Create().GetUser(accessToken, entity.USERID);
                        if (user != null)
                        {
                            entity.AVATAR_URL = user.Avatar;
                        }
                        entity.STATUS      = 4;
                        entity.CREATE_TIME = DateTime.Now;
                        rows      = (int)_empRepo.Insert(entity);
                        entity.ID = rows;
                        //修改关系表
                        if (rows > 0)
                        {
                            //删除所有员工关系
                            _empRepo.DeleteRelByEmpID(entity.ID);
                            //新增关系
                            REL_EMP_GROUP rel = new REL_EMP_GROUP();
                            rel.TYPE        = groupInfo.TYPE;
                            rel.EMP_ID      = entity.ID;
                            rel.GROUP_ID    = deptId;
                            rel.CREATE_TIME = DateTime.Now;
                            rel.CREATE_USER = "******";
                            _empRepo.Insert(rel);
                        }
                    }
                    else
                    {
                        errMsg = response.ErrorMessage;
                    }
                }
                else
                {
                    var response = WXQYClientServiceApi.Create().UpdateUser(accessToken, entity.USERID, entity.NAME, department, entity.POSITION, entity.MOBILE, gender, entity.EMAIL, entity.WECHAT_ID);
                    if (response != null && response.ErrorCode == 0)
                    {
                        //同步头像
                        UserInfo user = WXQYClientServiceApi.Create().GetUser(accessToken, entity.USERID);
                        if (user != null)
                        {
                            entity.AVATAR_URL = user.Avatar;
                        }
                        entity.FullUpdate = false;
                        rows = _empRepo.Update(entity);
                    }
                    else
                    {
                        errMsg = response.ErrorMessage;
                    }
                }

                scope.Commit();

                return(rows);
            }
        }
Пример #21
0
        public bool Login([FromBody] EMPLOYEE emp)
        {
            EmployeeManager manager = EmployeeManager.GetInstance();

            return(manager.Login(emp.EMP_ID, emp.EMP_PW));
        }
Пример #22
0
        public ActionResult EmpAddOrSearch(string op)
        {
            ViewData["front"] = "3";
            EntitieFinal entitie = new EntitieFinal();

            if (op == "add")
            {
                var emp = new EMPLOYEE();
                emp.EMPLOYEE_ID   = long.Parse(Request["ID"]);
                emp.EMPLOYEE_NAME = Request["NAME"];
                emp.EMPLOYEE_SEX  = 0;
                if (Request["NAME"] == "女")
                {
                    emp.EMPLOYEE_SEX = 1;
                }
                emp.EMPLOYEE_EMAIL       = Request["EMAIL"];
                emp.EMPLOYEE_DEPART_NAME = Request["DEP"];
                emp.EMPLOYEE_TITLE       = Request["TIT"];
                emp.EMPLOYEE_SALARY      = 0;
                emp.EMPLOYEE_ADDRESS_ID  = 1;
                emp.EMPLOYEE_ENTRY_TIME  = new DateTime(2000, 1, 1);
                entitie.EMPLOYEEs.Add(emp);
                entitie.SaveChanges();
                GetData();
                return(RedirectToAction("AdminView"));
            }
            else
            {
                var empList = from emp in entitie.EMPLOYEEs
                              select emp;
                if (!string.IsNullOrEmpty(Request["ID"]))
                {
                    var p = long.Parse(Request["ID"]);
                    empList = from emp in empList
                              where emp.EMPLOYEE_ID == p
                              select emp;
                }
                if (!string.IsNullOrEmpty(Request["NAME"]))
                {
                    var p = Request["NAME"];

                    empList = from emp in empList
                              where emp.EMPLOYEE_NAME == p
                              select emp;
                }
                if (!string.IsNullOrEmpty(Request["SEX"]))
                {
                    long p = 0;
                    if (Request["SEX"] == "女")
                    {
                        p = 1;
                    }
                    empList = from emp in empList
                              where emp.EMPLOYEE_SEX == p
                              select emp;
                }
                if (!string.IsNullOrEmpty(Request["EMAIL"]))
                {
                    var p = Request["EMAIL"];
                    empList = from emp in empList
                              where emp.EMPLOYEE_EMAIL == p
                              select emp;
                }
                if (!string.IsNullOrEmpty(Request["DEP"]))
                {
                    var p = Request["DEP"];
                    empList = from emp in empList
                              where emp.EMPLOYEE_DEPART_NAME == p
                              select emp;
                }
                if (!string.IsNullOrEmpty(Request["TIT"]))
                {
                    var p = Request["TIT"];
                    empList = from emp in empList
                              where emp.EMPLOYEE_TITLE == p
                              select emp;
                }
                GetData();
                ViewData["EMP"] = empList.ToList();
            }


            return(View("AdminView"));
        }
Пример #23
0
        public async Task <ActionResult> Create([Bind(Include = "EmployeeName,ImageFile,Sex,DoB,Birthplace,HomeTown,Nation,IdNumber,Phone,Email,City,Ward,Dictrict,Street,RoomID,PositionID,ContractID,HealthInsurance,HealthInsuranceID,DeductionPersonal,DeductionDependent,EducationName,MajorID,Date,Place,CertificateName,TypeCertificate,CertificateDate,CertificatePlace,ContractID,ContractType,DateStartWork,ContractExpirationDate,BasicSalary,Password")] EmployeeViewModel employee)
        {
            //Tao ID nhan vien tu dong
            var    emloyeeList = db.EMPLOYEEs.SqlQuery("Select * from EMPLOYEE").ToList();
            int    n           = 0;
            string id;
            bool   flag;

            do
            {
                n++;
                flag = false;
                String formatted = String.Format("{0:000000}", n);
                id = "NV" + formatted;
                foreach (var i in emloyeeList)
                {
                    if (i.EmployeeID == id)
                    {
                        flag = true;
                        break;
                    }
                }
            }while (flag == true);
            List <SelectListItem> city            = new List <SelectListItem>();
            List <SelectListItem> ward            = new List <SelectListItem>();
            List <SelectListItem> dictrict        = new List <SelectListItem>();
            List <SelectListItem> nation          = new List <SelectListItem>();
            List <SelectListItem> contractType    = new List <SelectListItem>();
            List <SelectListItem> education       = new List <SelectListItem>();
            List <SelectListItem> typecertificate = new List <SelectListItem>();
            var Directory = AppDomain.CurrentDomain.BaseDirectory;
            //path of folder
            var path     = Directory + "./File_Text/";
            var encoding = Encoding.UTF8;

            string[] lines1 = System.IO.File.ReadAllLines(path + "City.txt", encoding);
            string[] lines2 = System.IO.File.ReadAllLines(path + "Ward.txt", encoding);
            string[] lines3 = System.IO.File.ReadAllLines(path + "Dictrict.txt", encoding);
            string[] lines4 = System.IO.File.ReadAllLines(path + "Nation.txt", encoding);
            string[] lines5 = System.IO.File.ReadAllLines(path + "ContractType.txt", encoding);
            string[] lines6 = System.IO.File.ReadAllLines(path + "Education.txt", encoding);
            string[] lines7 = System.IO.File.ReadAllLines(path + "TypeCertificate.txt", encoding);
            foreach (string line in lines1)
            {
                city.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines2)
            {
                ward.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines3)
            {
                dictrict.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines4)
            {
                nation.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines5)
            {
                contractType.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines6)
            {
                education.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            foreach (string line in lines7)
            {
                typecertificate.Add(new SelectListItem()
                {
                    Text  = line,
                    Value = line
                });
            }
            SelectList citylist         = new SelectList(city, "Value", "Text");
            SelectList wardlist         = new SelectList(ward, "Value", "Text");
            SelectList dictrictlist     = new SelectList(dictrict, "Value", "Text");
            SelectList nationlist       = new SelectList(nation, "Value", "Text");
            SelectList contracttypelist = new SelectList(contractType, "Value", "Text");
            SelectList educationlist    = new SelectList(education, "Value", "Text");
            SelectList certificatelist  = new SelectList(typecertificate, "Value", "Text");

            // Set vào ViewBag
            ViewBag.Birthplace      = citylist;
            ViewBag.HomeTown        = citylist;
            ViewBag.nationList      = nationlist;
            ViewBag.ContractType    = contracttypelist;
            ViewBag.City            = citylist;
            ViewBag.Ward            = wardlist;
            ViewBag.Dictrict        = dictrictlist;
            ViewBag.EducationName   = educationlist;
            ViewBag.PositionID      = new SelectList(db.POSITIONs, "PositionID", "PositionName");
            ViewBag.RoomID          = new SelectList(db.ROOMs, "RoomID", "RoomName");
            ViewBag.MajorID         = new SelectList(db.MAJORs, "MajorID", "MajorName");
            ViewBag.TypeCertificate = certificatelist;
            ViewBag.EmployeeID      = id;
            if (employee.ContractExpirationDate < employee.DateStartWork)
            {
                ModelState.AddModelError("ContractExpirationDate", "Ngày kết thúc phải lớn hơn ngày bắt đầu");
            }
            var Parameter = db.PARAMETERs.ToList();
            var tuoi      = DateTime.Now.Year - employee.DoB.Year;

            if (employee.Sex == "Nam")
            {
                if (tuoi < Parameter[19].Value) //tuoi toi thieu nam
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
                if (tuoi > Parameter[17].Value) //tuoi toi da nam
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
            }
            else
            {
                if (tuoi < Parameter[17].Value) //tuoi toi thieu nu
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
                if (tuoi > Parameter[18].Value) //tuoi toi da nu
                {
                    ModelState.AddModelError("DoB", "Tuổi không hợp lệ");
                }
            }
            if (ModelState.IsValid)
            {
                EMPLOYEE eMPLOYEE = new EMPLOYEE();
                eMPLOYEE.EmployeeID   = id;
                eMPLOYEE.EmployeeName = FormatProperCase(employee.EmployeeName); //Chuan hoa chuoi
                if (employee.ImageFile != null)
                {
                    BinaryReader b       = new BinaryReader(employee.ImageFile.InputStream);
                    byte[]       binData = b.ReadBytes(employee.ImageFile.ContentLength);
                    eMPLOYEE.Image = binData;
                }
                eMPLOYEE.Sex                = employee.Sex;
                eMPLOYEE.DoB                = (DateTime)employee.DoB;
                eMPLOYEE.Birthplace         = employee.Birthplace;
                eMPLOYEE.HomeTown           = employee.HomeTown;
                eMPLOYEE.Nation             = employee.Nation;
                eMPLOYEE.IdNumber           = employee.IdNumber;
                eMPLOYEE.Phone              = employee.Phone;
                eMPLOYEE.Email              = employee.Email;
                eMPLOYEE.City               = employee.City;
                eMPLOYEE.Ward               = employee.Ward;
                eMPLOYEE.Street             = employee.Street;
                eMPLOYEE.Dictrict           = employee.Dictrict;
                eMPLOYEE.RoomID             = employee.RoomID;
                eMPLOYEE.PositionID         = employee.PositionID;
                eMPLOYEE.ContractID         = employee.ContractID;
                eMPLOYEE.FreeInsurance      = Convert.ToBoolean(employee.HealthInsurance);
                eMPLOYEE.HealthInsuranceID  = employee.HealthInsuranceID;
                eMPLOYEE.SelfDeduction      = Convert.ToBoolean(employee.DeductionPersonal);
                eMPLOYEE.DependentDeduction = employee.DeductionDependent;
                eMPLOYEE.State              = true;
                //Trinh do
                EDUCATIONDETAIL eDUCATIONDETAIL = new EDUCATIONDETAIL();
                eDUCATIONDETAIL.EmployeeID    = id;
                eDUCATIONDETAIL.EducationName = employee.EducationName;
                if (eDUCATIONDETAIL.EducationName == "10" || eDUCATIONDETAIL.EducationName == "11" || eDUCATIONDETAIL.EducationName == "12")
                {
                    eDUCATIONDETAIL.MajorID = "M09";
                }
                else
                {
                    eDUCATIONDETAIL.MajorID = employee.MajorID;
                }
                eDUCATIONDETAIL.Date  = employee.Date;
                eDUCATIONDETAIL.Place = employee.Place;
                db.EDUCATIONDETAILs.Add(eDUCATIONDETAIL);
                //Chung chi
                CERTIFICATEDETAIL cERTIFICATEDETAIL = new CERTIFICATEDETAIL();
                cERTIFICATEDETAIL.EmployeeID       = id;
                cERTIFICATEDETAIL.CertificateName  = employee.CertificateName;
                cERTIFICATEDETAIL.CertificateDate  = employee.CertificateDate;
                cERTIFICATEDETAIL.CertificatePlace = employee.CertificatePlace;
                cERTIFICATEDETAIL.TypeCertificate  = employee.TypeCertificate;
                db.CERTIFICATEDETAILs.Add(cERTIFICATEDETAIL);
                //Hop dong
                CONTRACT cONTRACT = new CONTRACT();
                cONTRACT.ContractID             = employee.ContractID;
                cONTRACT.ContractType           = employee.ContractType;
                cONTRACT.DateStartWork          = (DateTime)employee.DateStartWork;
                cONTRACT.ContractExpirationDate = (DateTime)employee.ContractExpirationDate;
                cONTRACT.BasicSalary            = employee.BasicSalary;
                //Tai khoan
                USER uSER = new USER();
                uSER.EmployeeID = id;
                uSER.Password   = employee.Password;
                db.CONTRACTs.Add(cONTRACT);
                db.EMPLOYEEs.Add(eMPLOYEE);
                db.USERS.Add(uSER);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(employee));
        }
Пример #24
0
        public ActionResult Index(string FirstName, string EmpType, string LastName, string Email, EMPLOYEE emp)
        {
            var eMPLOYEEs = db.EMPLOYEEs.ToList().Where(p => p.F_name.StartsWith(FirstName) && p.Employee_type.StartsWith(EmpType) &&
                                                        p.L_name.StartsWith(LastName) && p.Email_address.Contains(Email));
            var        getTypeList = db.EMPLOYEE_TYPES.ToList();
            SelectList list        = new SelectList(getTypeList, "TypeID", "Employee_Type");

            ViewBag.employeetype = list;
            return(View(eMPLOYEEs));
        }
Пример #25
0
        // GET: EMPLOYEEs/Details/5
        public async Task <ActionResult> Details(string id)
        {
            Session["MainTitle"] = "Quản lý nhân sự";
            Session["SubTitle"]  = "Thông tin nhân viên";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EMPLOYEE eMPLOYEE = await db.EMPLOYEEs.FindAsync(id);

            if (eMPLOYEE == null)
            {
                return(HttpNotFound());
            }
            EmployeeViewModel employee = new EmployeeViewModel();

            employee.EmployeeID         = eMPLOYEE.EmployeeID;
            employee.EmployeeName       = eMPLOYEE.EmployeeName;
            employee.Image              = eMPLOYEE.Image;
            employee.Sex                = eMPLOYEE.Sex;
            employee.DoB                = eMPLOYEE.DoB;
            employee.Birthplace         = eMPLOYEE.Birthplace;
            employee.HomeTown           = eMPLOYEE.HomeTown;
            employee.Nation             = eMPLOYEE.Nation;
            employee.IdNumber           = eMPLOYEE.IdNumber;
            employee.Phone              = eMPLOYEE.Phone;
            employee.Email              = eMPLOYEE.Email;
            employee.City               = eMPLOYEE.City;
            employee.Ward               = eMPLOYEE.Ward;
            employee.Dictrict           = eMPLOYEE.Dictrict;
            employee.RoomName           = eMPLOYEE.ROOM.RoomName;
            employee.PositionName       = eMPLOYEE.POSITION.PositionName;
            employee.ContractID         = eMPLOYEE.ContractID;
            employee.HealthInsurance    = eMPLOYEE.FreeInsurance;
            employee.HealthInsuranceID  = eMPLOYEE.HealthInsuranceID;
            employee.SocialInsuranceID  = eMPLOYEE.HealthInsuranceID.Substring(eMPLOYEE.HealthInsuranceID.Length - 10, 10);
            employee.DeductionPersonal  = eMPLOYEE.SelfDeduction;
            employee.DeductionDependent = (int)eMPLOYEE.DependentDeduction;
            employee.State              = (bool)eMPLOYEE.State;
            List <EDUCATIONDETAIL> eDUCATIONDETAIL = db.EDUCATIONDETAILs.SqlQuery("Select * from EDUCATIONDETAIL where employeeID = '" + id + "'").ToList();
            CONTRACT cONTRACT = await db.CONTRACTs.FindAsync(eMPLOYEE.ContractID);

            List <CERTIFICATEDETAIL> cERTIFICATEDETAIL = db.CERTIFICATEDETAILs.SqlQuery("Select * from CERTIFICATEDETAIL where employeeID = '" + id + "'").ToList();

            //Trinh do
            employee.EducationName = eDUCATIONDETAIL[0].EducationName;
            employee.MajorName     = eDUCATIONDETAIL[0].MAJOR.MajorName;
            employee.Date          = eDUCATIONDETAIL[0].Date;
            employee.Place         = eDUCATIONDETAIL[0].Place;
            //Chung chi
            employee.CertificateName  = cERTIFICATEDETAIL[0].CertificateName;
            employee.TypeCertificate  = cERTIFICATEDETAIL[0].TypeCertificate;
            employee.CertificateDate  = cERTIFICATEDETAIL[0].CertificateDate;
            employee.CertificatePlace = cERTIFICATEDETAIL[0].CertificatePlace;
            //Hop dong
            employee.ContractID             = cONTRACT.ContractID;
            employee.ContractType           = cONTRACT.ContractType;
            employee.DateStartWork          = cONTRACT.DateStartWork;
            employee.ContractExpirationDate = cONTRACT.ContractExpirationDate;
            employee.BasicSalary            = (int)cONTRACT.BasicSalary;
            return(View(employee));
        }
 public void PostSingleEmployee(EMPLOYEE employee)
 {
     employee.EMPLOYEE_ID = (short)(db.EMPLOYEEs.Max(t => t.EMPLOYEE_ID) + 1);
     db.EMPLOYEEs.Add(employee);
     db.SaveChanges();
 }
Пример #27
0
        /// <summary>
        /// How to Archive a employee?
        /// </summary>


        public void Editprofile(EMPLOYEE employee)
        {
            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtUserNo.Text.Trim() == "")
            {
                MessageBox.Show("User No is empty!");
            }

            else if (txtPassword.Text.Trim() == "")
            {
                MessageBox.Show("User has no password!");
            }
            else if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("User Name is empty!");
            }
            else if (txtSurname.Text.Trim() == "")
            {
                MessageBox.Show("User Surname is empty!");
            }
            else if (txtSalary.Text.Trim() == "")
            {
                MessageBox.Show("User has no salary!");
            }
            else if (cmbDepartment.SelectedIndex == -1)
            {
                MessageBox.Show("Select a department!");
            }
            else if (cmbPosition.SelectedIndex == -1)
            {
                MessageBox.Show("Select a position!");
            }
            else
            {
                if (!isUpdated)
                {
                    if (!EmployeeBLL.isUnique(Convert.ToInt32(txtUserNo.Text)))
                    {
                        MessageBox.Show("This user No is already taken!");
                    }
                    else
                    {
                        EMPLOYEE employee = new EMPLOYEE();
                        employee.UserNo       = Convert.ToInt32(txtUserNo.Text);
                        employee.Password     = PasswordEncryption.CreateMD5Hash(txtPassword.Text);
                        employee.isAdmin      = chAdmin.Checked;
                        employee.Name         = txtName.Text;
                        employee.Surname      = txtSurname.Text;
                        employee.Salary       = Convert.ToInt32(txtSalary.Text);
                        employee.DepartmentID = Convert.ToInt32(cmbDepartment.SelectedValue);
                        employee.PositionID   = Convert.ToInt32(cmbPosition.SelectedValue);
                        employee.Address      = txtAddress.Text;
                        employee.Birthday     = dateTimePicker1.Value;
                        employee.ImagePath    = fileName;
                        EmployeeBLL.AddEmployee(employee);
                        File.Copy(txtImagePath.Text, @"Images\\" + fileName);
                        MessageBox.Show("Employee successfuly added!");
                        txtUserNo.Clear();
                        txtPassword.Clear();
                        chAdmin.Checked = false;
                        txtName.Clear();
                        txtSurname.Clear();
                        txtSalary.Clear();
                        txtAddress.Clear();
                        txtImagePath.Clear();
                        pictureBox1.Image           = null;
                        comboFull                   = false;
                        cmbDepartment.SelectedIndex = -1;
                        cmbPosition.DataSource      = dto.Positions;
                        cmbPosition.SelectedIndex   = -1;
                        comboFull                   = true;
                        dateTimePicker1.Value       = DateTime.Today;
                        fileName = "";
                    }
                }

                else
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure?", "Warning", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        EMPLOYEE employee = new EMPLOYEE();
                        if (txtImagePath.Text != imagePath)
                        {
                            if (File.Exists(@"Images\\" + detail.ImagePath))
                            {
                                File.Delete(@"Images\\" + detail.ImagePath);
                            }
                            File.Copy(txtImagePath.Text, @"Images\\" + fileName);
                            employee.ImagePath = fileName;
                        }
                        else
                        {
                            employee.ImagePath = detail.ImagePath;
                        }
                        employee.ID           = detail.EmployeeID;
                        employee.UserNo       = Convert.ToInt32(txtUserNo.Text);
                        employee.Address      = txtAddress.Text;
                        employee.Birthday     = dateTimePicker1.Value;
                        employee.Name         = txtName.Text;
                        employee.Surname      = txtSurname.Text;
                        employee.Password     = txtPassword.Text;
                        employee.isAdmin      = chAdmin.Checked;
                        employee.DepartmentID = Convert.ToInt32(cmbDepartment.SelectedValue);
                        employee.PositionID   = Convert.ToInt32(cmbPosition.SelectedValue);
                        employee.Salary       = Convert.ToInt32(txtSalary.Text);
                        EmployeeBLL.UpdateEmployee(employee);
                        MessageBox.Show("Employee updated!");
                        this.Close();
                    }
                }
            }
        }
Пример #29
0
 public REQ_DOCUMENT()
 {
     OPERATOR = EMPLOYEE.CreateInstance();
     FILTER   = new FILTER_DOCUMENT();
 }
        public IHttpActionResult Postitme(EmployeeUser data)
        {
            try
            {
                USER user = new USER();
                user.USERNAME = data.USERNAME;
                string passString = data.PASSWORD;
                var    hash       = GenerateHash(ApplySomeSalt(passString));
                user.PASSWORD = hash;

                user.USERTYPEID = data.USERTYPEID;
                user.UserPasswordChangeRequest = false;
                db.USERs.Add(user);
                db.SaveChanges();
                int value = int.Parse(db.USERs
                                      .OrderByDescending(p => p.USERID)
                                      .Select(r => r.USERID)
                                      .First().ToString());
                EMPLOYEE EMPLOYEE = new EMPLOYEE();
                EMPLOYEE.USERID             = value;
                EMPLOYEE.EMPLOYEETYPEID     = data.EMPLOYEETYPEID;
                EMPLOYEE.EMPLOYEENATIONALID = data.EMPLOYEENATIONALID;
                EMPLOYEE.EMPLOYEEPASSPORTNO = data.EMPLOYEEPASSPORTNO;
                EMPLOYEE.DATEEMPLOYED       = DateTime.Today;
                EMPLOYEE.ACTIVE             = true;
                EMPLOYEE.NAME         = data.NAME;
                EMPLOYEE.SURNAME      = data.SURNAME;
                EMPLOYEE.DATEOFBIRTH  = data.DATEOFBIRTH;
                EMPLOYEE.PHONE_NUMBER = data.PHONE_NUMBER;
                EMPLOYEE.EMAIL        = data.EMAIL;
                db.EMPLOYEEs.Add(EMPLOYEE);
                db.SaveChanges();
                try
                {
                    //send email with verification OTP
                    MailMessage mail       = new MailMessage();
                    SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                    mail.From = new MailAddress("*****@*****.**");
                    mail.To.Add(data.EMAIL);
                    mail.Subject                     = "Employee Details Added";
                    mail.Body                        = "Good day " + data.NAME + " " + data.SURNAME + "\n  Your details have been added to the system \n Your Username is: " + data.USERNAME;
                    SmtpServer.Port                  = 587;
                    SmtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    SmtpServer.UseDefaultCredentials = false;
                    SmtpServer.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "test123@123test");
                    SmtpServer.EnableSsl             = true;
                    SmtpServer.Send(mail);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                dynamic User = new ExpandoObject();
                User.Message = "Something went wrong !";
                return(null);
            }
            return(Ok(data));
        }