/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { BrandSP spBrand = new BrandSP(); BrandInfo infoBrand = new BrandInfo(); infoBrand.BrandName = txtBrandName.Text.Trim(); infoBrand.Narration = txtNarration.Text.Trim(); ; infoBrand.Manufacturer = txtManufacturer.Text.Trim(); infoBrand.ExtraDate = DateTime.Now; infoBrand.Extra1 = string.Empty; infoBrand.Extra2 = string.Empty; if (spBrand.BrandCheckIfExist(txtBrandName.Text.Trim(), 0) == false) { decIdentity = spBrand.BrandAdd(infoBrand); Messages.SavedMessage(); Clear(); } else { Messages.InformationMessage("Brand name already exist"); txtBrandName.Focus(); } } catch (Exception ex) { MessageBox.Show("BR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill controls on datagridview cell double click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvBrand_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { BrandInfo infoBrand = new BrandInfo(); BrandSP spBrand = new BrandSP(); strBrandName = dgvBrand.CurrentRow.Cells["Column1"].Value.ToString(); if (strBrandName != "NA") { decBrandId = Convert.ToDecimal(dgvBrand.Rows[e.RowIndex].Cells["dgvtxtBrandid"].Value.ToString()); infoBrand = spBrand.BrandView(decBrandId); txtBrandName.Text = infoBrand.BrandName; txtManufacturer.Text = infoBrand.Manufacturer; txtNarration.Text = infoBrand.Narration; btnSave.Text = "Update"; txtBrandName.Focus(); btnDelete.Enabled = true; strBrandName = infoBrand.BrandName; } else { Messages.WarningMessage("NA Brand cannot update or delete"); Clear(); } } } catch (Exception ex) { MessageBox.Show("BR19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { BrandSP spBrand = new BrandSP(); BrandInfo infoBrand = new BrandInfo(); infoBrand.BrandName = txtBrandName.Text.Trim(); infoBrand.Narration = txtNarration.Text.Trim();; infoBrand.Manufacturer = txtManufacturer.Text.Trim(); infoBrand.ExtraDate = DateTime.Now; infoBrand.Extra1 = string.Empty; infoBrand.Extra2 = string.Empty; if (spBrand.BrandCheckIfExist(txtBrandName.Text.Trim(), 0) == false) { decIdentity = spBrand.BrandAdd(infoBrand); Messages.SavedMessage(); Clear(); } else { Messages.InformationMessage("Brand name already exist"); txtBrandName.Focus(); } } catch (Exception ex) { MessageBox.Show("BR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit /// </summary> public void EditFunction() { try { BrandSP spBrand = new BrandSP(); BrandInfo infoBrand = new BrandInfo(); infoBrand.BrandName = txtBrandName.Text.Trim(); infoBrand.Narration = txtNarration.Text.Trim(); infoBrand.Manufacturer = txtManufacturer.Text.Trim(); infoBrand.Extra1 = string.Empty; infoBrand.Extra2 = string.Empty; infoBrand.ExtraDate = DateTime.Now; infoBrand.BrandId = decBrandId; if (txtBrandName.Text != strBrandName) { if (CheckExistenceOfBrandName() == false) { if (spBrand.BrandEdit(infoBrand)) { Messages.UpdatedMessage(); Clear(); txtBrandName.Focus(); } else if (infoBrand.BrandId == 1) { Messages.InformationMessage("Cannot update"); Clear(); txtBrandName.Focus(); } } else { Messages.InformationMessage("Brand name already exists"); txtBrandName.Focus(); } } else if (infoBrand.BrandId == 1) { Messages.InformationMessage("Cannot update"); Clear(); txtBrandName.Focus(); } else { if (spBrand.BrandEdit(infoBrand)) { Messages.UpdatedMessage(); Clear(); } } } catch (Exception ex) { MessageBox.Show("BR3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill datagridview /// </summary> public void GridFill() { try { BrandSP spBrand = new BrandSP(); DataTable dtblBrand = new DataTable(); dtblBrand = spBrand.BrandSearch(txtBrandNameSearch.Text.Trim()); dgvBrand.DataSource = dtblBrand; } catch (Exception ex) { formMDI.infoError.ErrorString = "BR7:" + ex.Message; } }
/// <summary> /// Function to fill datagridview /// </summary> public void GridFill() { try { BrandSP spBrand = new BrandSP(); DataTable dtblBrand = new DataTable(); dtblBrand = spBrand.BrandSearch(txtBrandNameSearch.Text.Trim()); dgvBrand.DataSource = dtblBrand; } catch (Exception ex) { MessageBox.Show("BR7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Brand combobox /// </summary> public void BrandComboFill() { try { DataTable dtbl = new DataTable(); BrandSP spBrand = new BrandSP(); dtbl = spBrand.BrandViewAll(); DataRow dr = dtbl.NewRow(); dr["brandName"] = "All"; dr["brandId"] = 0; dtbl.Rows.InsertAt(dr, 0); cmbBrand.DataSource = dtbl; cmbBrand.DisplayMember = "brandName"; cmbBrand.ValueMember = "brandId"; } catch (Exception ex) { MessageBox.Show("SE:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the barnd combobox /// </summary> public void BrandComboFill() { try { DataTable dtbl = new DataTable(); BrandSP spBrand = new BrandSP(); dtbl = spBrand.BrandViewAll(); DataRow dr = dtbl.NewRow(); dr["brandName"] = "All"; dr["brandId"] = 0; dtbl.Rows.InsertAt(dr, 0); cmbBrand.DataSource = dtbl; cmbBrand.DisplayMember = "brandName"; cmbBrand.ValueMember = "brandId"; } catch (Exception ex) { formMDI.infoError.ErrorString = "SER3:" + ex.Message; } }
/// <summary> /// Function to delete /// </summary> public void DeleteFunction() { try { BrandSP spBrand = new BrandSP(); if (spBrand.BrandDeleteCheckExistence(decBrandId) <= 0) { Messages.ReferenceExistsMessage(); } else { Clear(); btnSave.Text = "Save"; Messages.DeletedMessage(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "BR6:" + ex.Message; } }
/// <summary> /// Function to delete /// </summary> public void DeleteFunction() { try { BrandSP spBrand = new BrandSP(); if (spBrand.BrandDeleteCheckExistence(decBrandId) <= 0) { Messages.ReferenceExistsMessage(); } else { Clear(); btnSave.Text = "Save"; Messages.DeletedMessage(); } } catch (Exception ex) { MessageBox.Show("BR6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to check existence of brand name /// </summary> /// <returns></returns> public bool CheckExistenceOfBrandName() { bool isExist = false; try { BrandSP spBrand = new BrandSP(); isExist = spBrand.BrandCheckIfExist(txtBrandName.Text.Trim(), 0); if (isExist) { string strBrandNames = txtBrandName.Text.Trim(); if (strBrandNames.ToLower() == strBrandName.ToLower()) { isExist = false; } } } catch (Exception ex) { MessageBox.Show("BR8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(isExist); }
/// <summary> /// Function to check existence of brand name /// </summary> /// <returns></returns> public bool CheckExistenceOfBrandName() { bool isExist = false; try { BrandSP spBrand = new BrandSP(); isExist = spBrand.BrandCheckIfExist(txtBrandName.Text.Trim(), 0); if (isExist) { string strBrandNames = txtBrandName.Text.Trim(); if (strBrandNames.ToLower() == strBrandName.ToLower()) { isExist = false; } } } catch (Exception ex) { formMDI.infoError.ErrorString = "BR8:" + ex.Message; } return(isExist); }
/// <summary> /// Function to fill Brand combobox /// </summary> public void BrandComboFill() { try { BrandSP spBrand = new BrandSP(); dtblBrand = spBrand.BrandViewAll(); dgvcmbBrand.DataSource = dtblBrand; dgvcmbBrand.ValueMember = "brandId"; dgvcmbBrand.DisplayMember = "brandName"; SettingsSP spSettings = new SettingsSP(); if (spSettings.SettingsStatusCheck("ShowBrand") == "Yes") { dgvcmbBrand.ReadOnly = false; } else { dgvcmbBrand.ReadOnly = true; } } catch (Exception ex) { MessageBox.Show("MPC6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to check existence of brand name /// </summary> /// <returns></returns> public bool CheckExistenceOfBrandName() { bool isExist = false; try { BrandSP spBrand = new BrandSP(); isExist = spBrand.BrandCheckIfExist(txtBrandName.Text.Trim(), 0); if (isExist) { string strBrandNames = txtBrandName.Text.Trim(); if (strBrandNames.ToLower() == strBrandName.ToLower()) { isExist = false; } } } catch (Exception ex) { MessageBox.Show("BR8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isExist; }
/// <summary> /// Grid fill function Againest DeliveryNote /// </summary> public void gridFillAgainestDeliveryNote() { DeliveryNoteMasterSP SPDeliveryNoteMaster = new DeliveryNoteMasterSP(); DeliveryNoteDetailsSP SPDeliveryNoteDetails = new DeliveryNoteDetailsSP(); ProductInfo infoproduct = new ProductInfo(); SalesMasterSP spSalesMaster = new SalesMasterSP(); BrandInfo InfoBrand = new BrandInfo(); TaxInfo infoTax = new TaxInfo(); TaxSP SPTax = new TaxSP(); try { if (cmbSalesModeOrderNo.SelectedIndex > 0) { inMaxCount = 0; isValueChange = false; for (int i = 0; i < dgvSalesInvoice.RowCount - 1; i++) { if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != string.Empty) { lstArrOfRemove.Add(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString()); } } dgvSalesInvoice.Rows.Clear(); isValueChange = true; DataTable dtblMaster = SPDeliveryNoteMaster.SalesInvoiceGridfillAgainestDeliveryNote(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString())); cmbPricingLevel.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["pricingLevelId"].ToString()); cmbCurrency.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["exchangeRateId"].ToString()); cmbPricingLevel.Enabled = false; cmbCurrency.Enabled = false; DataTable dtblDetails = SPDeliveryNoteDetails.SalesInvoiceGridfillAgainestDeliveryNoteUsingDeliveryNoteDetails(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()), decSalesInvoiceIdToEdit, DecSalesInvoiceVoucherTypeId); dtblDeliveryNoteDetails = dtblDetails; int inRowIndex = 0; foreach (DataRow drowDetails in dtblDetails.Rows) { dgvSalesInvoice.Rows.Add(); IsSetGridValueChange = false; isValueChange = false; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = drowDetails["deliveryNoteDetailsId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductCode"].Value = drowDetails["productCode"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBarcode"].Value = drowDetails["barcode"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = drowDetails["voucherNo"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = drowDetails["invoiceNo"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value = "0"; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInRowIndex"].Value = drowDetails["deliveryNoteDetailsId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value = drowDetails.ItemArray[2].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = drowDetails["unitConversionId"].ToString(); infoproduct = spSalesMaster.ProductViewByProductIdforSalesInvoice(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductName"].Value = infoproduct.ProductName; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceMrp"].Value = infoproduct.Mrp; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = infoproduct.PurchaseRate; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceSalesRate"].Value = infoproduct.SalesRate; InfoBrand = new BrandSP().BrandView(infoproduct.BrandId); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBrand"].Value = InfoBrand.BrandName; infoTax = SPTax.TaxViewByProductId(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceTaxName"].Value = infoTax.TaxId; isValueChange = false; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceQty"].Value = drowDetails["Qty"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceRate"].Value = drowDetails["rate"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceAmount"].Value = drowDetails["amount"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceConversionRate"].Value = drowDetails["conversionRate"].ToString(); isFromAgainest = true; gridColumnMakeEnables(); int intIndex = 0; intIndex = Convert.ToInt32(drowDetails["deliveryNoteDetailsId"].ToString()); if (inMaxCount < intIndex) inMaxCount = intIndex; inRowIndex++; isValueChange = true; isFromAgainest = false; GrossValueCalculation(dgvSalesInvoice.Rows.Count - 2); discountCalculation(dgvSalesInvoice.Rows.Count - 2); taxAndGridTotalAmountCalculation(dgvSalesInvoice.Rows.Count - 2); } IsSetGridValueChange = true; for (int i = inRowIndex; i < dgvSalesInvoice.Rows.Count; ++i) dgvSalesInvoice["dgvtxtSalesInvoiceInRowIndex", i].Value = GetNextinRowIndex().ToString(); SerialNoforSalesInvoice(); strVoucherNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString(); strInvoiceNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString(); decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value); } else { SiGridTotalAmountCalculation(); ClearGridAgainest(); } SiGridTotalAmountCalculation(); } catch (Exception ex) { MessageBox.Show("SI: 53" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//-------------------------------------------------------------BrandComboFill--------------------------- public void BrandComboFill() { try { DataTable dtbl = new DataTable(); BrandSP spBrand = new BrandSP(); dtbl = spBrand.BrandViewAll(); cmbBrand.DataSource = dtbl; cmbBrand.DisplayMember = "brandName"; cmbBrand.ValueMember = "brandId"; cmbBrand.SelectedValue = 1; } catch (Exception ex) { MessageBox.Show("PC:46" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }