Beispiel #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (IsValidSalaryTrans())
            {
                salaryBll b = new salaryBll();
                b.SalaryNo    = txtSalaryId.Text;
                b.EmpName     = cmbEmployeeName.Text.ToString();
                b.SalaryMonth = dateTimePickerSalaryMonth.Value;

                b.Salary     = txtSalary.Text;
                b.Bonus      = txtBonus.Text;
                b.PaidDate   = dateTimePickerPayDate.Value;
                b.Total      = txtTotal.Text;
                b.PaidAmt    = txtPaidAmt.Text;
                b.SalaryDues = txtSalaryDues.Text;
                b.Note       = txtNotes.Text;

                DialogResult result = MessageBox.Show("Are you Sure you want to Update",
                                                      "Update", MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    var success = dalObj.Update(b);
                    if (success == true)
                    {
                        MessageBox.Show("Successfully Updated Salary Information",
                                        "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Clear();
                        txtSalaryId.Clear();
                        // cmbSalaryMonth.SelectedItem = "January";
                        dateTimePickerSalaryMonth.Value = DateTime.Now;
                        dateTimePickerPayDate.Value     = DateTime.Now;
                        GenarateSalaryNo();
                        LoadEmpName();
                        cmbEmployeeName.SelectedIndex = -1;
                        var dt = dal.Select();
                        dgvSalary.DataSource = dt;
                        btnUpdate.Enabled    = false;
                        //btnDelete.Enabled = true;
                        btnPay.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show("Failed to Update Salary Information");
                    }
                }
            }
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Salary model)
 {
     return(dal.Update(model));
 }