コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Bonuses bonus = new Bonuses();

            bonus.EmpID = Convert.ToInt32(ddlEmp.SelectedValue.ToString());
            bonus.Type  = Convert.ToInt32(ddlType.SelectedValue.ToString());

            bonus.Nature = 0;//Nature=0 it's a Deductions
            HttpCookie myCookie = Request.Cookies["user"];

            bonus.OperatorID = Convert.ToInt32(myCookie.Values["userid"].ToString());
            bonus.Month      = Convert.ToInt32(ddlMonth.SelectedValue.ToString());
            bonus.Year       = Convert.ToInt32(ddlYear.SelectedValue.ToString());
            bonus.Manger     = Convert.ToInt32(ddlManger.SelectedValue.ToString());
            if (ddlType.SelectedValue == "1")
            {
                bonus.Value          = Convert.ToDecimal(txtAmount.Text);
                bonus.PrecentageFrom = Convert.ToInt32(ddlprecentageFrom.SelectedValue.ToString());
                bonus.NumberOfDays   = 0;
            }
            else if (ddlType.SelectedValue == "3")
            {
                bonus.Value          = 0;
                bonus.PrecentageFrom = 0;
                bonus.NumberOfDays   = Convert.ToInt32(txtNumberOfDays.Text);
            }
            else
            {
                bonus.Value          = Convert.ToDecimal(txtAmount.Text);
                bonus.PrecentageFrom = 0;
                bonus.NumberOfDays   = 0;
            }
            bonus.Reason = txtResone.Text;
            int id = bonus.save();

            if (id > 0)
            {
                Response.Redirect("~/HR/Deductions.aspx?alert=success");
            }
            else
            {
                Response.Redirect("~/HR/CreateDeduction.aspx?id=0&&alret=notpass");
            }
        }