Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            LeaveType leaveType = new LeaveType();

            leaveType.LeaveTypeName = txtLeaveType.Text;

            leaveType.Balance = Convert.ToInt32(txtBalance.Text);
            HttpCookie myCookie = Request.Cookies["user"];

            leaveType.OperatorID = Convert.ToInt32(myCookie.Values["userid"].ToString());
            if (cbDeduction.Checked)
            {
                leaveType.Deduction      = 1;
                leaveType.DeductionValue = Convert.ToInt32(txtDays.Text);
            }
            else
            {
                leaveType.Deduction      = 0;
                leaveType.DeductionValue = 0;
            }
            int id = leaveType.save();

            if (id > 0)
            {
                Response.Redirect("~/HR/LeaveTypes.aspx?alert=success");
            }
            else
            {
                Response.Redirect("~/HR/AddLeaveType.aspx?id=0&&alret=notpass");
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                loLeaveType.Id          = lId;
                loLeaveType.Code        = GlobalFunctions.replaceChar(txtCode.Text);
                loLeaveType.Description = GlobalFunctions.replaceChar(txtDescription.Text);
                loLeaveType.Category    = GlobalFunctions.replaceChar(txtCategory.Text);
                loLeaveType.Remarks     = GlobalFunctions.replaceChar(txtRemarks.Text);
                loLeaveType.UserId      = GlobalVariables.UserId;

                string _Id = loLeaveType.save(lOperation);
                if (_Id != "")
                {
                    MessageBoxUI _mb = new MessageBoxUI("Leave Type has been saved successfully!", GlobalVariables.Icons.Save, GlobalVariables.Buttons.OK);
                    _mb.showDialog();
                    lRecords[0] = _Id;
                    lRecords[1] = txtCode.Text;
                    lRecords[2] = txtDescription.Text;
                    lRecords[3] = txtCategory.Text;
                    lRecords[4] = txtRemarks.Text;
                    object[] _params = { lRecords };
                    if (lOperation == GlobalVariables.Operation.Edit)
                    {
                        ParentList.GetType().GetMethod("updateData").Invoke(ParentList, _params);
                        this.Close();
                    }
                    else
                    {
                        ParentList.GetType().GetMethod("addData").Invoke(ParentList, _params);
                        clear();
                    }
                }
                else
                {
                    MessageBoxUI _mb = new MessageBoxUI("Failure to save the record!", GlobalVariables.Icons.Error, GlobalVariables.Buttons.OK);
                    _mb.showDialog();
                    return;
                }
            }
            catch (Exception ex)
            {
                ErrorMessageUI em = new ErrorMessageUI(ex.Message, this.Name, "btnSave_Click");
                em.ShowDialog();
                return;
            }
        }