public JsonResult Create(string para01, string para02, string para03)
        {
            string employee_id = para01;
            string expense_id  = para02;
            string date        = para03;

            SALARY newSalary = new SALARY();

            newSalary.EXPENSE_ID  = expense_id;
            newSalary.EMPLOYEE_ID = employee_id;
            newSalary.SALARY_DATE = Convert.ToDateTime(date);

            EMPLOYEE myEmployee = db.EMPLOYEE.Find(employee_id);
            EXPENSE  myExpense  = db.EXPENSE.Find(expense_id);

            myExpense.MONEY           = myExpense.MONEY + myEmployee.SALARY;
            db.Entry(myExpense).State = EntityState.Modified;

            db.SALARY.Add(newSalary);
            db.SaveChanges();

            var list = db.SALARY.Include(s => s.EMPLOYEE).Include(s => s.EXPENSE).Select(n => new { EMPLOYEE_ID = n.EMPLOYEE_ID, EMPLOYEE_NAME = n.EMPLOYEE.EMPLOYEE_NAME, SALARY_DATE = n.SALARY_DATE, SALARY = n.EMPLOYEE.SALARY, EXPENSE_ID = n.EXPENSE_ID });

            return(Json(new { code = 0, msg = "", count = 1000, data = list }, JsonRequestBehavior.AllowGet));
        }
        public string test(string para01, string para02, string para03)
        {
            string employee_id = para01;
            string expense_id  = para02;

            SALARY mySalary = db.SALARY.Find(expense_id, employee_id);

            if (mySalary != null)
            {
                return("1");
            }
            EXPENSE myExpense = db.EXPENSE.Find(expense_id);

            if (myExpense == null)
            {
                return("2");
            }
            EMPLOYEE myEmployee = db.EMPLOYEE.Find(employee_id);

            if (myEmployee == null)
            {
                return("3");
            }
            return("4");
        }
Esempio n. 3
0
 public static void UpdateSalary(SALARY salary, bool control)
 {
     SalaryDAO.UpdateSalary(salary);
     if (control)
     {
         EmployeeDAO.UpdateEmployee(salary.EmployeeID, salary.Amount);
     }
 }
Esempio n. 4
0
        public ActionResult DeleteConfirmed(string id)
        {
            SALARY sALARY = db.SALARY.Find(id);

            db.SALARY.Remove(sALARY);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
 public static void AddSalary(SALARY salary)
 {
     try
     {
         db.SALARies.InsertOnSubmit(salary);
         db.SubmitChanges();
     }catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "EXPENSE_ID,EMPLOYEE_ID,SALARY_DATE")] SALARY sALARY)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sALARY).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EMPLOYEE_ID = new SelectList(db.EMPLOYEE, "EMPLOYEE_ID", "EMPLOYEE_NAME", sALARY.EMPLOYEE_ID);
     ViewBag.EXPENSE_ID  = new SelectList(db.EXPENSE, "EXPENSE_ID", "TYPE", sALARY.EXPENSE_ID);
     return(View(sALARY));
 }
 public static void DeleteSalary(int salaryID)
 {
     try
     {
         SALARY sl = db.SALARY.First(x => x.ID == salaryID);
         db.SALARY.DeleteOnSubmit(sl);
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 8
0
 public static void DeleteSalary(int salaryID)
 {
     try
     {
         SALARY salary = db.SALARies.First(x => x.ID == salaryID);
         db.SALARies.DeleteOnSubmit(salary);
         db.SubmitChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 9
0
        // GET: SALARies/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SALARY sALARY = db.SALARY.Find(id);

            if (sALARY == null)
            {
                return(HttpNotFound());
            }
            return(View(sALARY));
        }
        static void Main(string[] args)
        {
            int    NUMBER, HOURS;
            double VALOR_HORA, SALARY;

            NUMBER     = int.Parse(Console.ReadLine());
            HOURS      = int.Parse(Console.ReadLine());
            VALOR_HORA = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

            SALARY = HOURS * VALOR_HORA;

            Console.WriteLine("NUMBER = " + NUMBER);
            Console.WriteLine("SALARY = U$ " + SALARY.ToString("F2"), CultureInfo.InvariantCulture);
        }
Esempio n. 11
0
 public static void UpdateSalary(SALARY salary, bool control)
 {
     try
     {
         SALARY sl = db.SALARies.First(x => x.ID == salary.ID);
         sl.Amount  = salary.Amount;
         sl.Year    = salary.Year;
         sl.MonthID = salary.MonthID;
         db.SubmitChanges();
     }catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 12
0
        static void uri1008()
        {
            int    NUMBER, quantidadeHoraTrabalho;
            double ganhoHora, SALARY;

            NUMBER = int.Parse(Console.ReadLine());
            quantidadeHoraTrabalho = int.Parse(Console.ReadLine());
            ganhoHora = double.Parse(Console.ReadLine());

            SALARY = quantidadeHoraTrabalho * ganhoHora;

            Console.WriteLine("NUMBER = " + NUMBER);
            Console.WriteLine("SALARY = U$ " + SALARY.ToString("f2"));
            Console.ReadLine();
        }
Esempio n. 13
0
        // GET: SALARies/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SALARY sALARY = db.SALARY.Find(id);

            if (sALARY == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EMPLOYEE_ID = new SelectList(db.EMPLOYEE, "EMPLOYEE_ID", "EMPLOYEE_NAME", sALARY.EMPLOYEE_ID);
            ViewBag.EXPENSE_ID  = new SelectList(db.EXPENSE, "EXPENSE_ID", "TYPE", sALARY.EXPENSE_ID);
            return(View(sALARY));
        }
Esempio n. 14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtYear.Text.Trim() == "")
            {
                MessageBox.Show("year is empty");
            }
            else if (txtSalary.Text.Trim() == "")
            {
                MessageBox.Show("Salary is empty");
            }
            else if (cmbMonth.SelectedIndex == -1)
            {
                MessageBox.Show("Select a month");
            }
            else
            {
                bool control = false;
                if (!isUpdate)
                {
                    if (salary.EmployeeID == 0)
                    {
                        MessageBox.Show("please select an employee from table");
                    }
                    else
                    {
                        salary.Year    = Convert.ToInt32(txtYear.Text);
                        salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue);
                        salary.Amount  = Convert.ToInt32(txtSalary.Text);
                        if (salary.Amount > oldsalary)
                        {
                            control = true;
                        }
                        SalaryBLL.AddSalary(salary, control);
                        MessageBox.Show("Salary was added");
                        cmbMonth.SelectedIndex = -1;
                        salary = new SALARY();
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        SALARY salary = new SALARY();
                        salary.ID         = detail.SalaryID;
                        salary.EmployeeID = detail.EmployeeID;
                        salary.Year       = Convert.ToInt32(txtYear.Text);
                        salary.MonthID    = Convert.ToInt32(cmbMonth.SelectedValue);
                        salary.Amount     = Convert.ToInt32(txtSalary.Text);

                        if (salary.Amount > detail.oldSalary)
                        {
                            control = true;
                        }
                        SalaryBLL.UpdateSalary(salary, control);
                        MessageBox.Show("Salary was Uptaded");
                        this.Close();
                    }
                }
            }
        }
Esempio n. 15
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtYear.Text.Trim() == "")
     {
         MessageBox.Show("Please fill the year");
     }
     else if (cmbMonth.SelectedIndex == -1)
     {
         MessageBox.Show("Please select month");
     }
     else if (txtSalary.Text.Trim() == "")
     {
         MessageBox.Show("Please fill the salary");
     }
     else if (txtUserNo.Text.Trim() == "")
     {
         MessageBox.Show("Please select the employee");
     }
     else
     {
         bool control = false;
         if (!isUpdated)
         {
             if (salary.EmployeeID == 0)
             {
                 MessageBox.Show("Please select the employee from the table");
             }
             else
             {
                 salary.Year    = Convert.ToInt32(txtYear.Text);
                 salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue);
                 salary.Amount  = Convert.ToInt32(txtSalary.Text);
                 if (salary.Amount > oldSalary)
                 {
                     control = true;
                 }
                 SalaryBLL.AddSalary(salary, control);
                 MessageBox.Show("Salary added!");
                 cmbMonth.SelectedIndex = -1;
                 salary = new SALARY();
             }
         }
         else
         {
             DialogResult dialogResult = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 SALARY salary = new SALARY();
                 salary.ID         = detail.SalaryID;
                 salary.EmployeeID = detail.EmployeeID;
                 salary.Year       = Convert.ToInt32(txtYear.Text);
                 salary.MonthID    = Convert.ToInt32(cmbMonth.SelectedValue);
                 salary.Amount     = Convert.ToInt32(txtSalary.Text);
                 if (salary.Amount > detail.OldSalary)
                 {
                     control = true;
                 }
                 SalaryBLL.UpdateSalary(salary, control);
                 MessageBox.Show("Salary updated!");
                 this.Close();
             }
         }
     }
 }