Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                if (validate())
                {
                    HolidaysBAL  _objBAL   = new HolidaysBAL();
                    HolidayModel _objModel = new HolidayModel();
                    _objModel._HolidayID    = selectedRecordId;
                    _objModel._HolidayDate  = Convert.ToDateTime(dtpHolidayDate.Text);
                    _objModel._Description  = tbxDescription.Text;
                    _objModel._ModifiedDate = DateTime.Now;
                    if (selectedRecordId == 0)
                    {
                        _objBAL.SaveHoliday(_objModel);
                    }
                    else
                    {
                        _objBAL.UpdateHoliday(_objModel);
                    }
                    MakeEmpty();

                    MessageBox.Show("Record Saved Successfully!");
                    FillGrid();
                }
            }
            catch
            { }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Exemple #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (selectedRecordId != 0)
     {
         try
         {
             Cursor = Cursors.WaitCursor;
             HolidaysBAL _objBAL = new HolidaysBAL();
             _objBAL.DeleteHoliday(selectedRecordId);
             MessageBox.Show("Record has been deleted successfully!");
             FillGrid();
         }
         catch (System.Data.SqlClient.SqlException sqlEx)
         {
             if (sqlEx.Number == 547)
             {
                 MessageBox.Show("You cannot delete this record. Its refference exists in other documents.");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         finally
         {
             Cursor = Cursors.Default;
             MakeEmpty();
         }
     }
 }
Exemple #3
0
 private void FillForm(Int32 _HolidayId)
 {
     try
     {
         HolidaysBAL  _objBAL   = new HolidaysBAL();
         HolidayModel _objModel = _objBAL.SearchHoliday(_HolidayId);
         dtpHolidayDate.Text  = _objModel._HolidayDate.ToString();
         tbxDescription.Text  = _objModel._Description;
         tbxModifiedDate.Text = _objModel._ModifiedDate.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #4
0
        private void FillGrid()
        {
            HolidaysBAL         _objBAL        = new HolidaysBAL();
            List <HolidayModel> DepartmentList = new List <HolidayModel>();

            grdHolidays.DataSource = null;
            grdHolidays.Rows.Clear();
            DepartmentList = _objBAL.GetHolidayList();
            grdHolidays.AutoGenerateColumns = false;
            int count = 0;

            foreach (var item in DepartmentList)
            {
                count++;
                grdHolidays.Rows.Add(item._HolidayID, item._HolidayDate, item._ModifiedDate.ToShortDateString(), item._Description);
            }
            tbxCount.Text = count.ToString();
        }