Пример #1
0
        /// <summary>
        /// Function to fill the details for edit or delete
        /// </summary>
        public void FillRegisterOrReport()
        {
            SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP();
            TransactionsGeneralFill transactionGeneralFillObj = new TransactionsGeneralFill();
            SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
            SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
            ProductSP SpProduct = new ProductSP();
            try
            {
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                IsDoAfterFill = false;
                IsCellValue = false;
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                infoSalesQuotationMaster = SpSalesQuotationMaster.SalesQuotationMasterView(decSalesquotationMasterId);
                txtQuotationNo.Text = infoSalesQuotationMaster.InvoiceNo;
                strVoucherNo = infoSalesQuotationMaster.VoucherNo.ToString();
                decSalesQuotationPreffixSuffixId = Convert.ToDecimal(infoSalesQuotationMaster.SuffixPrefixId);
                decSalesQuotationVoucherId = Convert.ToDecimal(infoSalesQuotationMaster.VoucherTypeId);
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decSalesQuotationVoucherId);
                decsalesQuotationTypeId = decSalesQuotationVoucherId;
                txtSalesQuotationDate.Text = infoSalesQuotationMaster.Date.ToString("dd-MMM-yyyy");
                cmbCashOrParty.SelectedValue = infoSalesQuotationMaster.LedgerId;
                ComboSalesManFill();
                cmbSalesman.SelectedValue = infoSalesQuotationMaster.EmployeeId;
                txtNarration.Text = infoSalesQuotationMaster.Narration;
                cmbCurrency.SelectedValue = infoSalesQuotationMaster.ExchangeRateId;
                decimal decsalesregisterTotal = Convert.ToDecimal(infoSalesQuotationMaster.TotalAmount.ToString());
                decsalesregisterTotal = Math.Round(decsalesregisterTotal, PublicVariables._inNoOfDecimalPlaces);
                txtTotal.Text = Convert.ToString(decsalesregisterTotal);
                cmbPricinglevel.SelectedValue = infoSalesQuotationMaster.PricinglevelId;
                DataTable dtbl = new DataTable();
                dtbl = SpSalesQuotationDetails.SalesQuotationDetailsViewByMasterId(decSalesquotationMasterId);
                if (isAutomatic)
                {
                    txtQuotationNo.ReadOnly = true;
                    txtSalesQuotationDate.Focus();
                }
                else
                {
                    txtQuotationNo.ReadOnly = false;
                    txtQuotationNo.Focus();
                }
                string strApproved = Convert.ToString(infoSalesQuotationMaster.Approved);
                if (strApproved == "False")
                {
                    cbxApproved.Checked = false;
                }
                else
                {
                    cbxApproved.Checked = true;
                }

                decimal decCount = SpSalesQuotationMaster.CheckingStastusForSalesQuotation(decSalesquotationMasterId);
                if (decCount > 0)
                {
                    cbxApproved.Enabled = false;
                }
                else
                {
                    cbxApproved.Enabled = true;
                }
                for (int i = 0; i < dtbl.Rows.Count; i++)
                {
                    isAmountcalc = false;

                    dgvProduct.Rows.Add();

                    dgvProduct.Rows[i].HeaderCell.Value = string.Empty;
                    dgvProduct.Rows[i].Cells["dgvtxtQuotationDetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["quotationDetailsId"].ToString());
                    dgvProduct.Rows[i].Cells["ProductId"].Value = dtbl.Rows[i]["productId"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = dtbl.Rows[i]["Barcode"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = dtbl.Rows[i]["productCode"].ToString();
                    transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, dtbl.Rows[i]["productId"].ToString(), i);
                    SpSalesQuotationMaster.SalesQuotationMasterBatchFill(dgvProduct, Convert.ToDecimal(dtbl.Rows[i]["productId"].ToString()), i);
                    dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = dtbl.Rows[i]["productName"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = dtbl.Rows[i]["qty"].ToString();
                    IsCellValue = true;
                    dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitId"].ToString());
                    IsCellValue = false;
                    dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = dtbl.Rows[i]["rate"].ToString();
                    IsCellValue = true;
                    dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = dtbl.Rows[i]["amount"].ToString();
                    IsCellValue = false;
                    dgvProduct.Rows[i].Cells["dgvcmbbatch"].Value = Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString());

                    UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                    DataTable dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[i].Cells["ProductId"].Value.ToString());
                    if (dtblUnitByProduct.Rows.Count > 0)
                    {
                        foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                        {
                            if (dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                            {
                                dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                                
                            }
                        }
                    }

                    decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(Convert.ToDecimal(dtbl.Rows[i]["productId"].ToString()), PublicVariables._dtCurrentDate, Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString()), Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces);
                    if (dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty)
                    {
                        if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value) != 0)
                        {
                            dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces);
                        }
                    }


                }
                isAmountcalc = true;
                IsCellValue = true;
                IsDoAfterFill = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:39" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }