private void ListDocument() { try { grdList.Rows.Clear(); LeaveCompOffEntryDB lcdb = new LeaveCompOffEntryDB(); List <leavecompoff> lco = lcdb.getLeaveOBDetails(Convert.ToInt32(txtEmpID.Text)); foreach (leavecompoff lcf in lco) { grdList.Rows.Add(); grdList.Rows[grdList.RowCount - 1].Cells["RowID"].Value = lcf.RowID; grdList.Rows[grdList.RowCount - 1].Cells["Date"].Value = lcf.cdate.Date.ToString("dd-MM-yyyy"); grdList.Rows[grdList.RowCount - 1].Cells["EmpID"].Value = lcf.EmployeeID; grdList.Rows[grdList.RowCount - 1].Cells["empStatus"].Value = statusvalue(lcf.Status); } if (grdList.Rows.Count >= lcdb.getMaxAccuralForLeaveType()) { btnNew.Visible = false; } else { applyPrivilege(); btnNew.Visible = true; } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } enableBottomButtons(); pnlMainList.Visible = true; }
private void btnSave_Click(object sender, EventArgs e) { try { leavecompoff lco = new leavecompoff(); LeaveCompOffEntryDB LcoDB = new LeaveCompOffEntryDB(); lco.EmployeeID = txtEmpID.Text; lco.cdate = dtpcDate.Value.Date; //doc.Status = getstatuscode(cmbUserStatus.SelectedItem.ToString()); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; { if (btnText.Equals("Save")) { for (int i = 0; i < grdList.Rows.Count; i++) { if (lco.cdate.Date.ToString("dd-MM-yyyy") == grdList.Rows[i].Cells["Date"].Value.ToString()) { MessageBox.Show("Date Already Exists!!!"); return; } } if (lco.cdate.Year == DateTime.Now.Year || lco.cdate.Year == DateTime.Now.Year - 1) { if (lco.cdate < DateTime.Now.Date) { if (LcoDB.insertLeaveCompOff(lco)) { MessageBox.Show("CompOff data Added"); closeAllPanels(); ListDocument(); } else { MessageBox.Show("Failed to Insert CompOff"); } } else { MessageBox.Show("Please Check the date!!!!"); } } else { MessageBox.Show("Please Check the date!!!!"); } } } } catch (Exception) { MessageBox.Show("Failed Adding / Editing User Data"); } btnNew.Enabled = true; }
private void grdList_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } string columnName = grdList.Columns[e.ColumnIndex].Name; if (columnName.Equals("Delete")) { if (grdList.Rows[e.RowIndex].Cells["empStatus"].Value.ToString() != "Availed") { DialogResult dialog = MessageBox.Show("Are you sure to Delete the CompOff Entered ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { LeaveCompOffEntryDB lcdb = new LeaveCompOffEntryDB(); int rowid = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["RowID"].Value); if (lcdb.DeleteLeaveCompOff(rowid)) { MessageBox.Show("CompOff Deleted Successfully"); ListDocument(); } else { MessageBox.Show("Error Deleting CompOff!!!"); } //disableBottomButtons(); } } else { MessageBox.Show("Leave has Been Availed!!! "); } } } catch (Exception) { } }