/// <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) { formMDI.infoError.ErrorString = "Ser12:" + ex.Message; } }
/// <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) { formMDI.infoError.ErrorString = "Ser17:" + ex.Message; } }
/// <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) { formMDI.infoError.ErrorString = "Ser11:" + ex.Message; } }
/// <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> /// 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); }