Ejemplo n.º 1
0
 /// <summary>
 /// Function to Update values in Service Table
 /// </summary>
 /// <param name="serviceinfo"></param>
 /// <returns></returns>
 public bool ServiceEdit(ServiceInfo serviceinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
         sprmparam.Value = serviceinfo.ServiceId;
         sprmparam = sccmd.Parameters.Add("@serviceName", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.ServiceName;
         sprmparam = sccmd.Parameters.Add("@serviceCategoryId", SqlDbType.Decimal);
         sprmparam.Value = serviceinfo.ServiceCategoryId;
         sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = serviceinfo.Rate;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.Extra2;
         int inEffectedRow = sccmd.ExecuteNonQuery();
         if (inEffectedRow > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         return false;
     }
     finally
     {
         sqlcon.Close();
     }
 }
Ejemplo n.º 2
0
 /// <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);
     }
 }
Ejemplo n.º 3
0
 /// <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);
     }
 }
Ejemplo n.º 4
0
 /// <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);
     }
 }
Ejemplo n.º 5
0
 /// <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);
     }
 }
Ejemplo n.º 6
0
 /// <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);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Function to insert values to Service Table and return the Curresponding row's Id
 /// </summary>
 /// <param name="serviceinfo"></param>
 /// <returns></returns>
 public decimal ServiceAddWithReturnIdentity(ServiceInfo serviceinfo)
 {
     decimal decIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceAddWithReturnIdentity", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceName", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.ServiceName;
         sprmparam = sccmd.Parameters.Add("@serviceCategoryId", SqlDbType.Decimal);
         sprmparam.Value = serviceinfo.ServiceCategoryId;
         sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = serviceinfo.Rate;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = serviceinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = serviceinfo.Extra2;
         decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decIdentity;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Function to get particular values from Service Table based on the parameter
 /// </summary>
 /// <param name="serviceId"></param>
 /// <returns></returns>
 public ServiceInfo ServiceViewForRate(decimal serviceId)
 {
     ServiceInfo serviceinfo = new ServiceInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceViewForRate", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
         sprmparam.Value = serviceId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             serviceinfo.ServiceName = sdrreader["serviceName"].ToString();
             serviceinfo.ServiceCategoryId = decimal.Parse(sdrreader["serviceCategoryId"].ToString());
             serviceinfo.Rate = decimal.Parse(sdrreader["rate"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return serviceinfo;
 }