Example #1
0
        /// <summary>
        /// Function to insert values to SalesQuotationMaster Table
        /// </summary>
        /// <param name="salesquotationmasterinfo"></param>
        /// <returns></returns>
        public decimal SalesQuotationMasterAdd(SalesQuotationMasterInfo salesquotationmasterinfo)
        {
            decimal decSalesQuotationmasterIdentity = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("SalesQuotationMasterAdd", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value = salesquotationmasterinfo.VoucherNo;
                sprmparam       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value = salesquotationmasterinfo.InvoiceNo;
                sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.VoucherTypeId;
                sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.SuffixPrefixId;
                sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = salesquotationmasterinfo.Date;
                sprmparam       = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.PricinglevelId;
                sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.LedgerId;
                sprmparam       = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.EmployeeId;
                sprmparam       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.userId;
                sprmparam       = sccmd.Parameters.Add("@approved", SqlDbType.Bit);
                sprmparam.Value = salesquotationmasterinfo.Approved;
                sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.TotalAmount;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = salesquotationmasterinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.FinancialYearId;
                sprmparam       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
                sprmparam.Value = salesquotationmasterinfo.ExchangeRateId;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = salesquotationmasterinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = salesquotationmasterinfo.Extra2;
                decSalesQuotationmasterIdentity = Convert.ToDecimal(sccmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decSalesQuotationmasterIdentity);
        }
 /// <summary>
 /// Function to insert values to SalesQuotationMaster Table
 /// </summary>
 /// <param name="salesquotationmasterinfo"></param>
 /// <returns></returns>
 public decimal SalesQuotationMasterAdd(SalesQuotationMasterInfo salesquotationmasterinfo)
 {
     decimal decSalesQuotationmasterIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalesQuotationMasterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = salesquotationmasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = salesquotationmasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = salesquotationmasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.PricinglevelId;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.EmployeeId;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.userId;
         sprmparam = sccmd.Parameters.Add("@approved", SqlDbType.Bit);
         sprmparam.Value = salesquotationmasterinfo.Approved;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = salesquotationmasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = salesquotationmasterinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = salesquotationmasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = salesquotationmasterinfo.Extra2;
         decSalesQuotationmasterIdentity = Convert.ToDecimal(sccmd.ExecuteScalar());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decSalesQuotationmasterIdentity;
 }
Example #3
0
        /// <summary>
        /// Function to get particular values from SalesQuotationMaster table based on the parameter
        /// </summary>
        /// <param name="quotationMasterId"></param>
        /// <returns></returns>
        public SalesQuotationMasterInfo SalesQuotationMasterView(decimal quotationMasterId)
        {
            SalesQuotationMasterInfo salesquotationmasterinfo = new SalesQuotationMasterInfo();
            SqlDataReader            sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("SalesQuotationMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@quotationMasterId", SqlDbType.Decimal);
                sprmparam.Value = quotationMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    salesquotationmasterinfo.QuotationMasterId = Convert.ToDecimal(sdrreader[0].ToString());
                    salesquotationmasterinfo.VoucherNo         = sdrreader[1].ToString();
                    salesquotationmasterinfo.InvoiceNo         = sdrreader[2].ToString();
                    salesquotationmasterinfo.VoucherTypeId     = Convert.ToDecimal(sdrreader[3].ToString());
                    salesquotationmasterinfo.SuffixPrefixId    = Convert.ToDecimal(sdrreader[4].ToString());
                    salesquotationmasterinfo.Date            = DateTime.Parse(sdrreader[5].ToString());
                    salesquotationmasterinfo.PricinglevelId  = Convert.ToDecimal(sdrreader[6].ToString());
                    salesquotationmasterinfo.LedgerId        = Convert.ToDecimal(sdrreader[7].ToString());
                    salesquotationmasterinfo.EmployeeId      = Convert.ToDecimal(sdrreader[8].ToString());
                    salesquotationmasterinfo.Approved        = bool.Parse(sdrreader[9].ToString());
                    salesquotationmasterinfo.TotalAmount     = Convert.ToDecimal(sdrreader[10].ToString());
                    salesquotationmasterinfo.Narration       = sdrreader[11].ToString();
                    salesquotationmasterinfo.FinancialYearId = Convert.ToDecimal(sdrreader[12].ToString());
                    salesquotationmasterinfo.ExchangeRateId  = Convert.ToDecimal(sdrreader[13].ToString());
                    salesquotationmasterinfo.Extra1          = sdrreader[14].ToString();
                    salesquotationmasterinfo.Extra2          = sdrreader[15].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(salesquotationmasterinfo);
        }
Example #4
0
        /// <summary>
        /// To fill the details according to the DeliveryNote master Id from frmDeliveryNoteRegister and frmDeliveryNoteReport
        /// </summary>
        public void FillRegisterOrReport()
        {
            try
            {
                DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP();
                DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP();
                SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
                SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
                SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
                SalesQuotationMasterSP spSalesQuotationMaster = new SalesQuotationMasterSP();
                dgvProduct.Rows.Clear();
                isRegisterReportFill = true;
                btnSave.Text = "Update";
                int inRowIndex = 0;
                btnDelete.Enabled = true;
                txtDeliveryNoteNo.ReadOnly = true;
                if (txtDeliveryNoteNo.ReadOnly == true)
                {
                    txtDate.Focus();
                }
                else
                {
                    txtDeliveryNoteNo.Focus();
                }

                infoDeliveryNoteMaster = spDeliveryNoteMaster.DeliveryNoteMasterViewAllByMasterId(decDelivryNoteIdToEdit);
                txtDeliveryNoteNo.Text = infoDeliveryNoteMaster.InvoiceNo;
                strVoucherNo = infoDeliveryNoteMaster.VoucherNo.ToString();
                decDeliveryNoteSuffixPrefixId = Convert.ToDecimal(infoDeliveryNoteMaster.SuffixPrefixId);
                decDeliveryNoteVoucherTypeId = Convert.ToDecimal(infoDeliveryNoteMaster.VoucherTypeId);
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decDeliveryNoteVoucherTypeId);
                decDeliveryNoteTypeId = decDeliveryNoteVoucherTypeId;
                cmbCashOrParty.SelectedValue = infoDeliveryNoteMaster.LedgerId;
                txtDate.Text = infoDeliveryNoteMaster.Date.ToString("dd-MMM-yyyy");
                cmbPricingLevel.SelectedValue = infoDeliveryNoteMaster.PricinglevelId;
                infoVoucherType = spVoucherType.VoucherTypeView(decDeliveryNoteVoucherTypeId);
                this.Text = infoVoucherType.VoucherTypeName;
                if (infoDeliveryNoteMaster.OrderMasterId != 0)
                {
                    cmbDeliveryMode.Text = "Against Order";
                    infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId);
                    cmbType.SelectedValue = infoSalesOrderMaster.VoucherTypeId;
                    AgainstOrderComboFill();
                    cmbOrderNo.SelectedValue = infoDeliveryNoteMaster.OrderMasterId;
                }
                else if (infoDeliveryNoteMaster.QuotationMasterId != 0)
                {
                    cmbDeliveryMode.Text = "Against Quotation";
                    infoSalesQuotationMaster = spSalesQuotationMaster.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId);
                    cmbType.SelectedValue = infoSalesQuotationMaster.VoucherTypeId;
                    AgainstQuotationComboFill();
                    cmbOrderNo.SelectedValue = infoDeliveryNoteMaster.QuotationMasterId;
                }
                CurrencyComboFill();
                cmbSalesMan.SelectedValue = infoDeliveryNoteMaster.EmployeeId;
                cmbCurrency.SelectedValue = infoDeliveryNoteMaster.ExchangeRateId;
                txtTraspotationCompany.Text = infoDeliveryNoteMaster.TransportationCompany;
                txtNarration.Text = infoDeliveryNoteMaster.Narration;
                txtLRNo.Text = infoDeliveryNoteMaster.LrNo;
                txtTotalAmnt.Text = infoDeliveryNoteMaster.TotalAmount.ToString("00.00");
                DataTable dtblDetails = spDeliveryNoteDetails.DeliveryNoteDetailsViewByDeliveryNoteMasterId(decDelivryNoteIdToEdit);
                foreach (DataRow drowDetails in dtblDetails.Rows)
                {
                    dgvProduct.Rows.Add();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true;
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtDetailsId"].Value = drowDetails["deliveryNoteDetailsId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherNo"].Value = drowDetails["VoucherNo"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtInvoiceNo"].Value = drowDetails["OrderNoOrQuotationNo"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherTypeId"].Value = drowDetails["VoucherTypeId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = drowDetails["productCode"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].Value = drowDetails["productName"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["Col"].Value = drowDetails["slNo"].ToString();
                    if (Convert.ToDecimal(drowDetails["orderDetails1Id"].ToString()) == 0)
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = 0;
                    }
                    else
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = Convert.ToDecimal(drowDetails["orderDetails1Id"].ToString());
                    }
                    if (Convert.ToDecimal(drowDetails["quotationDetails1Id"].ToString()) != 0)
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = Convert.ToDecimal(drowDetails["quotationDetails1Id"].ToString());
                    }
                    BatchComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
                    UnitComboFill1(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                    GridGodownComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(drowDetails["godownId"].ToString());
                    RackComboFill1(Convert.ToDecimal(drowDetails["godownId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtQty"].Value = drowDetails["qty"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value = drowDetails["rate"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = drowDetails["unitConversionId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = drowDetails["conversionRate"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtAmount"].Value = drowDetails["amount"].ToString();
                    if (cmbOrderNo.Visible == true)
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true;
                    }
                    if (spDeliveryNoteMaster.DeliveryNoteMasterReferenceCheckRejectionIn(decDelivryNoteIdToEdit))
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true;
                    }
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].HeaderCell.Value = "";
                    AmountCalculation("dgvtxtQty", inRowIndex);
                    TotalAmountCalculation();
                }
                if (!isAutomatic)
                {
                    txtDeliveryNoteNo.ReadOnly = false;
                    txtDeliveryNoteNo.Focus();
                }
                isRegisterReportFill = false;
                isDoAfterGridFill = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN19: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #5
0
        /// <summary>
        /// Save Function
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
                DeliveryNoteDetailsInfo infoDeliveryNoteDetails = new DeliveryNoteDetailsInfo();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                StockPostingSP spStockPosting = new StockPostingSP();
                DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP();
                DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP();
                SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
                SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
                SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
                SalesQuotationMasterSP spSalesQuotationMaster = new SalesQuotationMasterSP();
                infoDeliveryNoteMaster.InvoiceNo = txtDeliveryNoteNo.Text;
                infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId;
                infoDeliveryNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoDeliveryNoteMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                infoDeliveryNoteMaster.VoucherNo = strVoucherNo;
                infoDeliveryNoteMaster.SuffixPrefixId = decDeliveryNoteSuffixPrefixId;
                if (btnSave.Text == "Save")
                {
                    if (cmbOrderNo.SelectedValue != null)
                    {
                        if (cmbDeliveryMode.Text == "Against Order")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "Against Quotation")
                        {
                            infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesQuotationMaster = spSalesQuotationMaster.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "NA")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0;
                        }
                    }
                    else
                    {
                        infoDeliveryNoteMaster.OrderMasterId = 0;
                        infoDeliveryNoteMaster.QuotationMasterId = 0;
                    }
                    infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
                    if (cmbSalesMan.SelectedIndex != -1)
                    {
                        infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
                    }
                    else
                    {
                        infoDeliveryNoteMaster.EmployeeId = 0;
                    }
                    infoDeliveryNoteMaster.Narration = txtNarration.Text;
                    infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text);
                    infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId;
                    infoDeliveryNoteMaster.LrNo = txtLRNo.Text;
                    infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text;
                    infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoDeliveryNoteMaster.Extra1 = string.Empty;
                    infoDeliveryNoteMaster.Extra2 = string.Empty;
                    infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                    if (decDelivryNoteIdToEdit == 0)
                    {
                        decDeliveryNoteMasterId = Convert.ToDecimal(spDeliveryNoteMaster.DeliveryNoteMasterAdd(infoDeliveryNoteMaster));
                    }
                    int inRowcount = dgvProduct.Rows.Count;
                    for (int inI = 0; inI < inRowcount - 1; inI++)
                    {
                        if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null)
                        {
                            if (cmbDeliveryMode.Text == "Against Order")
                            {
                                if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null)
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                    infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                                }
                            }
                            else if (cmbDeliveryMode.Text == "Against Quotation")
                            {
                                if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null)
                                {
                                    infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                    infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                                }
                            }
                            else if (cmbDeliveryMode.Text == "NA")
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                            }
                        }
                        else
                        {
                            if (cmbOrderNo.SelectedText != string.Empty)
                            {
                                if (cmbDeliveryMode.Text == "Against Order")
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else if (cmbDeliveryMode.Text == "Against Quotation")
                                {
                                    infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                                }
                                else if (cmbDeliveryMode.Text == "NA")
                                {
                                    infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                    infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                                }
                            }
                            else
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                            }
                        }
                        infoDeliveryNoteDetails.ProductId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtProductId"].Value.ToString());
                        infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
                        infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                        infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                        infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                        infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
                        infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString());
                        infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
                        infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString());
                        infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString());
                        infoDeliveryNoteDetails.Extra1 = string.Empty;
                        infoDeliveryNoteDetails.Extra2 = string.Empty;
                        if (decDelivryNoteIdToEdit == 0)
                        {
                            infoDeliveryNoteDetails.DeliveryNoteMasterId = decDeliveryNoteMasterId;
                            spDeliveryNoteDetails.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails);
                        }
                        else
                        {
                            infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit;
                            spDeliveryNoteDetails.DeliveryNoteDetailsEdit(infoDeliveryNoteDetails);
                        }
                        infoStockPosting.Date = Convert.ToDateTime(txtDate.Text);
                        if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null)
                        {
                            if (cmbDeliveryMode.SelectedItem.ToString() != "NA")
                            {
                                if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null)
                                {
                                    infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value);
                                }
                                else
                                {
                                    infoStockPosting.VoucherTypeId = 0;
                                }
                                if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value != null)
                                {
                                    infoStockPosting.VoucherNo = dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value.ToString();
                                }
                                else
                                {
                                    infoStockPosting.VoucherNo = string.Empty;
                                }
                                if (dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value != null)
                                {
                                    infoStockPosting.InvoiceNo = dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value.ToString();
                                }
                                else
                                {
                                    infoStockPosting.InvoiceNo = string.Empty;
                                }
                                if (decDeliveryNoteVoucherTypeId != 0)
                                {
                                    infoStockPosting.AgainstVoucherTypeId = decDeliveryNoteVoucherTypeId;
                                }
                                else
                                {
                                    infoStockPosting.AgainstVoucherTypeId = 0;
                                }
                                if (strVoucherNo != string.Empty)
                                {
                                    infoStockPosting.AgainstVoucherNo = strVoucherNo;
                                }
                                else
                                {
                                    infoStockPosting.AgainstVoucherNo = string.Empty;
                                }
                                if (txtDeliveryNoteNo.Text != string.Empty)
                                {
                                    infoStockPosting.AgainstInvoiceNo = txtDeliveryNoteNo.Text;
                                }
                                else
                                {
                                    infoStockPosting.AgainstInvoiceNo = string.Empty;
                                }
                            }
                        }
                        else
                        {
                            infoStockPosting.InvoiceNo = txtDeliveryNoteNo.Text;
                            infoStockPosting.VoucherNo = strVoucherNo;
                            infoStockPosting.VoucherTypeId = decDeliveryNoteVoucherTypeId;
                            infoStockPosting.AgainstVoucherTypeId = 0;
                            infoStockPosting.AgainstVoucherNo = "NA";
                            infoStockPosting.AgainstInvoiceNo = "NA";
                        }
                        infoStockPosting.ProductId = infoDeliveryNoteDetails.ProductId;
                        infoStockPosting.BatchId = infoDeliveryNoteDetails.BatchId;
                        infoStockPosting.UnitId = infoDeliveryNoteDetails.UnitId;
                        infoStockPosting.GodownId = infoDeliveryNoteDetails.GodownId;
                        infoStockPosting.RackId = infoDeliveryNoteDetails.RackId;
                        infoStockPosting.OutwardQty = infoDeliveryNoteDetails.Qty;
                        infoStockPosting.Rate = infoDeliveryNoteDetails.Rate;
                        infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                        infoStockPosting.Extra1 = string.Empty;
                        infoStockPosting.Extra2 = string.Empty;
                        spStockPosting.StockPostingAdd(infoStockPosting);
                    }
                    Messages.SavedMessage();
                    if (cbxPrint.Checked)
                    {
                        SettingsSP spSettings = new SettingsSP();
                        if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decDeliveryNoteMasterId);
                        }
                        else
                        {
                            Print(decDeliveryNoteMasterId);
                        }
                    }
                }
                if (btnSave.Text == "Update")
                {
                    SettingsSP spSettings = new SettingsSP();
                    infoDeliveryNoteMaster.DeliveryNoteMasterId = decDelivryNoteIdToEdit;
                    infoDeliveryNoteMaster.SuffixPrefixId = Convert.ToDecimal(decDeliveryNoteSuffixPrefixId);
                    infoDeliveryNoteMaster.VoucherNo = strVoucherNo;
                    infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid
                    infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
                    if (cmbSalesMan.SelectedIndex != -1)
                    {
                        infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
                    }
                    else
                    {
                        infoDeliveryNoteMaster.EmployeeId = 0;
                    }
                    infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                    if (cmbOrderNo.SelectedValue != null)
                    {
                        if (cmbDeliveryMode.Text == "Against Order")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "Against Quotation")
                        {
                            infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            infoSalesQuotationMaster = spSalesQuotationMaster.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId);
                        }
                        else if (cmbDeliveryMode.Text == "NA")
                        {
                            infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0;
                        }
                    }
                    else
                    {
                        infoDeliveryNoteMaster.OrderMasterId = 0;
                        infoDeliveryNoteMaster.QuotationMasterId = 0;
                    }
                    infoDeliveryNoteMaster.Narration = txtNarration.Text.Trim();
                    infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                    infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text);
                    infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text;
                    infoDeliveryNoteMaster.LrNo = txtLRNo.Text;
                    infoDeliveryNoteMaster.Extra1 = string.Empty;
                    infoDeliveryNoteMaster.Extra2 = string.Empty;
                    spDeliveryNoteMaster.DeliveryNoteMasterEdit(infoDeliveryNoteMaster);
                    RemoveDeliveryNoteDetails();
                    infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId;
                    spDeliveryNoteMaster.StockPostDeletingForDeliveryNote(decDeliveryNoteVoucherTypeId, strVoucherNo, txtDeliveryNoteNo.Text);
                    DeliveryNoteDetails();
                    Messages.UpdatedMessage();
                    if (frmDeliveryNoteRegisterObj != null)
                    {
                        if (cbxPrint.Checked)
                        {
                            if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decDelivryNoteIdToEdit);
                            }
                            else
                            {
                                Print(decDelivryNoteIdToEdit);
                            }
                        }
                        frmDeliveryNoteRegisterObj.GridFill();
                    }
                    if (frmDeliveryNoteReportObj != null)
                    {
                        if (cbxPrint.Checked)
                        {
                            if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decDelivryNoteIdToEdit);
                            }
                            else
                            {
                                Print(decDelivryNoteIdToEdit);
                            }
                        }
                        frmDeliveryNoteReportObj.GridFill();
                    }
                    this.Close();
                }
                Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #6
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);
            }
        }
Example #7
0
 /// <summary>
 /// Function to edit the SalesQuatation
 /// </summary>
 public void EditFunction()
 {
     SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP();
     SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
     SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
     SettingsSP spSettings = new SettingsSP();
     try
     {
         for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++)
         {
             if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtquotationDetailsId"].Value) != 0)
             {
                 isEditDetails = Convert.ToString(SpSalesQuotationDetails.SalesQuotationRefererenceCheckForEditDetails(Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtquotationDetailsId"].Value)));
             }
         }
         isEditMaster = Convert.ToString(SpSalesQuotationMaster.SalesQuotationRefererenceCheckForEditMaster(decSalesquotationMasterId));
         if (isEditMaster == "False" && isEditDetails == "False")
         {
             infoSalesQuotationMaster.QuotationMasterId = decSalesquotationMasterId;
             infoSalesQuotationMaster.Date = Convert.ToDateTime(txtSalesQuotationDate.Text);
             infoSalesQuotationMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
             infoSalesQuotationMaster.SuffixPrefixId = Convert.ToDecimal(decSalesQuotationPreffixSuffixId);
             infoSalesQuotationMaster.VoucherNo = strVoucherNo;
             infoSalesQuotationMaster.VoucherTypeId = decSalesQuotationVoucherId;
             infoSalesQuotationMaster.InvoiceNo = txtQuotationNo.Text;
             infoSalesQuotationMaster.userId = PublicVariables._decCurrentUserId;//by default current userid used as current user id
             infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString());
             infoSalesQuotationMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
             infoSalesQuotationMaster.Narration = txtNarration.Text.Trim();
             infoSalesQuotationMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
             infoSalesQuotationMaster.PricinglevelId = Convert.ToDecimal(cmbPricinglevel.SelectedValue.ToString());
             infoSalesQuotationMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
             if (cbxApproved.Checked)
             {
                 infoSalesQuotationMaster.Approved = true;
             }
             else
             {
                 infoSalesQuotationMaster.Approved = false;
             }
             infoSalesQuotationMaster.Extra1 = string.Empty;
             infoSalesQuotationMaster.Extra2 = string.Empty;
             SpSalesQuotationMaster.SalesQuotationMasterEdit(infoSalesQuotationMaster);
             RemoveSalesQuotationDetails();
             NewRowAddedToSalesQuotationDetails();
             SalesQuotationDetailsEditFill();
             Messages.UpdatedMessage();
             if (frmSalesQuotationRegisterObj != null)
             {
                 if (cbxPrintAfterSave.Checked)
                 {
                     if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesquotationMasterId);
                     }
                     else
                     {
                         Print(decSalesquotationMasterId);
                     }
                 }
                 this.Close();
                 frmSalesQuotationRegisterObj.GridFill();
             }
             if (frmSalesQuotationReportObj != null)
             {
                 if (cbxPrintAfterSave.Checked)
                 {
                     if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesquotationMasterId);
                     }
                     else
                     {
                         Print(decSalesquotationMasterId);
                     }
                 }
                 this.Close();
                 frmSalesQuotationReportObj.GridFill();
             }
             if (frmDayBookObj != null)
             {
                 if (cbxPrintAfterSave.Checked)
                 {
                     if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesquotationMasterId);
                     }
                     else
                     {
                         Print(decSalesquotationMasterId);
                     }
                 }
                 this.Close();
             }
             if (objfrmVoucherSearch != null)
             {
                 if (cbxPrintAfterSave.Checked)
                 {
                     if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesquotationMasterId);
                     }
                     else
                     {
                         Print(decSalesquotationMasterId);
                     }
                 }
                 this.Close();
             }
             if (objVoucherSearch != null)
             {
                 if (cbxPrintAfterSave.Checked)
                 {
                     if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesquotationMasterId);
                     }
                     else
                     {
                         Print(decSalesquotationMasterId);
                     }
                 }
                 this.Close();
             }
             
         }
         else
         {
             Messages.ReferenceExistsMessageForUpdate();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:33" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #8
0
 /// <summary>
 /// Function to save the sales quatation
 /// </summary>
 public void SaveFunction()
 {
     SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP();
     SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
     SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
     SalesQuotationDetailsInfo infoSalesQuotationDetails = new SalesQuotationDetailsInfo();
     SettingsSP spSettings = new SettingsSP();
     ProductSP spProduct = new ProductSP();
     ProductInfo infoproduct = new ProductInfo();
     try
     {
         infoSalesQuotationMaster.Date = Convert.ToDateTime(txtSalesQuotationDate.Text);
         infoSalesQuotationMaster.PricinglevelId = Convert.ToDecimal(cmbPricinglevel.SelectedValue.ToString());
         infoSalesQuotationMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString());
         if (isAutomatic)
         {
             infoSalesQuotationMaster.SuffixPrefixId = decSalesQuotationPreffixSuffixId;
             infoSalesQuotationMaster.VoucherNo = strSalesQuotationNo;
         }
         else
         {
             infoSalesQuotationMaster.SuffixPrefixId = 0;
             infoSalesQuotationMaster.VoucherNo = SpSalesQuotationMaster.VoucherNoMax(decsalesQuotationTypeId);
         }
         infoSalesQuotationMaster.VoucherTypeId = decsalesQuotationTypeId;
         infoSalesQuotationMaster.InvoiceNo = txtQuotationNo.Text;
         infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString());
         infoSalesQuotationMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         infoSalesQuotationMaster.userId = PublicVariables._decCurrentUserId;
         infoSalesQuotationMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
         infoSalesQuotationMaster.Narration = txtNarration.Text.Trim();
         infoSalesQuotationMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoSalesQuotationMaster.Extra1 = string.Empty;
         infoSalesQuotationMaster.Extra2 = string.Empty;
         if (cbxApproved.Checked)
         {
             infoSalesQuotationMaster.Approved = true;
         }
         else
         {
             infoSalesQuotationMaster.Approved = false;
         }
         decSalesQuotationmasterIdentity = Convert.ToDecimal(SpSalesQuotationMaster.SalesQuotationMasterAdd(infoSalesQuotationMaster));
         int inRowcount = dgvProduct.Rows.Count;
         for (int inI = 0; inI < inRowcount - 1; inI++)
         {
             infoSalesQuotationDetails.QuotationMasterId = decSalesQuotationmasterIdentity;
             if (dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty)
             {
                 infoproduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                 infoSalesQuotationDetails.ProductId = infoproduct.ProductId;
             }
             if (dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
             }
             if (dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                 decimal unitConversion = SpSalesQuotationDetails.UnitconversionIdViewByUnitIdAndProductId(infoSalesQuotationDetails.UnitId, infoSalesQuotationDetails.ProductId);
                 infoSalesQuotationDetails.UnitConversionId = unitConversion;
             }
             if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value);
             }
             else
             {
                 infoSalesQuotationDetails.BatchId = 0;
             }
             infoSalesQuotationDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
             infoSalesQuotationDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
             infoSalesQuotationDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
             infoSalesQuotationDetails.Extra1 = string.Empty;
             infoSalesQuotationDetails.Extra2 = string.Empty;
             SpSalesQuotationDetails.SalesQuotationDetailsAdd(infoSalesQuotationDetails);
         }
         Messages.SavedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             if (dgvProduct.Rows.Count > 0)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decSalesQuotationmasterIdentity);
                 }
                 else
                 {
                     Print(decSalesQuotationmasterIdentity);
                 }
             }
             else
             {
                 Messages.InformationMessage("No data found");
             }
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:32" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to get particular values from SalesQuotationMaster table based on the parameter
 /// </summary>
 /// <param name="quotationMasterId"></param>
 /// <returns></returns>
 public SalesQuotationMasterInfo SalesQuotationMasterView(decimal quotationMasterId)
 {
     SalesQuotationMasterInfo salesquotationmasterinfo = new SalesQuotationMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalesQuotationMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@quotationMasterId", SqlDbType.Decimal);
         sprmparam.Value = quotationMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             salesquotationmasterinfo.QuotationMasterId = Convert.ToDecimal(sdrreader[0].ToString());
             salesquotationmasterinfo.VoucherNo = sdrreader[1].ToString();
             salesquotationmasterinfo.InvoiceNo = sdrreader[2].ToString();
             salesquotationmasterinfo.VoucherTypeId = Convert.ToDecimal(sdrreader[3].ToString());
             salesquotationmasterinfo.SuffixPrefixId = Convert.ToDecimal(sdrreader[4].ToString());
             salesquotationmasterinfo.Date = DateTime.Parse(sdrreader[5].ToString());
             salesquotationmasterinfo.PricinglevelId = Convert.ToDecimal(sdrreader[6].ToString());
             salesquotationmasterinfo.LedgerId = Convert.ToDecimal(sdrreader[7].ToString());
             salesquotationmasterinfo.EmployeeId = Convert.ToDecimal(sdrreader[8].ToString());
             salesquotationmasterinfo.Approved = bool.Parse(sdrreader[9].ToString());
             salesquotationmasterinfo.TotalAmount = Convert.ToDecimal(sdrreader[10].ToString());
             salesquotationmasterinfo.Narration = sdrreader[11].ToString();
             salesquotationmasterinfo.FinancialYearId = Convert.ToDecimal(sdrreader[12].ToString());
             salesquotationmasterinfo.ExchangeRateId = Convert.ToDecimal(sdrreader[13].ToString());
             salesquotationmasterinfo.Extra1 = sdrreader[14].ToString();
             salesquotationmasterinfo.Extra2 = sdrreader[15].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return salesquotationmasterinfo;
 }
Example #10
0
 /// <summary>
 /// Function to use to fill details to updation when comes register or report
 /// </summary>
 public void FillRegisterOrReport()
 {
     try
     {
         SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
         SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
         SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
         SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
         isValueChange = false;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtOrderNo.ReadOnly = true;
         infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(decSalesOrderMasterId);
         txtOrderNo.Text = infoSalesOrderMaster.InvoiceNo;
         strVoucherNo = infoSalesOrderMaster.VoucherNo.ToString();
         decSalesSuffixPrefixId = Convert.ToDecimal(infoSalesOrderMaster.SuffixPrefixId);
         decSalesVoucherId = Convert.ToDecimal(infoSalesOrderMaster.VoucherTypeId);
         isAutomatic = new VoucherTypeSP().CheckMethodOfVoucherNumbering(decSalesVoucherId);
         decSalesOrderTypeId = decSalesVoucherId;
         txtDate.Text = infoSalesOrderMaster.Date.ToString("dd-MMM-yyyy");
         cmbCashOrParty.SelectedValue = infoSalesOrderMaster.LedgerId;
         decSalesOrderVoucherTypeId = infoSalesOrderMaster.VoucherTypeId;
         VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
         VoucherTypeSP spVoucherType = new VoucherTypeSP();
         infoVoucherType = spVoucherType.VoucherTypeView(decSalesOrderVoucherTypeId);
         string strVoucherTypeName = infoVoucherType.VoucherTypeName;
         this.Text = strVoucherTypeName;
         if (infoSalesOrderMaster.QuotationMasterId == 0)
         {
             cmbType.SelectedItem = "NA";
         }
         else if (infoSalesOrderMaster.QuotationMasterId != 0)
         {
             infoSalesQuotationMaster = new SalesQuotationMasterSP().SalesQuotationMasterView(infoSalesOrderMaster.QuotationMasterId);
             cmbType.SelectedValue = infoSalesQuotationMaster.VoucherTypeId;
             AgainstQuotationComboFill();
             cmbQuotationNo.SelectedValue = infoSalesOrderMaster.QuotationMasterId;
         }
         txtDueDate.Text = infoSalesOrderMaster.DueDate.ToString("dd-MMM-yyyy");
         TimeSpan objTs = Convert.ToDateTime(txtDueDate.Text).Subtract(Convert.ToDateTime(txtDate.Text));
         txtDueDays.Text = objTs.Days.ToString();
         txtNarration.Text = infoSalesOrderMaster.Narration;
         cmbCurrency.SelectedValue = infoSalesOrderMaster.ExchangeRateId;
         cmbPricingLevel.SelectedValue = infoSalesOrderMaster.PricinglevelId;
         SalesManComboFill();
         cmbSalesMan.SelectedValue = infoSalesOrderMaster.EmployeeId;
         txtTotalAmount.Text = infoSalesOrderMaster.TotalAmount.ToString();
         DataTable dtbl = new DataTable();
         dtbl = spSalesOrderDetails.SalesOrderDetailsViewByMasterId(decSalesOrderMasterId);
         if (CheckCancelStatus(decSalesOrderMasterId))
         {
             isCheck = true;
             cbxCancelled.Checked = true;
             cbxCancelled.Enabled = false;
             btnSave.Enabled = false;
             isCheck = false;
         }
         else
         {
             isCheck = true;
             cbxCancelled.Enabled = true;
             cbxCancelled.Checked = false;
             isCheck = false;
         }
         if (isAutomatic)
         {
             txtOrderNo.ReadOnly = true;
             txtDate.Focus();
         }
         else
         {
             txtOrderNo.ReadOnly = false;
             txtOrderNo.Focus();
         }
         for (int i = 0; i < dtbl.Rows.Count; i++)
         {
             isAmountcalc = false;
             isValueChange = false;
             dgvSalesOrder.Rows.Add();
             dgvSalesOrder.Rows[i].HeaderCell.Value = string.Empty;
             dgvSalesOrder.Rows[i].Cells["dgvtxtSalesOrderDetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["salesOrderDetailsId"].ToString());
             dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value = dtbl.Rows[i]["productId"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtProductCode"].Value = dtbl.Rows[i]["productCode"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtProductName"].Value = dtbl.Rows[i]["productName"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtQty"].Value = dtbl.Rows[i]["qty"].ToString();
             UnitComboFill(Convert.ToDecimal(dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value.ToString()), i, dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
             dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitId"].ToString());
             dgvSalesOrder.Rows[i].Cells["dgvtxtRate"].Value = dtbl.Rows[i]["rate"].ToString();
             BatchComboFill(Convert.ToDecimal(dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value.ToString()), i, dgvSalesOrder.Rows[i].Cells["dgvcmbBatch"].ColumnIndex);
             dgvSalesOrder.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString());
             dgvSalesOrder.Rows[i].Cells["dgvtxtBarcode"].Value = dtbl.Rows[i]["barcode"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtAmount"].Value = dtbl.Rows[i]["amount"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtUnitConversionId"].Value = dtbl.Rows[i]["unitConversionId"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtConversionRate"].Value = dtbl.Rows[i]["conversionRate"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtSalesQuotationDetailsId"].Value = dtbl.Rows[i]["quotationDetailsId"].ToString();
             if (Convert.ToDecimal(dtbl.Rows[i]["quotationDetailsId"].ToString()) != 0)
             {
                 dgvSalesOrder.Rows[i].Cells["dgvtxtProductCode"].ReadOnly = true;
                 dgvSalesOrder.Rows[i].Cells["dgvtxtProductName"].ReadOnly = true;
                 dgvSalesOrder.Rows[i].Cells["dgvtxtBarcode"].ReadOnly = true;
             }
             if (cmbQuotationNo.Visible == true)
             {
                 dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true;
             }
         }
         isAmountcalc = true;
         isEditFill = false;
         isValueChange = true;
         isDoAfterGridFill = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }