Пример #1
0
        internal void Addperson(salary student)
        {
            string cs = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(cs))
            {
                using (SqlCommand cmd = new SqlCommand("adddata", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();
                    cmd.Parameters.AddWithValue("@name", student.name);
                    cmd.Parameters.AddWithValue("@employerid", student.employerid);
                    cmd.Parameters.AddWithValue("@title", student.title);
                    cmd.Parameters.AddWithValue("@depart", student.depart);
                    cmd.Parameters.AddWithValue("@accno", student.accno);
                    cmd.Parameters.AddWithValue("@basicsalary", student.basicsalary);
                    cmd.Parameters.AddWithValue("@mealallow", student.mealallow);
                    cmd.Parameters.AddWithValue("@transportallow", student.transportallow);
                    cmd.Parameters.AddWithValue("@medicalallow", student.medicalallow);
                    cmd.Parameters.AddWithValue("@tax", student.tax);
                    cmd.Parameters.AddWithValue("@total", student.total);

                    cmd.ExecuteNonQuery();
                }
            }
        }
        public IActionResult stdlog(salary salary)
        {
            var test = _context.salary;
            var m    = new List <salary>();
            var i    = _context.salary.Where(x => x.id == salary.id && x.name == salary.name).FirstOrDefault();

            if (i == null)
            {
                ViewBag.Login = "******";
            }
            else
            {
                ViewBag.Login = "******";

                var s = new salary();

                s.date     = i.date;
                s.monthly  = i.monthly;
                s.monthly  = i.monthly;
                s.rent     = i.rent;
                s.bonus    = i.bonus;
                s.hospital = i.hospital;
                s.recieved = i.recieved;

                m.Add(s);

                return(View("facultydetails", m));
            }
            return(View());
        }
        public async Task <IActionResult> salary(salary model)
        {
            if (ModelState.IsValid)
            {
                salary lcl_salary = new salary
                {
                    id      = model.id,
                    name    = model.name,
                    date    = model.date,
                    monthly = model.monthly,

                    rent     = model.rent,
                    bonus    = model.bonus,
                    hospital = model.hospital,
                    recieved = model.recieved,
                };
                _context.salary.Add(lcl_salary);
                await _context.SaveChangesAsync();

                ViewBag.Success = "Data has been successfully saved";
                return(View());
            }

            return(View(model));
        }
Пример #4
0
        static void Main(string[] args)
        {
            // methods
            Console.WriteLine(" welcome to the stuff payroll system");
            Console.WriteLine("press enter to display salary");
            Console.WriteLine("press enter again to display wages");
            Console.Write("please enter the button");
            int button = int.Parse(Console.ReadLine());


            {
                //salary class//
                salary s1 = new salary();
                Console.WriteLine($"your per week salary ${Math.Round(s1.DisplaySalary(), 2)}");
                //2 lines//
                Console.WriteLine("");
                Console.WriteLine("");
            }

            // wages class//
            wages w1 = new wages();

            Console.Write("please enter the working hours");
            int hours = int.Parse(Console.ReadLine());

            Console.WriteLine($"Wages per week ${Math.Round(w1.Displaywages(), 2)}");
            Console.ReadLine();
        }
        public ActionResult update(int id)
        {
            salaryViewModel studentVM = new salaryViewModel();
            salary          student   = studentVM.print(id);

            return(View(student));
        }
Пример #6
0
        internal salary print(int id)
        {
            salary student = new salary();
            string cs      = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(cs))
            {
                using (SqlCommand cmd = new SqlCommand("printdetail", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();

                    cmd.Parameters.AddWithValue("@id", id);
                    SqlDataReader reader = cmd.ExecuteReader();

                    reader.Read();
                    student.id             = Convert.ToInt32(reader["id"]);
                    student.name           = reader["Name"].ToString();
                    student.employerid     = reader["employerid"].ToString();
                    student.title          = reader["title"].ToString();
                    student.depart         = reader["depart"].ToString();
                    student.accno          = reader["accno"].ToString();
                    student.basicsalary    = Convert.ToInt32(reader["basicsalary"]);
                    student.mealallow      = Convert.ToInt32(reader["mealallow"]);
                    student.transportallow = Convert.ToInt32(reader["transportallow"]);
                    student.medicalallow   = Convert.ToInt32(reader["medicalallow"]);
                    student.tax            = Convert.ToInt32(reader["tax"]);
                    student.total          = Convert.ToInt32(reader["medicalallow"]) + Convert.ToInt32(reader["transportallow"]) + Convert.ToInt32(reader["mealallow"]) + Convert.ToInt32(reader["basicsalary"]) - Convert.ToInt32(reader["tax"]);
                }
            }
            return(student);
        }
Пример #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            salary salary = db.salaries.Find(id);

            db.salaries.Remove(salary);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 private void materialButton1_Click(object sender, EventArgs e)
 {
     using (HamroSuperMarketEntities db = new HamroSuperMarketEntities())
     {
         salary sal = db.salaries.Where(o => o.id == id).First();
         db.Entry(sal).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
 public ActionResult Create(salary student)
 {
     if (ModelState.IsValid)
     {
         salaryViewModel studentVM = new salaryViewModel();
         studentVM.Addperson(student);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
 public async Task Handle(EmployeePermanentCreatedIntegrationEvent @event)
 {
     using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
     {
         // _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
         var empsalary = new salary(@event.EmpId, 1000.00);
         _repository.Add(empsalary);
         await _repository.UnitOfWork
         .SaveEntitiesAsync();
     }
 }
Пример #11
0
 static void Main(string[] args)
 {
     salary s1 = new salary();
     s1.AnnualSalary = 80000;
     Console.WriteLine($"Your salary is se tat {s1.AnnualSalary}");
     Console.WriteLine($"your salary per weekis {s1.DispalySalary()}");
     Console.WriteLine("");
     Console.WriteLine("i will calculate your wages");
     Console.WriteLine("enter a number of hour work:");
     int hour = int.Parse(Console.ReadLine());
 }
Пример #12
0
        private void SaveSalaryData(object sender, RoutedEventArgs e)
        {
            try
            {
                salary uSalary = dbContext.salary.SingleOrDefault(k => k.employeeID == selectedPersonID);

                if (uSalary != null)
                {
                    uSalary.baseSalary = Convert.ToDecimal(string.IsNullOrEmpty(baseSalary.Text) ? "0" : baseSalary.Text);

                    uSalary.dosentBase           = Convert.ToDecimal(string.IsNullOrEmpty(dosentBase.Text) ? "0" : dosentBase.Text);
                    uSalary.professorBase        = Convert.ToDecimal(string.IsNullOrEmpty(professorBase.Text) ? "0" : professorBase.Text);
                    uSalary.academicBase         = Convert.ToDecimal(string.IsNullOrEmpty(academicBase.Text) ? "0" : academicBase.Text);
                    uSalary.scientceDoctorBase   = Convert.ToDecimal(string.IsNullOrEmpty(scientceDoctorBase.Text) ? "0" : scientceDoctorBase.Text);
                    uSalary.scienceCandadateBase = Convert.ToDecimal(string.IsNullOrEmpty(scienceCandidateBase.Text) ? "0" : scienceCandidateBase.Text);

                    uSalary.dosentPercent           = Convert.ToDecimal(string.IsNullOrEmpty(dosentPercent.Text) ? "0" : dosentPercent.Text);
                    uSalary.professorPercent        = Convert.ToDecimal(string.IsNullOrEmpty(professorPercent.Text) ? "0" : professorPercent.Text);
                    uSalary.academicPercent         = Convert.ToDecimal(string.IsNullOrEmpty(academicPercent.Text) ? "0" : academicPercent.Text);
                    uSalary.scientceDoctorPercent   = Convert.ToDecimal(string.IsNullOrEmpty(scientceDoctorPercent.Text) ? "0" : scientceDoctorPercent.Text);
                    uSalary.scienceCandadatePercent = Convert.ToDecimal(string.IsNullOrEmpty(scienceCandadatePercent.Text) ? "0" : scienceCandadatePercent.Text);



                    //uSalary.employeeID = selectedPersonID;
                }

                else
                {
                    salary eSalary = new salary();

                    eSalary.baseSalary           = Convert.ToDecimal(string.IsNullOrEmpty(baseSalary.Text) ? "0" : baseSalary.Text);
                    eSalary.dosentBase           = Convert.ToDecimal(string.IsNullOrEmpty(dosentBase.Text) ? "0" : dosentBase.Text);
                    eSalary.professorBase        = Convert.ToDecimal(string.IsNullOrEmpty(professorBase.Text) ? "0" : professorBase.Text);
                    eSalary.academicBase         = Convert.ToDecimal(string.IsNullOrEmpty(academicBase.Text) ? "0" : academicBase.Text);
                    eSalary.scientceDoctorBase   = Convert.ToDecimal(string.IsNullOrEmpty(scientceDoctorBase.Text) ? "0" : scientceDoctorBase.Text);
                    eSalary.scienceCandadateBase = Convert.ToDecimal(string.IsNullOrEmpty(scienceCandidateBase.Text) ? "0" : scienceCandidateBase.Text);
                    eSalary.employeeID           = selectedPersonID;
                    dbContext.salary.Add(eSalary);
                }

                dbContext.SaveChanges();

                //  txtStatus.Text = rOrganization.organizationName + " has being added!";
            }
            catch (DbUpdateException ex)
            {
                MessageBox.Show("Problem yarandı" + ex.ToString());
            }
            finally
            {
                MessageBox.Show("Melumatlar saxlanıldı");
            }
        }
Пример #13
0
 public ActionResult Edit([Bind(Include = "Salary_Id,Employee_Id,Salary_Amount,Advance_Cut,Total_Pay,Salary_Date")] salary salary)
 {
     if (ModelState.IsValid)
     {
         db.Entry(salary).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Employee_Id = new SelectList(db.employees, "Employee_Id", "Employee_Name", salary.Employee_Id);
     return(View(salary));
 }
Пример #14
0
        private bool updateSalaryDetailFilePath(string salaryId, string salaryDetailFilePath, sys_employeeEntities db)
        {
            var query = (from s in db.salary
                         where s.salaryId == salaryId
                         select s).First();
            salary salary = (salary)query;

            salary.salaryDetailFilePath = salaryDetailFilePath;

            db.SaveChanges();
            return(false);
        }
Пример #15
0
        public ActionResult addBonus(int user_id, int count, int ded, int bonus, int salary, DateTime da)
        {
            salary s = new salary();

            s.eid       = user_id;
            s.bonus     = bonus;
            s.deduction = ded;
            s.days      = count;
            s.month     = da.Date;
            db.salaries.Add(s);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #16
0
        // GET: salaries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            salary salary = db.salaries.Find(id);

            if (salary == null)
            {
                return(HttpNotFound());
            }
            return(View(salary));
        }
Пример #17
0
        // GET: salaries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            salary salary = db.salaries.Find(id);

            if (salary == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Employee_Id = new SelectList(db.employees, "Employee_Id", "Employee_Name", salary.Employee_Id);
            return(View(salary));
        }
        public void AddSalary(int employee_no, int employee_salary, string from_date, string to_date)
        {
            salary sal = new salary();

            sal.emp_no    = employee_no;
            sal.salary1   = employee_salary;
            sal.from_date = from_date;
            sal.to_date   = to_date;

            var db = new newdataEntities();

            db.salaries.Add(sal);
            db.SaveChanges();
            db.Dispose();
        }
Пример #19
0
        private bool addSalaryDetailFilePath(string employeeId, string salaryMonth, string salaryDetailFilePath, sys_employeeEntities db)
        {
            string salaryId = string.Format("{0}{1}", employeeId, salaryMonth.Substring(0, 7).Replace("/", ""));
            salary salary   = new salary();

            salary.salaryId             = salaryId;
            salary.employeeId           = employeeId;
            salary.paymentDate          = string.Format("{0}/{1}", salaryMonth.Substring(0, 7), "15");
            salary.salaryDetailFilePath = salaryDetailFilePath;//fileName.Substring(fileName.IndexOf(ConstantCommon.SALARYFOLDERPATH));
            salary.description          = "";
            db.salary.Add(salary);
            db.SaveChanges();

            return(false);
        }
Пример #20
0
        public async Task <IHttpActionResult> Deleteemployee(int id)
        {
            employee employee = await db.employees.FindAsync(id);

            if (employee == null)
            {
                return(NotFound());
            }

            salary salary_move = await(db.salaries.Where(u => u.employee_id == employee.employee_id).FirstOrDefaultAsync <salary>());;
            await db.Database.ExecuteSqlCommandAsync("Delete from salaries where employee_id=" + employee.employee_id);

            db.employees.Remove(employee);

            await db.SaveChangesAsync();

            return(Ok(employee));
        }
        private void label2_Click(object sender, EventArgs e)
        {
            if (nepaliCalender1From.engdate > nepaliCalender2To.engdate)
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("beging date can not be bigger then finising date", 2000);
                return;
            }
            if (Amountofsalary.Text.Trim() == "")
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("please enter the amout", 2000);
                return;
            }
            if (!(Convert.ToDecimal(Amountofsalary.Text) > 0))
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("enter the salary'amount in positive value", 2000);
                return;
            }
            try
            {
                salary sal = new salary();
                sal.employee_id = this.id;
                sal.form        = nepaliCalender1From.engdate;
                sal.toto        = nepaliCalender2To.engdate;
                sal.amount      = Convert.ToDecimal(Amountofsalary.Text);
                sal.dates       = Dashboard.Instance.nepaliCalender1.engdate;
                sal.day         = nepaliCalender1From.DATESTAMP;
                sal.today       = nepaliCalender2To.DATESTAMP;
                db.salaries.Add(sal);
                db.SaveChanges();
                var notification = new RetailControls.NotificationMAnager();
                notification.show("Salary Added for " + this.name, 2000);
                this.Dispose();
            }

            catch (Exception ex)
            {
                var notification = new RetailControls.NotificationMAnager();
                notification.show("please enter the correct value" + this.name, 2000);
            }
        }
Пример #22
0
 public ActionResult Index(salary s)
 {
     if (s.basic > 30000)
     {
         s.deduction = s.basic * (5.0 / 100);
     }
     else if (s.basic > 15000)
     {
         s.deduction = s.basic * (2.0 / 100);
     }
     else
     {
         s.deduction = 0;
     }
     s.otpay  = s.othours * s.otrate;
     s.netsal = s.basic + s.bonus + s.otpay - s.deduction;
     //s.netsal = s.basic + s.bonus +( s.othours* s.otrate) - s.deduction;
     return(View(s));
 }
Пример #23
0
        public IActionResult Index(salary pay)
        {
            if (pay.sal > 50000)
            {
                pay.tax = pay.sal * 10 / 100;
            }
            else if (pay.sal > 30000)
            {
                pay.tax = pay.sal * 5 / 100;
            }
            else
            {
                pay.tax = 0;
            }

            pay.net = pay.sal - pay.tax;

            return(View(pay));
        }
Пример #24
0
        public List <salary> personDetails()
        {
            List <salary> students   = new List <salary>();
            string        connString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(connString))
            {
                using (SqlCommand cmd = new SqlCommand("persondata", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    conn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        salary student = new salary();
                        student.id             = Convert.ToInt16(reader["id"]);
                        student.name           = reader["name"].ToString();
                        student.employerid     = reader["employerid"].ToString();
                        student.title          = reader["title"].ToString();
                        student.depart         = reader["depart"].ToString();
                        student.accno          = reader["accno"].ToString();
                        student.basicsalary    = Convert.ToInt32(reader["basicsalary"]);
                        student.mealallow      = Convert.ToInt32(reader["mealallow"]);
                        student.transportallow = Convert.ToInt32(reader["transportallow"]);
                        student.medicalallow   = Convert.ToInt32(reader["medicalallow"]);
                        student.tax            = Convert.ToInt32(reader["tax"]);
                        student.total          = Convert.ToInt32(reader["medicalallow"]) + Convert.ToInt32(reader["transportallow"]) + Convert.ToInt32(reader["mealallow"]) + Convert.ToInt32(reader["basicsalary"]) + -Convert.ToInt32(reader["tax"]);



                        students.Add(student);
                    }
                }
            }
            return(students);
        }
Пример #25
0
        public ActionResult All(string ym = "")
        {
            //ReportSalary
            ViewBag.Title = "全部薪資查詢(主管權限)";
            if (string.IsNullOrEmpty(ym))
            {
                ModelState.AddModelError("", "請輸入年度與月份");
                View("Index");
            }
            var ctx  = new ApplicationDbContext();
            var user = ctx.Users.Where(x => x.UserName == User.Identity.Name).FirstOrDefault();

            if (user != null)
            {
                if (ctx.permList.Where(x => x.workNo == user.workNo && x.mod == "ReportSalary").Count() == 0)
                {
                    return(RedirectToAction("AccessDenied", "Account"));
                }
            }


            int      y    = Convert.ToInt32(ym.Split('-')[0]);
            int      m    = Convert.ToInt32(ym.Split('-')[1]);
            DateTime dtym = new DateTime(y, m, 1);

            ViewBag.ym = dtym.ToString("yyyy-MM");

            List <salary> sObjList = ctx.salaryList.Where(x => x.year == y && x.month == m).OrderBy(x => x.workNo).ToList <salary>();
            List <KeyValuePair <string, int> > fdList = new List <KeyValuePair <string, int> >();

            DataTable dt = new DataTable();

            if (sObjList.Count > 0)
            {
                salary  sObj = sObjList[0];
                JObject jobj = null;
                try
                {
                    jobj = JObject.Parse(sObj.jData);
                }
                catch (Exception ex)
                {
                    jobj = null;
                }
                if (jobj == null)
                {
                    View("Index");
                }

                for (int i = 0; i < jobj.Properties().ToList <JProperty>().Count(); i++)
                {
                    string pnm = jobj.Properties().ToList <JProperty>()[i].Name;
                    if (pnm == "雇主負擔" || pnm == "本人負擔")
                    {
                        pnm = "勞保-" + pnm;
                    }
                    if (pnm.Split('-').Count() > 1)
                    {
                        pnm = pnm.Split('-')[0];
                    }
                    KeyValuePair <string, int> fd;
                    if (fdList.Where(x => x.Key == pnm).Count() > 0)
                    {
                        int idx = 0;
                        for (int itmp = 0; itmp < fdList.Count(); itmp++)
                        {
                            if (fdList[itmp].Key == pnm)
                            {
                                fd           = fdList.Where(x => x.Key == pnm).First();
                                fd           = new KeyValuePair <string, int>(pnm, fd.Value + 1);
                                fdList[itmp] = fd;
                                break;
                            }
                        }
                    }
                    else
                    {
                        fd = new KeyValuePair <string, int>(pnm, 1);
                        fdList.Add(fd);
                    }
                    dt.Columns.Add(jobj.Properties().ToList <JProperty>()[i].Name);
                }
            }

            foreach (salary sObj in sObjList)
            {
                JObject jobj = null;
                try
                {
                    jobj = JObject.Parse(sObj.jData);
                }
                catch (Exception ex)
                {
                    jobj = null;
                }

                if (jobj != null)
                {
                    DataRow r = dt.NewRow();
                    for (int i = 0; i < jobj.Properties().ToList <JProperty>().Count(); i++)
                    {
                        string pnm = jobj.Properties().ToList <JProperty>()[i].Name;
                        if (pnm == "勞保-雇主負擔" || pnm == "勞保-本人負擔")
                        {
                            r[pnm] = jobj[pnm.Replace("勞保-", "")];
                        }
                        else
                        {
                            r[pnm] = jobj[pnm];
                        }
                    }
                    dt.Rows.Add(r);
                    dt.AcceptChanges();
                }
            }
            ViewBag.data   = dt;
            ViewBag.fdList = fdList;
            return(View("Index"));
        }
Пример #26
0
        public ActionResult Index(string ym = "")
        {
            ViewBag.Title = "個人薪資查詢";
            if (string.IsNullOrEmpty(ym))
            {
                ModelState.AddModelError("", "請輸入年度與月份");
                return(View());
            }
            var ctx  = new ApplicationDbContext();
            var user = ctx.Users.Where(x => x.UserName == User.Identity.Name).FirstOrDefault();

            if (user != null)
            {
                string   workNo = user.workNo;
                int      y      = Convert.ToInt32(ym.Split('-')[0]);
                int      m      = Convert.ToInt32(ym.Split('-')[1]);
                DateTime dtym   = new DateTime(y, m, 1);
                ViewBag.ym = dtym.ToString("yyyy-MM");
                salary sObj = ctx.salaryList.Where(x => x.year == y && x.month == m && x.workNo == user.workNo).FirstOrDefault();
                if (sObj != null)
                {
                    JObject jobj = null;
                    try
                    {
                        jobj = JObject.Parse(sObj.jData);
                        List <string> removeList = new List <string>();
                        foreach (JProperty prop in jobj.Properties())
                        {
                            if (getHiddenFields().Where(x => prop.Name.Contains(x)).Count() > 0)
                            {
                                if (getShowFields().Where(x => prop.Name.Equals(x)).Count() == 0)
                                {
                                    removeList.Add(prop.Name);
                                }
                            }
                        }
                        foreach (string propName in removeList)
                        {
                            jobj.Remove(propName);
                        }
                    }
                    catch (Exception ex)
                    {
                        jobj = null;
                    }
                    if (jobj == null)
                    {
                        return(View());
                    }
                    DataTable dt = new DataTable();

                    List <KeyValuePair <string, int> > fdList = new List <KeyValuePair <string, int> >();

                    for (int i = 0; i < jobj.Properties().ToList <JProperty>().Count(); i++)
                    {
                        string pnm  = jobj.Properties().ToList <JProperty>()[i].Name;
                        string pnm2 = "";
                        if (pnm.Split('-').Count() > 1)
                        {
                            pnm = pnm.Split('-')[0];
                        }
                        KeyValuePair <string, int> fd;
                        if (fdList.Where(x => x.Key == pnm).Count() > 0)
                        {
                            int idx = 0;
                            for (int itmp = 0; itmp < fdList.Count(); itmp++)
                            {
                                if (fdList[itmp].Key == pnm)
                                {
                                    fd           = fdList.Where(x => x.Key == pnm).First();
                                    fd           = new KeyValuePair <string, int>(pnm, fd.Value + 1);
                                    fdList[itmp] = fd;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            fd = new KeyValuePair <string, int>(pnm, 1);
                            fdList.Add(fd);
                        }
                        dt.Columns.Add(jobj.Properties().ToList <JProperty>()[i].Name);
                    }

                    DataRow r = dt.NewRow();
                    for (int i = 0; i < jobj.Properties().ToList <JProperty>().Count(); i++)
                    {
                        string pnm = jobj.Properties().ToList <JProperty>()[i].Name;
                        r[pnm] = jobj[pnm];
                    }
                    dt.Rows.Add(r);
                    dt.AcceptChanges();
                    ViewBag.data   = dt;
                    ViewBag.fdList = fdList;
                    return(View());
                }
            }

            return(View());
        }
 public double CalcTax(salary salary)
 {
Пример #28
0
        // GET: Salary
        public ActionResult Index()
        {
            salary sal = new salary();

            return(View(sal));
        }
Пример #29
0
        static void Main(string[] args)
        {
            double [] salary = new salary[9];

            Console.WriteLine("Enter the person's salary");
            double inputSalary = Convert.ToDouble(Console.ReadLine());

            if (inputSalary != -1)
            {
                double computedSal = (inputSalary * (0.09)) + 200;
                if (computedSal < 300)
                {
                    salary[0] = salary[0] + 1;
                }
                else if (computedSal < 400)
                {
                    salary[1] = salary[1] + 1;
                }
                else if (computedSal < 500)
                {
                    salary[2] = salary[2] + 1;
                }
                else if (computedSal < 600)
                {
                    salary[3] = salary[3] + 1;
                }
                else if (computedSal < 700)
                {
                    salary[4] = salary[4] + 1;
                }
                else if (computedSal < 800)
                {
                    salary[5] = salary[5] + 1;
                }
                else if (computedSal < 900)
                {
                    salary[6] = salary[6] + 1;
                }
                else if (computedSal < 1000)
                {
                    salary[7] = salary[7] + 1;
                }
                else
                {
                    salary[8] = salary[8] + 1;
                }
            }

            for (int i = 0; i < salary.Length; i++)
            {
                // int num = 0;
                switch (i)
                {
                case 0:
                    Console.WriteLine($"$200-299: {salary[i]}");
                    break;

                case 1:
                    Console.WriteLine($"$300-399: {salary[i]}");
                    break;

                case 2:
                    Console.WriteLine($"$400-499: {salary[i]}");
                    break;

                case 3:
                    Console.WriteLine($"$500-599: {salary[i]}");
                    break;

                case 4:
                    Console.WriteLine($"$600-699: {salary[i]}");
                    break;

                case 5:
                    Console.WriteLine($"$700-799: {salary[i]}");
                    break;

                case 6:
                    Console.WriteLine($"$800-899: {salary[i]}");
                    break;

                case 7:
                    Console.WriteLine($"$900-999: {salary[i]}");
                    break;

                case 8:
                    Console.WriteLine($"$1000 and above: {salary[i]}");
                    break;

                default:
                    Console.WriteLine("invalid");
                }
            }
            Console.WriteLine();
        }
Пример #30
0
        public ActionResult Upload(HttpPostedFileBase file)
        {
            if (file == null)
            {
                ModelState.AddModelError("", "上傳檔案失敗,請重新執行");
                return(View());
            }

            if (file.ContentLength > 0)
            {
                string filename = Path.GetFileName(file.FileName);
                string ext      = Path.GetExtension(file.FileName).Replace(".", "").ToUpper();
                if (ext != "XLSX")
                {
                    ModelState.AddModelError("", "請選擇XLSX格式Excel檔案!");
                    return(View());
                }

                var ctx = new ApplicationDbContext();

                //string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "upload", ctx.getLocalTiime().ToString("yyyyMMdd") + ".xlsx");
                string        path = @"C:\inetpub\upload\" + ctx.getLocalTiime().ToString("yyyyMM");
                DirectoryInfo di   = new DirectoryInfo(path);
                if (di.Exists == false)
                {
                    di.Create();
                }
                string uploadfile = path + @"\" + ctx.getLocalTiime().ToString("yyyyMMdd") + ".xlsx";
                if (System.IO.File.Exists(uploadfile))
                {
                    //System.IO.File.Delete(uploadfile);
                }
                file.SaveAs(uploadfile);
                ExcelPackage   pkg = new ExcelPackage(new FileInfo(uploadfile));
                ExcelWorkbook  bk  = pkg.Workbook;
                ExcelWorksheet sht = bk.Worksheets[1];

                List <string> fieldList = new List <string>();

                for (int j = 1; j <= 73; j++)
                {
                    fieldList.Add(sht.Cells[1, j].Text.Replace("\n", "").Replace(" ", ""));
                }

                for (int i = 2; i <= 65535; i++)
                {
                    if (sht.Cells[i, 1].Text.Trim() == "")
                    {
                        break;
                    }

                    int    year = 0; int month = 0;
                    string workNo = "";

                    string[] ym = sht.Cells[i, 3].Text.Split('/');
                    if (ym.Length == 2)
                    {
                        year  = Convert.ToInt32(ym[0]);
                        month = Convert.ToInt32(ym[1]);
                    }
                    workNo = sht.Cells[i, 1].Text;

                    salary sObj = null;
                    sObj = ctx.salaryList.Where(x => x.year == year && x.month == month && x.workNo == workNo).FirstOrDefault();
                    if (sObj == null)
                    {
                        sObj = new salary
                        {
                            id     = Guid.NewGuid().ToString(),
                            year   = year,
                            month  = month,
                            workNo = workNo,
                            jData  = "{}"
                        };
                        ctx.salaryList.Add(sObj);
                    }

                    JObject jobj = new JObject();
                    //jobj.Properties().ToList<JProperty>()[1].Name
                    for (int j = 0; j < fieldList.Count; j++)
                    {
                        if (!string.IsNullOrEmpty(fieldList[j]))
                        {
                            jobj[fieldList[j]] = sht.Cells[i, j + 1].Text;
                        }
                    }
                    sObj.jData = jobj.ToString();
                    ctx.SaveChanges();
                }
                //System.IO.File.Delete(uploadfile);
                TempData["msg"] = "上傳完成";
                return(View());
            }
            else
            {
                ModelState.AddModelError("", "上傳檔案失敗,請重新執行");
                return(View());
            }
        }