/// <summary> /// Edit function /// </summary> public void EditFunction() { try { SuffixPrefixSP spSuffixPrefix = new SuffixPrefixSP(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix.FromDate = Convert.ToDateTime(txtFromDate.Text.ToString()); infoSuffixPrefix.ToDate = Convert.ToDateTime(txtToDate.Text.ToString()); String strvouchertype = (cmbVoucherType.SelectedValue.ToString()); infoSuffixPrefix.VoucherTypeId = Convert.ToDecimal(strvouchertype.ToString()); infoSuffixPrefix.Prefix = txtPrefix.Text.Trim(); infoSuffixPrefix.Suffix = txtSufix.Text.Trim(); infoSuffixPrefix.StartIndex = Convert.ToDecimal(txtStartIndex.Text.ToString()); if (cbxPrefillWithZero.Checked) { infoSuffixPrefix.PrefillWithZero = true; infoSuffixPrefix.WidthOfNumericalPart = Convert.ToInt32(txtWidthofNumericalPart.Text.ToString()); } else { infoSuffixPrefix.PrefillWithZero = false; infoSuffixPrefix.WidthOfNumericalPart = 0; } infoSuffixPrefix.Narration = txtNarration.Text.Trim(); infoSuffixPrefix.Extra1 = string.Empty; infoSuffixPrefix.Extra2 = string.Empty; infoSuffixPrefix.SuffixprefixId = decSuffixPrefixId; if (spSuffixPrefix.SuffixPrefixCheckExistenceForAdd(txtFromDate.Text.ToString(), txtToDate.Text.ToString(), Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()), decSuffixPrefixId) == false) { if (spSuffixPrefix.SuffixPrefixSettingsEdit(infoSuffixPrefix)) { Messages.UpdatedMessage(); Clear(); } else { Messages.ReferenceExistsMessageForUpdate(); cmbVoucherType.Focus(); } } else { Messages.InformationMessage("Voucher type already exist for dates"); cmbVoucherType.Focus(); } } catch (Exception ex) { MessageBox.Show("SPS5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Update values in SuffixPrefix Table /// </summary> /// <param name="suffixprefixinfo"></param> public void SuffixPrefixEdit(SuffixPrefixInfo suffixprefixinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SuffixPrefixEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@suffixprefixId", SqlDbType.Decimal); sprmparam.Value = suffixprefixinfo.SuffixprefixId; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = suffixprefixinfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@fromDate", SqlDbType.DateTime); sprmparam.Value = suffixprefixinfo.FromDate; sprmparam = sccmd.Parameters.Add("@toDate", SqlDbType.DateTime); sprmparam.Value = suffixprefixinfo.ToDate; sprmparam = sccmd.Parameters.Add("@startIndex", SqlDbType.Decimal); sprmparam.Value = suffixprefixinfo.StartIndex; sprmparam = sccmd.Parameters.Add("@prefix", SqlDbType.VarChar); sprmparam.Value = suffixprefixinfo.Prefix; sprmparam = sccmd.Parameters.Add("@suffix", SqlDbType.VarChar); sprmparam.Value = suffixprefixinfo.Suffix; sprmparam = sccmd.Parameters.Add("@widthOfNumericalPart", SqlDbType.Int); sprmparam.Value = suffixprefixinfo.WidthOfNumericalPart; sprmparam = sccmd.Parameters.Add("@prefillWithZero", SqlDbType.Bit); sprmparam.Value = suffixprefixinfo.PrefillWithZero; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = suffixprefixinfo.Narration; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = suffixprefixinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = suffixprefixinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = suffixprefixinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get SuffixPrefix details based on parameter /// </summary> /// <param name="vouchertypeId"></param> /// <param name="date"></param> /// <returns></returns> public SuffixPrefixInfo GetSuffixPrefixDetails(decimal vouchertypeId, DateTime date) { SuffixPrefixInfo suffixprefixinfo = new SuffixPrefixInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GetSuffixPrefixDetails", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@voucherId", SqlDbType.Decimal); sprmparam.Value = vouchertypeId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = date; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { suffixprefixinfo.SuffixprefixId = decimal.Parse(sdrreader[0].ToString()); suffixprefixinfo.VoucherTypeId = decimal.Parse(sdrreader[1].ToString()); suffixprefixinfo.FromDate = DateTime.Parse(sdrreader[2].ToString()); suffixprefixinfo.ToDate = DateTime.Parse(sdrreader[3].ToString()); suffixprefixinfo.StartIndex = decimal.Parse(sdrreader[4].ToString()); suffixprefixinfo.Prefix = sdrreader[5].ToString(); suffixprefixinfo.Suffix = sdrreader[6].ToString(); suffixprefixinfo.WidthOfNumericalPart = int.Parse(sdrreader[7].ToString()); suffixprefixinfo.PrefillWithZero = bool.Parse(sdrreader[8].ToString()); suffixprefixinfo.Narration = sdrreader[9].ToString(); suffixprefixinfo.ExtraDate = DateTime.Parse(sdrreader[10].ToString()); suffixprefixinfo.Extra1 = sdrreader[11].ToString(); suffixprefixinfo.Extra2 = sdrreader[12].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(suffixprefixinfo); }
/// <summary> /// grid double click fill the items in controll for edit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSuffixPrefixSettings_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { SuffixPrefixSP spSuffixPrefix = new SuffixPrefixSP(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix = spSuffixPrefix.SuffixPrefixView(Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString())); decSuffixPrefixId = Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString()); txtFromDate.Text = infoSuffixPrefix.FromDate.ToString("dd-MMM-yyyy"); txtToDate.Text = infoSuffixPrefix.ToDate.ToString("dd-MMM-yyyy"); cmbVoucherType.SelectedValue = infoSuffixPrefix.VoucherTypeId.ToString(); txtStartIndex.Text = infoSuffixPrefix.StartIndex.ToString(); txtStartIndex.Enabled = false; txtSufix.Text = infoSuffixPrefix.Suffix; txtPrefix.Text = infoSuffixPrefix.Prefix; if (infoSuffixPrefix.PrefillWithZero == true) { cbxPrefillWithZero.Checked = true; txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString(); } else { cbxPrefillWithZero.Checked = false; txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString(); } txtNarration.Text = infoSuffixPrefix.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; txtFromDate.Focus(); txtWidthofNumericalPart.Enabled = true; if (cbxPrefillWithZero.Checked == true) { txtWidthofNumericalPart.Enabled = true; } else { txtWidthofNumericalPart.Enabled = false; } } } catch (Exception ex) { MessageBox.Show("SPS20" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get id for suffixprefix insert /// </summary> /// <param name="Infosuffixprefix"></param> /// <returns></returns> public bool SuffixPrefixAddWithId(SuffixPrefixInfo Infosuffixprefix) { bool isSave = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("SuffixPrefixAddWithId", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal).Value = Infosuffixprefix.VoucherTypeId; sqlcmd.Parameters.Add("@fromDate", SqlDbType.DateTime).Value = Infosuffixprefix.FromDate; sqlcmd.Parameters.Add("@toDate", SqlDbType.DateTime).Value = Infosuffixprefix.ToDate; sqlcmd.Parameters.Add("@startIndex", SqlDbType.Decimal).Value = Infosuffixprefix.StartIndex; sqlcmd.Parameters.Add("@prefix", SqlDbType.VarChar).Value = Infosuffixprefix.Prefix; sqlcmd.Parameters.Add("@suffix", SqlDbType.VarChar).Value = Infosuffixprefix.Suffix; sqlcmd.Parameters.Add("@widthOfNumericalPart", SqlDbType.Decimal).Value = Infosuffixprefix.WidthOfNumericalPart; sqlcmd.Parameters.Add("@prefillWithZero", SqlDbType.Bit).Value = Infosuffixprefix.PrefillWithZero; sqlcmd.Parameters.Add("@narration", SqlDbType.VarChar).Value = Infosuffixprefix.Narration; sqlcmd.Parameters.Add("@extra1", SqlDbType.VarChar).Value = Infosuffixprefix.Extra1; sqlcmd.Parameters.Add("@extra2", SqlDbType.VarChar).Value = Infosuffixprefix.Extra2; int ineffectedrow = sqlcmd.ExecuteNonQuery(); if (ineffectedrow > 0) { isSave = true; } else { isSave = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(isSave); }