/// <summary> /// Function to Update values in PayHead Table /// </summary> /// <param name="payheadinfo"></param> public void PayHeadEdit(PayHeadInfo payheadinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PayHeadEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@payHeadId", SqlDbType.Decimal); sprmparam.Value = payheadinfo.PayHeadId; sprmparam = sccmd.Parameters.Add("@payHeadName", SqlDbType.VarChar); sprmparam.Value = payheadinfo.PayHeadName; sprmparam = sccmd.Parameters.Add("@type", SqlDbType.VarChar); sprmparam.Value = payheadinfo.Type; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = payheadinfo.Narration; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function for Edit /// </summary> public void EditFunction() { try { PayHeadBll BllPayHead = new PayHeadBll(); PayHeadInfo infoPayhead = new PayHeadInfo(); infoPayhead.PayHeadId = decPayHeadId; infoPayhead.PayHeadName = txtPayheadName.Text.Trim(); infoPayhead.Type = cmbPayheadType.Text; infoPayhead.Narration = txtPayheadNarration.Text.Trim(); if (BllPayHead.PayheadCheckExistence(txtPayheadName.Text.Trim(), infoPayhead.PayHeadId) == false) { BllPayHead.PayHeadEdit(infoPayhead); GridFill(); Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage("Payhead name already exist"); txtPayheadName.Focus(); } } catch (Exception ex) { MessageBox.Show("PH2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fills controls for updation on cell double click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPayhead_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { PayHeadInfo infoPayhead = new PayHeadInfo(); PayHeadBll BllPayHead = new PayHeadBll(); infoPayhead = BllPayHead.PayHeadView(Convert.ToDecimal(dgvPayhead.CurrentRow.Cells["dgvtxtPayheadId"].Value.ToString())); txtPayheadName.Text = infoPayhead.PayHeadName; cmbPayheadType.Text = infoPayhead.Type; strPayheadType = cmbPayheadType.Text; txtPayheadNarration.Text = infoPayhead.Narration; btnPayheadSave.Text = "Update"; btnPayheadDelete.Enabled = true; strPayHeadName = infoPayhead.PayHeadName; decPayHeadId = Convert.ToDecimal(dgvPayhead.CurrentRow.Cells["dgvtxtPayheadId"].Value.ToString()); if (BllPayHead.payheadTypeCheckeferences(infoPayhead.PayHeadId, txtPayheadName.Text, cmbPayheadType.Text, txtPayheadNarration.Text)) { if (e.RowIndex != -1) { cmbPayheadType.Enabled = true; } } else { cmbPayheadType.Enabled = false; } } } catch (Exception ex) { MessageBox.Show("PH14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for save /// </summary> public void SaveFunction() { try { PayHeadBll BllPayHead = new PayHeadBll(); PayHeadInfo infoPayhead = new PayHeadInfo(); infoPayhead.PayHeadName = txtPayheadName.Text.Trim(); infoPayhead.Type = cmbPayheadType.SelectedItem.ToString(); infoPayhead.Narration = txtPayheadNarration.Text.Trim(); infoPayhead.ExtraDate = DateTime.Parse(DateTime.Now.ToString()); infoPayhead.Extra1 = string.Empty; infoPayhead.Extra2 = string.Empty; if (btnPayheadSave.Text == "Save") { if (BllPayHead.PayheadCheckExistence(txtPayheadName.Text.Trim(), 0) == false) { Messages.SavedMessage(); BllPayHead.PayHeadAdd(infoPayhead); GridFill(); Clear(); } else { Messages.InformationMessage("Payhead name already exist"); txtPayheadName.Focus(); } } } catch (Exception ex) { MessageBox.Show("PH1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Edit /// </summary> public void EditFunction() { try { PayHeadSP spPayhead = new PayHeadSP(); PayHeadInfo infoPayhead = new PayHeadInfo(); infoPayhead.PayHeadId = decPayHeadId; infoPayhead.PayHeadName = txtPayheadName.Text.Trim(); infoPayhead.Type = cmbPayheadType.Text; infoPayhead.Narration = txtPayheadNarration.Text.Trim(); if (spPayhead.PayheadCheckExistence(txtPayheadName.Text.Trim(), infoPayhead.PayHeadId) == false) { spPayhead.PayHeadEdit(infoPayhead); GridFill(); Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage("Payhead name already exist"); txtPayheadName.Focus(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "PH2:" + ex.Message; } }
/// <summary> /// Fills controls for updation on cell double click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPayhead_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { PayHeadInfo infoPayhead = new PayHeadInfo(); PayHeadSP spPayhead = new PayHeadSP(); infoPayhead = spPayhead.PayHeadView(Convert.ToDecimal(dgvPayhead.CurrentRow.Cells["dgvtxtPayheadId"].Value.ToString())); txtPayheadName.Text = infoPayhead.PayHeadName; cmbPayheadType.Text = infoPayhead.Type; strPayheadType = cmbPayheadType.Text; txtPayheadNarration.Text = infoPayhead.Narration; btnPayheadSave.Text = "Update"; btnPayheadDelete.Enabled = true; strPayHeadName = infoPayhead.PayHeadName; decPayHeadId = Convert.ToDecimal(dgvPayhead.CurrentRow.Cells["dgvtxtPayheadId"].Value.ToString()); if (spPayhead.payheadTypeCheckeferences(infoPayhead.PayHeadId, txtPayheadName.Text, cmbPayheadType.Text, txtPayheadNarration.Text)) { if (e.RowIndex != -1) { cmbPayheadType.Enabled = true; } } else { cmbPayheadType.Enabled = false; } } } catch (Exception ex) { formMDI.infoError.ErrorString = "PH14:" + ex.Message; } }
/// <summary> /// Function for save /// </summary> public void SaveFunction() { try { PayHeadSP spPayhead = new PayHeadSP(); PayHeadInfo infoPayhead = new PayHeadInfo(); infoPayhead.PayHeadName = txtPayheadName.Text.Trim(); infoPayhead.Type = cmbPayheadType.SelectedItem.ToString(); infoPayhead.Narration = txtPayheadNarration.Text.Trim(); infoPayhead.ExtraDate = DateTime.Parse(DateTime.Now.ToString()); infoPayhead.Extra1 = string.Empty; infoPayhead.Extra2 = string.Empty; if (btnPayheadSave.Text == "Save") { if (spPayhead.PayheadCheckExistence(txtPayheadName.Text.Trim(), 0) == false) { Messages.SavedMessage(); spPayhead.PayHeadAdd(infoPayhead); GridFill(); Clear(); } else { Messages.InformationMessage("Payhead name already exist"); txtPayheadName.Focus(); } } } catch (Exception ex) { formMDI.infoError.ErrorString = "PH1:" + ex.Message; } }
/// <summary> /// Function to Update values in PayHead Table /// </summary> /// <param name="payheadinfo"></param> public void PayHeadEdit(PayHeadInfo payheadinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PayHeadEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@payHeadId", SqlDbType.Decimal); sprmparam.Value = payheadinfo.PayHeadId; sprmparam = sccmd.Parameters.Add("@payHeadName", SqlDbType.VarChar); sprmparam.Value = payheadinfo.PayHeadName; sprmparam = sccmd.Parameters.Add("@type", SqlDbType.VarChar); sprmparam.Value = payheadinfo.Type; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = payheadinfo.Narration; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function for save /// </summary> public void SaveFunction() { try { PayHeadSP spPayhead = new PayHeadSP(); PayHeadInfo infoPayhead = new PayHeadInfo(); infoPayhead.PayHeadName = txtPayheadName.Text.Trim(); infoPayhead.Type = cmbPayheadType.SelectedItem.ToString(); infoPayhead.Narration = txtPayheadNarration.Text.Trim(); infoPayhead.ExtraDate = DateTime.Parse(DateTime.Now.ToString()); infoPayhead.Extra1 = string.Empty; infoPayhead.Extra2 = string.Empty; if (btnPayheadSave.Text == "Save") { if (spPayhead.PayheadCheckExistence(txtPayheadName.Text.Trim(), 0) == false) { Messages.SavedMessage(); spPayhead.PayHeadAdd(infoPayhead); GridFill(); Clear(); } else { Messages.InformationMessage("Payhead name already exist"); txtPayheadName.Focus(); } } } catch (Exception ex) { MessageBox.Show("PH1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from PayHead Table based on the parameter /// </summary> /// <param name="payHeadId"></param> /// <returns></returns> public PayHeadInfo PayHeadView(decimal payHeadId) { PayHeadInfo payheadinfo = new PayHeadInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PayHeadView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@payHeadId", SqlDbType.Decimal); sprmparam.Value = payHeadId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { payheadinfo.PayHeadId = Convert.ToDecimal(sdrreader[0].ToString()); payheadinfo.PayHeadName = sdrreader[1].ToString(); payheadinfo.Type = sdrreader[2].ToString(); payheadinfo.Narration = sdrreader[3].ToString(); payheadinfo.ExtraDate = DateTime.Parse(sdrreader[4].ToString()); payheadinfo.Extra1 = sdrreader[5].ToString(); payheadinfo.Extra2 = sdrreader[6].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(payheadinfo); }
/// <summary> /// Function for Delete /// </summary> public void DeleteFunction() { try { PayHeadInfo infoPayhead = new PayHeadInfo(); PayHeadBll BllPayHead = new PayHeadBll(); if (BllPayHead.PayHeadDeleteVoucherTypeCheckReference(decPayHeadId)) { Messages.ReferenceExistsMessage(); txtPayheadName.Focus(); } else { Messages.DeletedMessage(); Clear(); } GridFill(); } catch (Exception ex) { MessageBox.Show("PH6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Delete /// </summary> public void DeleteFunction() { try { PayHeadInfo infoPayhead = new PayHeadInfo(); PayHeadSP spPayhead = new PayHeadSP(); if (spPayhead.PayHeadDeleteVoucherTypeCheckReference(decPayHeadId)) { Messages.ReferenceExistsMessage(); txtPayheadName.Focus(); } else { Messages.DeletedMessage(); Clear(); } GridFill(); } catch (Exception ex) { formMDI.infoError.ErrorString = "PH6:" + ex.Message; } }
/// <summary> /// Function to get particular values from PayHead Table based on the parameter /// </summary> /// <param name="payHeadId"></param> /// <returns></returns> public PayHeadInfo PayHeadView(decimal payHeadId) { PayHeadInfo payheadinfo = new PayHeadInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PayHeadView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@payHeadId", SqlDbType.Decimal); sprmparam.Value = payHeadId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { payheadinfo.PayHeadId = Convert.ToDecimal(sdrreader[0].ToString()); payheadinfo.PayHeadName = sdrreader[1].ToString(); payheadinfo.Type = sdrreader[2].ToString(); payheadinfo.Narration = sdrreader[3].ToString(); payheadinfo.ExtraDate = DateTime.Parse(sdrreader[4].ToString()); payheadinfo.Extra1 = sdrreader[5].ToString(); payheadinfo.Extra2 = sdrreader[6].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return payheadinfo; }
/// <summary> /// Function for Edit /// </summary> public void EditFunction() { try { PayHeadSP spPayhead = new PayHeadSP(); PayHeadInfo infoPayhead = new PayHeadInfo(); infoPayhead.PayHeadId = decPayHeadId; infoPayhead.PayHeadName = txtPayheadName.Text.Trim(); infoPayhead.Type = cmbPayheadType.Text; infoPayhead.Narration = txtPayheadNarration.Text.Trim(); if (spPayhead.PayheadCheckExistence(txtPayheadName.Text.Trim(), infoPayhead.PayHeadId) == false) { spPayhead.PayHeadEdit(infoPayhead); GridFill(); Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage("Payhead name already exist"); txtPayheadName.Focus(); } } catch (Exception ex) { MessageBox.Show("PH2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fills controls for updation on cell double click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPayhead_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { PayHeadInfo infoPayhead = new PayHeadInfo(); PayHeadSP spPayhead = new PayHeadSP(); infoPayhead = spPayhead.PayHeadView(Convert.ToDecimal(dgvPayhead.CurrentRow.Cells["dgvtxtPayheadId"].Value.ToString())); txtPayheadName.Text = infoPayhead.PayHeadName; cmbPayheadType.Text = infoPayhead.Type; strPayheadType = cmbPayheadType.Text; txtPayheadNarration.Text = infoPayhead.Narration; btnPayheadSave.Text = "Update"; btnPayheadDelete.Enabled = true; strPayHeadName = infoPayhead.PayHeadName; decPayHeadId = Convert.ToDecimal(dgvPayhead.CurrentRow.Cells["dgvtxtPayheadId"].Value.ToString()); if (spPayhead.payheadTypeCheckeferences(infoPayhead.PayHeadId, txtPayheadName.Text, cmbPayheadType.Text, txtPayheadNarration.Text)) { if (e.RowIndex != -1) { cmbPayheadType.Enabled = true; } } else { cmbPayheadType.Enabled = false; } } } catch (Exception ex) { MessageBox.Show("PH14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Delete /// </summary> public void DeleteFunction() { try { PayHeadInfo infoPayhead = new PayHeadInfo(); PayHeadSP spPayhead = new PayHeadSP(); if (spPayhead.PayHeadDeleteVoucherTypeCheckReference(decPayHeadId)) { Messages.ReferenceExistsMessage(); txtPayheadName.Focus(); } else { Messages.DeletedMessage(); Clear(); } GridFill(); } catch (Exception ex) { MessageBox.Show("PH6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }