/// <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 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> /// On 'Print' button click to print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvPayHead.RowCount > 0) { DataSet ds = new DataSet(); PayHeadSP spPayHead = new PayHeadSP(); DataTable dtbl = spPayHead.PayHeadViewAllForPayHeadReport(cmbPayHead.Text, cmbType.Text); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); ////frmReport //frmReport = new frmReport(); //frmReport.MdiParent = formMDI.MDIObj; ds.Tables.Add(dtbl); ds.Tables.Add(dtblCompany); // frmreport.PayHeadReport(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("PHR:7 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void GridFill() { try { PayHeadSP spPayHead = new PayHeadSP(); DataTable dtbl = spPayHead.PayHeadViewAllForPayHeadReport(cmbPayHead.Text, cmbType.Text); dgvPayHead.DataSource = dtbl; } catch (Exception ex) { MessageBox.Show("PHR:2 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void GridFill() { try { PayHeadSP spPayhead = new PayHeadSP(); DataTable dtblPayhead = new DataTable(); dtblPayhead = spPayhead.PayHeadSearch(txtPayheadSearch.Text.Trim()); dgvPayhead.DataSource = dtblPayhead; } catch (Exception ex) { MessageBox.Show("PH4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill PayHead combobox /// </summary> public void PayHeadComboFill() { try { PayHeadSP spPayHead = new PayHeadSP(); DataTable dtblPayHead = spPayHead.PayHeadViewAll(); DataRow dr = dtblPayHead.NewRow(); dr[2] = "All"; dtblPayHead.Rows.InsertAt(dr, 0); cmbPayHead.DataSource = dtblPayHead; cmbPayHead.ValueMember = "payHeadId"; cmbPayHead.DisplayMember = "payHeadName"; } catch (Exception ex) { MessageBox.Show("PHR:1 " + 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); } }