/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { ServiceSP spService = new ServiceSP(); ServiceInfo infoService = new ServiceInfo(); infoService.ServiceName = txtServiceName.Text.Trim(); infoService.ServiceCategoryId = Convert.ToDecimal(cmbCategory.SelectedValue.ToString()); infoService.Rate = Convert.ToDecimal(txtRate.Text.ToString()); infoService.Narration = txtNarration.Text.Trim(); infoService.ExtraDate = PublicVariables._dtCurrentDate; infoService.Extra1 = string.Empty; infoService.Extra2 = string.Empty; if (spService.ServiceCheckExistence(txtServiceName.Text.Trim(), 0) == false) { decIdForOtherForms = spService.ServiceAddWithReturnIdentity(infoService); Messages.SavedMessage(); Clear(); GridFill(); } else { Messages.InformationMessage("Service name already exist"); txtServiceName.Focus(); } if (frmServiceVoucherObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("Ser11 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Edit Function /// </summary> public void EditFunction() { try { ServiceSP spService = new ServiceSP(); ServiceInfo infoService = new ServiceInfo(); infoService.ServiceId = Convert.ToDecimal(dgvService.CurrentRow.Cells["dgvtxtServiceId"].Value.ToString()); infoService.ServiceName = txtServiceName.Text.Trim(); infoService.ServiceCategoryId = Convert.ToDecimal(cmbCategory.SelectedValue.ToString()); infoService.Rate = Convert.ToDecimal(txtRate.Text.ToString()); infoService.Narration = txtNarration.Text.Trim(); infoService.Extra1 = string.Empty; infoService.Extra2 = string.Empty; if (CheckExistenceOfServiceName() == false) { if (spService.ServiceEdit(infoService)) { Messages.UpdatedMessage(); Clear(); txtServiceName.Focus(); } } else { Messages.InformationMessage("Already exists"); txtServiceName.Focus(); } } catch (Exception ex) { MessageBox.Show("Ser12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill controls for Update or delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvService_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { ServiceSP spService = new ServiceSP(); ServiceInfo infoService = new ServiceInfo(); decServiceId = Convert.ToDecimal(dgvService.Rows[e.RowIndex].Cells["dgvtxtServiceId"].Value.ToString()); infoService = spService.ServiceView(decServiceId); txtServiceName.Text = infoService.ServiceName; cmbCategory.SelectedValue = infoService.ServiceCategoryId.ToString(); txtRate.Text = infoService.Rate.ToString(); txtNarration.Text = infoService.Narration; txtServiceNameSearch.Text = string.Empty; cmbCategorySearch.SelectedIndex = 0; btnSave.Text = "Update"; btnDelete.Enabled = true; strServiceName = infoService.ServiceName; txtServiceName.Focus(); } } catch (Exception ex) { MessageBox.Show("Ser17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Gridfill function /// </summary> public void GridFill() { try { ServiceSP spService = new ServiceSP(); DataTable dtblService = new DataTable(); dtblService = spService.ServiceGridFill(); dgvService.DataSource = dtblService; } catch (Exception ex) { MessageBox.Show("Ser4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Gridfill function /// </summary> public void GridFill() { try { ServiceSP spService = new ServiceSP(); DataTable dtblService = new DataTable(); dtblService = spService.ServiceGridFill(); dgvService.DataSource = dtblService; } catch (Exception ex) { formMDI.infoError.ErrorString = "Ser4:" + ex.Message; } }
/// <summary> /// Service Search function /// </summary> /// <param name="strBrandName"></param> /// <param name="strCategoryname"></param> public void ServiceSearch(string strBrandName, string strCategoryname) { try { ServiceSP spService = new ServiceSP(); ServiceInfo infoService = new ServiceInfo(); DataTable dtblService = new DataTable(); dtblService = spService.ServiceSearch(strBrandName, strCategoryname); dgvService.DataSource = dtblService; } catch (Exception ex) { formMDI.infoError.ErrorString = "Ser9:" + ex.Message; } }
/// <summary> /// Service Search function /// </summary> /// <param name="strBrandName"></param> /// <param name="strCategoryname"></param> public void ServiceSearch(string strBrandName, string strCategoryname) { try { ServiceSP spService = new ServiceSP(); ServiceInfo infoService = new ServiceInfo(); DataTable dtblService = new DataTable(); dtblService = spService.ServiceSearch(strBrandName, strCategoryname); dgvService.DataSource = dtblService; } catch (Exception ex) { MessageBox.Show("Ser9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Delete function and reference exists checking /// </summary> public void DeleteFunction() { try { ServiceSP spService = new ServiceSP(); if (spService.ServiceDeleteReferenceCheck(decServiceId) == -1) { Messages.ReferenceExistsMessage(); } else { Clear(); btnSave.Text = "Save"; Messages.DeletedMessage(); } } catch (Exception ex) { MessageBox.Show("Ser8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Delete function and reference exists checking /// </summary> public void DeleteFunction() { try { ServiceSP spService = new ServiceSP(); if (spService.ServiceDeleteReferenceCheck(decServiceId) == -1) { Messages.ReferenceExistsMessage(); } else { Clear(); btnSave.Text = "Save"; Messages.DeletedMessage(); GridFill(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "Ser8:" + ex.Message; } }
/// <summary> /// ServiceName Checking Existance /// </summary> /// <returns></returns> public bool CheckExistenceOfServiceName() { bool isExist = false; try { ServiceSP spService = new ServiceSP(); isExist = spService.ServiceCheckExistence(txtServiceName.Text.Trim(), 0); if (isExist) { string strServiceNames = txtServiceName.Text.Trim(); if (strServiceNames.ToLower() == strServiceName.ToLower()) { isExist = false; } } } catch (Exception ex) { formMDI.infoError.ErrorString = "Ser10:" + ex.Message; } return(isExist); }
/// <summary> /// ServiceName Checking Existance /// </summary> /// <returns></returns> public bool CheckExistenceOfServiceName() { bool isExist = false; try { ServiceSP spService = new ServiceSP(); isExist = spService.ServiceCheckExistence(txtServiceName.Text.Trim(), 0); if (isExist) { string strServiceNames = txtServiceName.Text.Trim(); if (strServiceNames.ToLower() == strServiceName.ToLower()) { isExist = false; } } } catch (Exception ex) { MessageBox.Show("Ser10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(isExist); }
/// <summary> /// ServiceName Checking Existance /// </summary> /// <returns></returns> public bool CheckExistenceOfServiceName() { bool isExist = false; try { ServiceSP spService = new ServiceSP(); isExist = spService.ServiceCheckExistence(txtServiceName.Text.Trim(), 0); if (isExist) { string strServiceNames = txtServiceName.Text.Trim(); if (strServiceNames.ToLower() == strServiceName.ToLower()) { isExist = false; } } } catch (Exception ex) { MessageBox.Show("Ser10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isExist; }
/// <summary> /// Function to fill the perticular combobox in grid /// </summary> public void GridParticularComboFill() { try { DataTable dtbl = new DataTable(); ServiceSP spService = new ServiceSP(); dtbl = spService.ServiceViewAll(); dgvcmbParticulars.DataSource = dtbl; dgvcmbParticulars.DisplayMember = "serviceName"; dgvcmbParticulars.ValueMember = "serviceId"; } catch (Exception ex) { MessageBox.Show("SV 10 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On cellvaluechange of dgvServiceVoucher /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvServiceVoucher_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { ServiceSP spService = new ServiceSP(); ServiceInfo infoService = new ServiceInfo(); decimal decRate = 0; if (e.RowIndex != -1 && e.ColumnIndex != -1) { SerialNo(); if (e.ColumnIndex == dgvServiceVoucher.Columns["dgvcmbParticulars"].Index) { if (dgvServiceVoucher.Rows[e.RowIndex].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[e.RowIndex].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { infoService = spService.ServiceViewForRate(Convert.ToDecimal(dgvServiceVoucher.Rows[e.RowIndex].Cells["dgvcmbParticulars"].Value.ToString())); decRate = infoService.Rate; string strAmount = decRate.ToString(); if (strAmount != string.Empty) { dgvServiceVoucher.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = strAmount; } } } AmountCalculation(); } CheckColumnMissing(e); } catch (Exception ex) { MessageBox.Show("SV 45 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }