/// <summary>
 /// Function to Update values in RejectionInMaster Table
 /// </summary>
 /// <param name="rejectioninmasterinfo"></param>
 public void RejectionInMasterEdit(RejectionInMasterInfo rejectioninmasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RejectionInMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@rejectionInMasterId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.RejectionInMasterId;
         sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.VoucherNo;
         sprmparam       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.InvoiceNo;
         sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.VoucherTypeId;
         sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.SuffixPrefixId;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = rejectioninmasterinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@deliveryNoteMasterId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.DeliveryNoteMasterId;
         sprmparam       = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.PricinglevelId;
         sprmparam       = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.EmployeeId;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.ExchangeRateId;
         sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.TotalAmount;
         sprmparam       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.UserId;
         sprmparam       = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.LrNo;
         sprmparam       = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.TransportationCompany;
         sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.FinancialYearId;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 /// <summary>
 /// Function to insert values to RejectionInMaster Table
 /// </summary>
 /// <param name="rejectioninmasterinfo"></param>
 /// <returns></returns>
 public decimal RejectionInMasterAdd(RejectionInMasterInfo rejectioninmasterinfo)
 {
     decimal decIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RejectionInMasterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = rejectioninmasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@deliveryNoteMasterId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.DeliveryNoteMasterId;
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.PricinglevelId;
         sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.EmployeeId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.LrNo;
         sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.TransportationCompany;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = rejectioninmasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = rejectioninmasterinfo.Extra2;
         decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decIdentity;
 }
        /// <summary>
        /// Function to get particular values from RejectionInMaster table based on the parameter
        /// </summary>
        /// <param name="rejectionInMasterId"></param>
        /// <returns></returns>
        public RejectionInMasterInfo RejectionInMasterView(decimal rejectionInMasterId)
        {
            RejectionInMasterInfo rejectioninmasterinfo = new RejectionInMasterInfo();
            SqlDataReader         sdrreader             = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("RejectionInMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@rejectionInMasterId", SqlDbType.Decimal);
                sprmparam.Value = rejectionInMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    rejectioninmasterinfo.RejectionInMasterId = decimal.Parse(sdrreader[0].ToString());
                    rejectioninmasterinfo.VoucherNo           = sdrreader[1].ToString();
                    rejectioninmasterinfo.InvoiceNo           = sdrreader[2].ToString();
                    rejectioninmasterinfo.VoucherTypeId       = decimal.Parse(sdrreader[3].ToString());
                    rejectioninmasterinfo.SuffixPrefixId      = decimal.Parse(sdrreader[4].ToString());
                    rejectioninmasterinfo.Date                  = DateTime.Parse(sdrreader[5].ToString());
                    rejectioninmasterinfo.LedgerId              = decimal.Parse(sdrreader[6].ToString());
                    rejectioninmasterinfo.PricinglevelId        = decimal.Parse(sdrreader[7].ToString());
                    rejectioninmasterinfo.EmployeeId            = decimal.Parse(sdrreader[8].ToString());
                    rejectioninmasterinfo.Narration             = sdrreader[9].ToString();
                    rejectioninmasterinfo.ExchangeRateId        = decimal.Parse(sdrreader[10].ToString());
                    rejectioninmasterinfo.TotalAmount           = decimal.Parse(sdrreader[11].ToString());
                    rejectioninmasterinfo.UserId                = decimal.Parse(sdrreader[12].ToString());
                    rejectioninmasterinfo.LrNo                  = sdrreader[13].ToString();
                    rejectioninmasterinfo.TransportationCompany = sdrreader[14].ToString();
                    rejectioninmasterinfo.FinancialYearId       = decimal.Parse(sdrreader[15].ToString());
                    rejectioninmasterinfo.ExtraDate             = DateTime.Parse(sdrreader[16].ToString());
                    rejectioninmasterinfo.Extra1                = sdrreader[17].ToString();
                    rejectioninmasterinfo.Extra2                = sdrreader[18].ToString();
                    rejectioninmasterinfo.DeliveryNoteMasterId  = decimal.Parse(sdrreader[19].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(rejectioninmasterinfo);
        }
 /// <summary>
 /// Function to get particular values from RejectionInMaster table based on the parameter
 /// </summary>
 /// <param name="rejectionInMasterId"></param>
 /// <returns></returns>
 public RejectionInMasterInfo RejectionInMasterView(decimal rejectionInMasterId)
 {
     RejectionInMasterInfo rejectioninmasterinfo = new RejectionInMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RejectionInMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@rejectionInMasterId", SqlDbType.Decimal);
         sprmparam.Value = rejectionInMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             rejectioninmasterinfo.RejectionInMasterId = decimal.Parse(sdrreader[0].ToString());
             rejectioninmasterinfo.VoucherNo = sdrreader[1].ToString();
             rejectioninmasterinfo.InvoiceNo = sdrreader[2].ToString();
             rejectioninmasterinfo.VoucherTypeId = decimal.Parse(sdrreader[3].ToString());
             rejectioninmasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[4].ToString());
             rejectioninmasterinfo.Date = DateTime.Parse(sdrreader[5].ToString());
             rejectioninmasterinfo.LedgerId = decimal.Parse(sdrreader[6].ToString());
             rejectioninmasterinfo.PricinglevelId = decimal.Parse(sdrreader[7].ToString());
             rejectioninmasterinfo.EmployeeId = decimal.Parse(sdrreader[8].ToString());
             rejectioninmasterinfo.Narration = sdrreader[9].ToString();
             rejectioninmasterinfo.ExchangeRateId = decimal.Parse(sdrreader[10].ToString());
             rejectioninmasterinfo.TotalAmount = decimal.Parse(sdrreader[11].ToString());
             rejectioninmasterinfo.UserId = decimal.Parse(sdrreader[12].ToString());
             rejectioninmasterinfo.LrNo = sdrreader[13].ToString();
             rejectioninmasterinfo.TransportationCompany = sdrreader[14].ToString();
             rejectioninmasterinfo.FinancialYearId = decimal.Parse(sdrreader[15].ToString());
             rejectioninmasterinfo.ExtraDate = DateTime.Parse(sdrreader[16].ToString());
             rejectioninmasterinfo.Extra1 = sdrreader[17].ToString();
             rejectioninmasterinfo.Extra2 = sdrreader[18].ToString();
             rejectioninmasterinfo.DeliveryNoteMasterId = decimal.Parse(sdrreader[19].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return rejectioninmasterinfo;
 }
Example #5
0
        /// <summary>
        /// Save or edit function
        /// </summary>
        public void SaveOrEdit()
        {
            SettingsSP spSetting = new SettingsSP();
            try
            {
                decimal decIdentity = 0;
                DeliveryNoteMasterSP SpDeliveryNoteMaster = new DeliveryNoteMasterSP();
                DeliveryNoteMasterInfo InfoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
                InfoDeliveryNoteMaster = SpDeliveryNoteMaster.DeliveryNoteMasterView(Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue));
                RejectionInMasterInfo InfoRejectionInMaster = new RejectionInMasterInfo();
                RejectionInDetailsInfo InfoRejectionInDetails = new RejectionInDetailsInfo();
                RejectionInDetailsSP SpRejectionInDetails = new RejectionInDetailsSP();
                StockPostingInfo InfoStockPosting = new StockPostingInfo();
                StockPostingSP SpStockPosting = new StockPostingSP();
                if (isAutomatic)
                {
                    InfoRejectionInMaster.VoucherNo = strVoucherNo;
                    InfoRejectionInMaster.InvoiceNo = txtRejectionInNo.Text;
                }
                else
                {
                    InfoRejectionInMaster.VoucherNo = txtRejectionInNo.Text;
                    InfoRejectionInMaster.InvoiceNo = txtRejectionInNo.Text;
                }
                InfoRejectionInMaster.VoucherTypeId = decRejectionInVoucherTypeId;
                InfoRejectionInMaster.SuffixPrefixId = decRejectionInSuffixPrefixId;
                InfoRejectionInMaster.Date = DateTime.Parse(txtDate.Text);
                InfoRejectionInMaster.LedgerId = Convert.ToDecimal(cmbCashorParty.SelectedValue.ToString());
                InfoRejectionInMaster.PricinglevelId = cmbPricingLevel.SelectedValue == null ? 0 : Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
                InfoRejectionInMaster.EmployeeId = cmbSalesMan.SelectedValue == null ? 1 : Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
                InfoRejectionInMaster.Narration = txtNarration.Text.Trim();
                InfoRejectionInMaster.ExchangeRateId = cmbCurrency.SelectedValue == null ? 0 : Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                InfoRejectionInMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
                InfoRejectionInMaster.UserId = PublicVariables._decCurrentUserId;
                InfoRejectionInMaster.LrNo = txtLRNo.Text.Trim();
                InfoRejectionInMaster.TransportationCompany = txtTransportationCompany.Text.Trim();
                InfoRejectionInMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                InfoRejectionInMaster.Extra1 = string.Empty;
                InfoRejectionInMaster.Extra2 = string.Empty;
                InfoRejectionInMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue == null ? "" : cmbDeliveryNoteNo.SelectedValue.ToString());

                if (decRejectionInIdToEdit == 0)
                {
                    decIdentity = spRejectionInMaster.RejectionInMasterAdd(InfoRejectionInMaster);
                }
                else
                {
                    InfoRejectionInMaster.RejectionInMasterId = decRejectionInIdToEdit;
                    spRejectionInMaster.RejectionInMasterEdit(InfoRejectionInMaster);
                }
                if (decRejectionInIdToEdit == 0)
                {
                    InfoRejectionInDetails.RejectionInMasterId = decIdentity;
                }
                else
                {
                    SpRejectionInDetails.DeleteRejectionInDetailsByRejectionInMasterId(decRejectionInIdToEdit);
                    SpStockPosting.DeleteStockPostingByAgnstVouTypeIdAndAgnstVouNo(decRejectionInVoucherTypeId, strVoucherNo);
                    InfoRejectionInDetails.RejectionInMasterId = decRejectionInIdToEdit;
                }
                foreach (DataGridViewRow dgvrow in dgvProduct.Rows)
                {
                    InfoRejectionInDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxDeliveryNoteDetailsId"].Value.ToString());
                    InfoRejectionInDetails.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString());
                    InfoRejectionInDetails.Qty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString());
                    InfoRejectionInDetails.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString());
                    InfoRejectionInDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString());
                    InfoRejectionInDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value.ToString());//0;//check
                    InfoRejectionInDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString());
                    InfoRejectionInDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString());
                    InfoRejectionInDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString());
                    InfoRejectionInDetails.Amount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAmount"].Value.ToString());
                    InfoRejectionInDetails.SlNo = Convert.ToInt32(dgvrow.Cells["dgvtxtSlNo"].Value.ToString());
                    InfoRejectionInDetails.Extra1 = string.Empty;
                    InfoRejectionInDetails.Extra2 = string.Empty;
                    SpRejectionInDetails.RejectionInDetailsAdd(InfoRejectionInDetails);
                    InfoStockPosting.Date = Convert.ToDateTime(txtDate.Text);
                    InfoStockPosting.VoucherTypeId = InfoDeliveryNoteMaster.VoucherTypeId;
                    InfoStockPosting.VoucherNo = InfoDeliveryNoteMaster.VoucherNo;
                    InfoStockPosting.InvoiceNo = InfoDeliveryNoteMaster.InvoiceNo;
                    InfoStockPosting.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString());
                    InfoStockPosting.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString());
                    InfoStockPosting.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString());
                    InfoStockPosting.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString());
                    InfoStockPosting.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString());
                    InfoStockPosting.AgainstVoucherTypeId = decRejectionInVoucherTypeId;
                    if (isAutomatic)
                    {
                        InfoStockPosting.AgainstInvoiceNo = txtRejectionInNo.Text;
                        InfoStockPosting.AgainstVoucherNo = strVoucherNo;
                    }
                    else
                    {
                        InfoStockPosting.AgainstInvoiceNo = txtRejectionInNo.Text;
                        InfoStockPosting.AgainstVoucherNo = txtRejectionInNo.Text;
                    }
                    InfoStockPosting.InwardQty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString());
                    InfoStockPosting.OutwardQty = 0;
                    InfoStockPosting.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString());
                    InfoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    InfoStockPosting.Extra1 = string.Empty;
                    InfoStockPosting.Extra2 = string.Empty;
                    SpStockPosting.StockPostingAdd(InfoStockPosting);

                }
                if (decRejectionInIdToEdit == 0)
                {
                    Messages.SavedMessage();
                    if (cbxPrintAfterSave.Checked)
                    {
                        if (spSetting.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decIdentity);
                        }
                        else
                        {
                            Print(decIdentity);
                        }
                    }

                }
                else
                {
                    Messages.UpdatedMessage();
                    if (cbxPrintAfterSave.Checked)
                    {
                        if (spSetting.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decRejectionInIdToEdit);
                        }
                        else
                        {
                            Print(decRejectionInIdToEdit);
                        }
                    }
                    this.Close();

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("RI:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #6
0
        /// <summary>
        /// function to Rejection In updation
        /// </summary>
        public void RejectionInview()
        {
            decimal decRejectioInMasterId = 0;
            try
            {
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                isFromRejectionInRegister = true;
                RejectionInMasterSP SpRejectionInMaster = new RejectionInMasterSP();
                RejectionInMasterInfo InfoRejectionInMaster = new RejectionInMasterInfo();
                InfoRejectionInMaster = SpRejectionInMaster.RejectionInMasterView(decRejectionInIdToEdit);
                DeliveryNoteMasterSP SpDeliveryNoteMaster = new DeliveryNoteMasterSP();
                DeliveryNoteMasterInfo InfoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
                InfoDeliveryNoteMaster = SpDeliveryNoteMaster.DeliveryNoteMasterView(InfoRejectionInMaster.DeliveryNoteMasterId);
                strRejectionInVoucherNo = SpRejectionInMaster.GetRejectionInVoucherNo(InfoRejectionInMaster.RejectionInMasterId);
                decRejectionInVoucherTypeId = InfoRejectionInMaster.VoucherTypeId;
                decRejectionInSuffixPrefixId = InfoRejectionInMaster.SuffixPrefixId;
                strVoucherNo = InfoRejectionInMaster.VoucherNo;
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decRejectionInVoucherTypeId);

                if (!isAutomatic)
                {
                    txtRejectionInNo.ReadOnly = false;
                    txtRejectionInNo.Focus();
                }
                else
                {
                    txtRejectionInNo.ReadOnly = true;
                    txtDate.Focus();
                }
                txtRejectionInNo.Text = InfoRejectionInMaster.InvoiceNo;
                txtDate.Text = InfoRejectionInMaster.Date.ToString("dd-MMM-yyyy");
                dtpDate.Value = Convert.ToDateTime(txtDate.Text);
                cmbCashorParty.SelectedValue = InfoRejectionInMaster.LedgerId;
                cmbVoucherType.SelectedValue = InfoDeliveryNoteMaster.VoucherTypeId;
                cmbPricingLevel.SelectedValue = InfoRejectionInMaster.PricinglevelId;
                cmbDeliveryNoteNo.SelectedValue = InfoRejectionInMaster.DeliveryNoteMasterId;
                cmbSalesMan.SelectedValue = InfoRejectionInMaster.EmployeeId;
                cmbCurrency.SelectedValue = InfoRejectionInMaster.ExchangeRateId;
                txtTransportationCompany.Text = InfoRejectionInMaster.TransportationCompany;
                txtNarration.Text = InfoRejectionInMaster.Narration;
                txtLRNo.Text = InfoRejectionInMaster.LrNo;
                txtTotalAmount.Text = Convert.ToString(InfoRejectionInMaster.TotalAmount);
                RejectionInDetailsSP SpRejectionInDetails = new RejectionInDetailsSP();
                DataTable dtblRejectionInDetails = SpRejectionInDetails.RejectionInDetailsViewByRejectionInMasterId(decRejectionInIdToEdit);
                decRejectioInMasterId = Convert.ToDecimal(dtblRejectionInDetails.Rows[0]["voucherTypeId"].ToString());
                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                infoVoucherType = spVoucherType.VoucherTypeView(decRejectioInMasterId);
                this.Text = infoVoucherType.VoucherTypeName;
                foreach (DataRow drRejectionInDetails in dtblRejectionInDetails.Rows)
                {
                    isDoCellValueChange = false;
                    DGVGodownComboFill();
                    dgvProduct.Rows.Add();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtProductId"].Value = drRejectionInDetails["productId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxDeliveryNoteDetailsId"].Value = drRejectionInDetails.ItemArray[2].ToString();
                    AssignProductDefaultValues(dgvProduct.Rows.Count - 1, Convert.ToDecimal(drRejectionInDetails.ItemArray[3].ToString()));
                    DGVBatchComboFill(dgvProduct.Rows.Count - 1, Convert.ToDecimal(drRejectionInDetails.ItemArray[3].ToString()));
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtQuantity"].Value = drRejectionInDetails["qty"].ToString();
                    isDoCellValueChange = true;
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drRejectionInDetails["unitId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drRejectionInDetails["unitconversionId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(drRejectionInDetails["godownId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbRack"].Value = Convert.ToDecimal(drRejectionInDetails["rackId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drRejectionInDetails["batchId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtRate"].Value = drRejectionInDetails["rate"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtAmount"].Value = drRejectionInDetails["amount"].ToString();
                    dgvProduct.CurrentCell = null;
                }
                SerialNo();
                CalcTotalAmt();
                isDoCellValueChange = true;
                isDoAfterGridFill = true;
                isFromRejectionInRegister = false;
               
            }
            catch (Exception ex)
            {
                MessageBox.Show("RI:35" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);              
            }
        }