public ActionResult Create(Employee_Payroll_Transactions model, FormCollection form, string[] joblevelgrade, string[] JoblevelClass, string[] JobClass)
        {
            try
            {
                var Month      = form["Month"].Split(',');
                var Year       = form["Year"].Split(',');
                var percentage = form["percentage"].Split(',');


                if (joblevelgrade[0] == "1")
                {
                    var Joblevelgrade = dbcontext.Job_level_gradee.ToList();
                    foreach (var item in Joblevelgrade)
                    {
                        int    ID = item.ID;
                        var    min_basic_salary = item.min_basic_salary;
                        double year             = double.Parse(Year[0]);
                        double month            = double.Parse(Month[0]);
                        double Percentage       = double.Parse(percentage[0]);
                        var    Allowance        = (min_basic_salary * Percentage) / 100;
                        double newsalary        = (Allowance + min_basic_salary);
                        var    new_details      = new special_allowance_job_level_grade {
                            Job_level_gradeID = ID, Year = year, Month = month, Percentage = Percentage, Allowance_amount = Allowance, pervious_basic = min_basic_salary, new_basic_sallary = newsalary
                        };
                        dbcontext.special_allowance_job_level_grade.Add(new_details);
                        dbcontext.SaveChanges();
                        item.min_basic_salary = newsalary;
                        dbcontext.SaveChanges();
                    }
                }
                if (JoblevelClass[0] == "1")
                {
                    var jobleveclass = dbcontext.Job_level_class.ToList();
                    foreach (var item in jobleveclass)
                    {
                        int    ID = item.ID;
                        var    min_basic_salary = item.min_basic_salary;
                        double year             = double.Parse(Year[0]);
                        double month            = double.Parse(Month[0]);
                        double Percentage       = double.Parse(percentage[0]);
                        var    Allowance        = (min_basic_salary * Percentage) / 100;
                        double newsalary        = (Allowance + min_basic_salary);
                        var    new_details      = new special_allowance_job_level_class {
                            Job_level_classID = ID, Year = year, Month = month, Percentage = Percentage, Allowance_amount = Allowance, pervious_basic = min_basic_salary, new_basic_sallary = newsalary
                        };
                        dbcontext.special_allowance_job_level_class.Add(new_details);
                        dbcontext.SaveChanges();
                        item.min_basic_salary = newsalary;
                        dbcontext.SaveChanges();
                    }
                }
                if (JobClass[0] == "1")
                {
                    var joblevelsetup = dbcontext.job_level_setup.ToList();
                    foreach (var item in joblevelsetup)
                    {
                        int    ID = item.ID;
                        var    min_basic_salary = item.min_basic_salary;
                        double year             = double.Parse(Year[0]);
                        double month            = double.Parse(Month[0]);
                        double Percentage       = double.Parse(percentage[0]);
                        var    Allowance        = (min_basic_salary * Percentage) / 100;
                        double newsalary        = (Allowance + min_basic_salary);
                        var    new_details      = new special {
                            job_level_setupID = ID, Year = year, Month = month, Percentage = Percentage, Allowance_amount = Allowance, pervious_basic = min_basic_salary, new_basic_sallary = newsalary
                        };
                        dbcontext.special.Add(new_details);
                        dbcontext.SaveChanges();
                        item.min_basic_salary = newsalary;
                        dbcontext.SaveChanges();
                    }
                }

                return(RedirectToAction("index"));
            }
            catch (Exception e)
            {
                return(View(model));
            }
        }
示例#2
0
        public ActionResult allowance(FormCollection form, int type, int ID)
        {
            try
            {
                TempData["TYPE"] = type;
                TempData["ID"]   = ID;
                ViewBag.id2      = ID;
                if (type == 1)
                {
                    var specialold = dbcontext.special_allowance_job_level_class.Where(m => m.Job_level_classID == ID);
                    dbcontext.special_allowance_job_level_class.RemoveRange(specialold);
                    dbcontext.SaveChanges();
                }
                else if (type == 2)
                {
                    var specialold = dbcontext.special_allowance_job_level_grade.Where(m => m.Job_level_gradeID == ID);
                    dbcontext.special_allowance_job_level_grade.RemoveRange(specialold);
                    dbcontext.SaveChanges();
                }
                else if (type == 3)
                {
                    var specialold = dbcontext.special.Where(m => m.job_level_setupID == ID);
                    dbcontext.special.RemoveRange(specialold);
                    dbcontext.SaveChanges();
                }
                var Year              = form["Year"].Split(char.Parse(","));
                var Month             = form["Month"].Split(char.Parse(","));
                var Percentage        = form["Percentage"].Split(char.Parse(","));
                var Allowance_amount  = form["Allowance_amount1"].Split(char.Parse(","));
                var pervious_basic    = form["pervious_basic"].Split(char.Parse(","));
                var new_basic_sallary = form["new_basic_sallary"].Split(char.Parse(","));
                for (var i = 0; i < Year.Count(); i++)
                {
                    if (type == 1)
                    {
                        var new_record = new special_allowance_job_level_class();
                        if (Year[i] != "" || Month[i] != "" || Percentage[i] != "" || pervious_basic[i] != "" || new_basic_sallary[i] != "")
                        {
                            new_record.Year              = float.Parse(Year[i]);
                            new_record.Month             = float.Parse(Month[i]);
                            new_record.Percentage        = float.Parse(Percentage[i]);
                            new_record.pervious_basic    = float.Parse(pervious_basic[i]);
                            new_record.new_basic_sallary = float.Parse(new_basic_sallary[i]);
                            new_record.Allowance_amount  = float.Parse(Allowance_amount[i]);
                            new_record.Job_level_classID = ID;
                            dbcontext.special_allowance_job_level_class.Add(new_record);
                            dbcontext.SaveChanges();
                        }
                    }
                    else if (type == 2)
                    {
                        var new_record = new special_allowance_job_level_grade();
                        if (Year[i] != "" || Month[i] != "" || Percentage[i] != "" || pervious_basic[i] != "" || new_basic_sallary[i] != "")
                        {
                            new_record.Year              = float.Parse(Year[i]);
                            new_record.Month             = float.Parse(Month[i]);
                            new_record.Percentage        = float.Parse(Percentage[i]);
                            new_record.pervious_basic    = float.Parse(pervious_basic[i]);
                            new_record.new_basic_sallary = float.Parse(new_basic_sallary[i]);
                            new_record.Allowance_amount  = float.Parse(Allowance_amount[i]);
                            new_record.Job_level_gradeID = ID;
                            dbcontext.special_allowance_job_level_grade.Add(new_record);
                            dbcontext.SaveChanges();
                        }
                    }
                    else if (type == 3)
                    {
                        var new_record = new special();
                        if (Year[i] != "" || Month[i] != "" || Percentage[i] != "" || pervious_basic[i] != "" || new_basic_sallary[i] != "")
                        {
                            new_record.Year              = float.Parse(Year[i]);
                            new_record.Month             = float.Parse(Month[i]);
                            new_record.Percentage        = float.Parse(Percentage[i]);
                            new_record.pervious_basic    = float.Parse(pervious_basic[i]);
                            new_record.new_basic_sallary = float.Parse(new_basic_sallary[i]);
                            new_record.Allowance_amount  = float.Parse(Allowance_amount[i]);
                            new_record.job_level_setupID = ID;
                            dbcontext.special.Add(new_record);
                            dbcontext.SaveChanges();
                        }
                    }
                }


                if (type == 2)
                {
                    return(RedirectToAction("index", "Job_level_grade"));
                }
                else if (type == 3)
                {
                    return(RedirectToAction("index", "job_level_setup"));
                }
                else
                {
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception e)
            {
                TempData["TYPE"] = type;
                TempData["ID"]   = ID;
                return(View());
            }
        }