Exemple #1
0
        /// <summary>
        /// Function to Update values in Employee Table
        /// </summary>
        /// <param name="employeeinfo"></param>
        /// <returns></returns>
        public bool EmployeeEdit(EmployeeInfo employeeinfo)
        {
            bool isEdit = false;

            try
            {
                isEdit = SPEmployee.EmployeeEdit(employeeinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("EC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(isEdit);
        }
        public JsonResult SaveEmployee(string employeeId, string strEmployee)
        {
            bool         isSuccess = true;
            string       message   = "success";
            EmployeeInfo info      = new EmployeeInfo();

            try
            {
                EmployeeSP spEmployee            = new EmployeeSP();
                int        nEmployeeId           = int.Parse(employeeId);
                Dictionary <string, object> dict = JsonConvert.DeserializeObject <Dictionary <string, object> >(strEmployee);
                info.EmployeeId   = int.Parse(dict["employeeId"].ToString());
                info.EmployeeCode = dict["employeeCode"] == null ? string.Empty : dict["employeeCode"].ToString();
                info.EmployeeName = dict["employeeName"] == null ? string.Empty : dict["employeeName"].ToString();
                info.SalaryType   = dict["salaryType"] == null ? string.Empty : dict["salaryType"].ToString();
                if (info.SalaryType == "Daily wage")
                {
                    info.DailyWage = decimal.Parse(dict["dailyWage"].ToString());
                }
                else
                {
                    info.DefaultPackageId = int.Parse(dict["salaryPackage"].ToString());
                }
                info.DesignationId        = int.Parse(dict["designationId"].ToString());
                info.Dob                  = Convert.ToDateTime(dict["dob"].ToString());
                info.MaritalStatus        = dict["maritalStatus"] == null ? "Single" : dict["maritalStatus"].ToString();
                info.Gender               = dict["gender"] == null ? "Male" : dict["gender"].ToString();
                info.Qualification        = dict["qualification"] == null ? string.Empty : dict["qualification"].ToString();
                info.BloodGroup           = dict["bloodGroup"] == null ? string.Empty : dict["bloodGroup"].ToString();
                info.JoiningDate          = Convert.ToDateTime(dict["joiningDate"].ToString());
                info.TerminationDate      = Convert.ToDateTime(dict["terminationDate"].ToString());
                info.Address              = dict["address"] == null ? string.Empty : dict["address"].ToString();
                info.PhoneNumber          = dict["phoneNumber"] == null ? string.Empty : dict["phoneNumber"].ToString();
                info.MobileNumber         = dict["mobileNumber"] == null ? string.Empty : dict["mobileNumber"].ToString();
                info.Email                = dict["email"] == null ? string.Empty : dict["email"].ToString();
                info.IsActive             = bool.Parse(dict["isActive"].ToString());
                info.Narration            = dict["narration"] == null ? string.Empty : dict["narration"].ToString();
                info.BankName             = dict["bankName"] == null ? string.Empty : dict["bankName"].ToString();
                info.BankAccountNumber    = dict["bankNumber"] == null ? string.Empty : dict["bankNumber"].ToString();
                info.BranchName           = dict["branchName"] == null ? string.Empty : dict["branchName"].ToString();
                info.BranchCode           = dict["branchCode"] == null ? string.Empty : dict["branchCode"].ToString();
                info.PanNumber            = dict["panNumber"] == null ? string.Empty : dict["panNumber"].ToString();
                info.PfNumber             = dict["pfNumber"] == null ? string.Empty : dict["pfNumber"].ToString();
                info.EsiNumber            = dict["esiNumber"] == null ? string.Empty : dict["esiNumber"].ToString();
                info.PassportNo           = dict["passportNo"] == null ? string.Empty : dict["passportNo"].ToString();
                info.PassportExpiryDate   = Convert.ToDateTime(dict["passportExpiryDate"].ToString());
                info.LabourCardNumber     = dict["labourCardNumber"] == null ? string.Empty : dict["labourCardNumber"].ToString();
                info.LabourCardExpiryDate = Convert.ToDateTime(dict["labourCardExpiryDate"].ToString());
                info.VisaNumber           = dict["visaNumber"] == null ? string.Empty : dict["visaNumber"].ToString();
                info.VisaExpiryDate       = Convert.ToDateTime(dict["visaExpiryDate"].ToString());
                info.ExtraDate            = DateTime.Now;
                info.Extra1               = string.Empty;
                info.Extra2               = string.Empty;
                if (spEmployee.EmployeeCodeCheckExistance(info.EmployeeCode, nEmployeeId) == false)
                {
                    if (nEmployeeId > 0) // edit mode
                    {
                        isSuccess = spEmployee.EmployeeEdit(info);
                    }
                    else //create mode
                    {
                        nEmployeeId = (int)spEmployee.EmployeeAddWithReturnIdentity(info);
                        if (nEmployeeId <= 0)
                        {
                            isSuccess = false;
                            message   = "Can not save this employee with any issues.";
                        }
                    }
                }
                else
                {
                    isSuccess = false;
                    message   = "Employee code already Exist.";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(Json(new
            {
                isSuccess = isSuccess,
                message = message,
                data = info
            }));
        }