Пример #1
0
        /// <summary>
        /// Function for Tax View By ProductId
        /// </summary>
        /// <param name="strProductCode"></param>
        /// <returns></returns>
        public TaxInfo TaxViewByProductId(string strProductCode)
        {
            TaxInfo       taxInfo   = new TaxInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("TaxViewByProductId", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@productId", SqlDbType.VarChar);
                sprmparam.Value = strProductCode;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    taxInfo.TaxId   = Convert.ToDecimal(sdrreader["taxId"].ToString());
                    taxInfo.TaxName = sdrreader["taxName"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(taxInfo);
        }
Пример #2
0
        /// <summary>
        /// Function for insert values and return id
        /// </summary>
        /// <param name="taxinfo"></param>
        /// <returns></returns>
        public decimal TaxAddWithIdentity(TaxInfo taxinfo)
        {
            decimal decTaxId = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("TaxAddWithIdentity", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@taxName", SqlDbType.VarChar);
                sprmparam.Value = taxinfo.TaxName;
                sprmparam       = sccmd.Parameters.Add("@applicableOn", SqlDbType.VarChar);
                sprmparam.Value = taxinfo.ApplicableOn;
                sprmparam       = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
                sprmparam.Value = taxinfo.Rate;
                sprmparam       = sccmd.Parameters.Add("@calculatingMode", SqlDbType.VarChar);
                sprmparam.Value = taxinfo.CalculatingMode;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = taxinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@isActive", SqlDbType.Bit);
                sprmparam.Value = taxinfo.IsActive;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = taxinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = taxinfo.Extra2;
                object objTaxId = sccmd.ExecuteScalar();
                if (objTaxId != null)
                {
                    decTaxId = decimal.Parse(objTaxId.ToString());
                }
                else
                {
                    decTaxId = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decTaxId);
        }
Пример #3
0
        /// <summary>
        /// Function to get particular values from Tax Table based on the parameter
        /// </summary>
        /// <param name="taxId"></param>
        /// <returns></returns>
        public TaxInfo TaxView(decimal taxId)
        {
            TaxInfo       taxinfo   = new TaxInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("TaxView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@taxId", SqlDbType.Decimal);
                sprmparam.Value = taxId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    taxinfo.TaxId           = decimal.Parse(sdrreader[0].ToString());
                    taxinfo.TaxName         = sdrreader[1].ToString();
                    taxinfo.ApplicableOn    = sdrreader[2].ToString();
                    taxinfo.Rate            = decimal.Parse(sdrreader[3].ToString());
                    taxinfo.CalculatingMode = sdrreader[4].ToString();
                    taxinfo.Narration       = sdrreader[5].ToString();
                    taxinfo.IsActive        = bool.Parse(sdrreader[6].ToString());
                    taxinfo.ExtraDate       = DateTime.Parse(sdrreader[7].ToString());
                    taxinfo.Extra1          = sdrreader[8].ToString();
                    taxinfo.Extra2          = sdrreader[9].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(taxinfo);
        }
Пример #4
0
 /// <summary>
 /// Function to insert values to  Tax Table
 /// </summary>
 /// <param name="taxinfo"></param>
 public void TaxAdd(TaxInfo taxinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("TaxAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@taxId", SqlDbType.Decimal);
         sprmparam.Value = taxinfo.TaxId;
         sprmparam       = sccmd.Parameters.Add("@taxName", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.TaxName;
         sprmparam       = sccmd.Parameters.Add("@applicableOn", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.ApplicableOn;
         sprmparam       = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = taxinfo.Rate;
         sprmparam       = sccmd.Parameters.Add("@calculatingMode", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.CalculatingMode;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@isActive", SqlDbType.Bit);
         sprmparam.Value = taxinfo.IsActive;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = taxinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Пример #5
0
 /// <summary>
 /// Function to insert values to  Tax Table
 /// </summary>
 /// <param name="taxinfo"></param>
 public void TaxAdd(TaxInfo taxinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("TaxAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@taxId", SqlDbType.Decimal);
         sprmparam.Value = taxinfo.TaxId;
         sprmparam = sccmd.Parameters.Add("@taxName", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.TaxName;
         sprmparam = sccmd.Parameters.Add("@applicableOn", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.ApplicableOn;
         sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = taxinfo.Rate;
         sprmparam = sccmd.Parameters.Add("@calculatingMode", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.CalculatingMode;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit);
         sprmparam.Value = taxinfo.IsActive;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = taxinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Пример #6
0
 /// <summary>
 /// delete function
 /// </summary>
 public void Delete()
 {
     try
     {
         if (PublicVariables.isMessageDelete)
         {
             if (Messages.DeleteMessage())
             {
                 TaxInfo infoTax = new TaxInfo();
                 TaxSP spTax = new TaxSP();
                 TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
                 TaxDetailsSP spTaxDetails = new TaxDetailsSP();
                 AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                 bool isExist = spTax.TaxReferenceCheck(decTaxId);
                 if (!isExist)
                 {
                     if ((spTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1)
                     {
                         Messages.ReferenceExistsMessage();
                     }
                     else
                     {
                         spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
                         spAccountLedger.AccountLedgerDelete(decLedgerId);
                         Messages.DeletedMessage();
                         TaxSearchGridFill();
                         TaxSelectionGridFill();
                         Clear();
                         SearchClear();
                     }
                 }
                 else
                 {
                     Messages.ReferenceExistsMessage();
                 }
             }
         }
         else
         {
             TaxInfo infoTax = new TaxInfo();
             TaxSP spTax = new TaxSP();
             TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
             TaxDetailsSP spTaxDetails = new TaxDetailsSP();
             bool isExist = spTax.TaxReferenceCheck(decTaxId);
             if (!isExist)
             {
                 if ((spTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1)
                 {
                     Messages.ReferenceExistsMessage();
                 }
                 else
                 {
                     spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
                     Messages.DeletedMessage();
                     TaxSearchGridFill();
                     TaxSelectionGridFill();
                     Clear();
                     SearchClear();
                 }
             }
             else
             {
                 Messages.ReferenceExistsMessage();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #7
0
        /// <summary>
        /// fill the curresponding details for update
        /// </summary>
        public void TaxSelectionFillForUpdate()
        {
            try
            {
                int inRowCount = dgvTaxSelection.RowCount;
                for (int i = 0; i < inRowCount; i++)
                {
                    dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = false;
                }
                decTaxId = Convert.ToDecimal(dgvTaxSearch.CurrentRow.Cells["dgvtxtTaxIdSearch"].Value.ToString());
                TaxInfo infoTax = new TaxInfo();
                TaxSP spTax = new TaxSP();
                TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
                TaxDetailsSP spTaxDetails = new TaxDetailsSP();
                infoTax = spTax.TaxView(decTaxId);
                txtTaxName.Text = infoTax.TaxName;
                txtRate.Text = infoTax.Rate.ToString();
                cmbApplicableFor.Text = infoTax.ApplicableOn;
                cmbCalculationMode.Text = infoTax.CalculatingMode;
                txtNarration.Text = infoTax.Narration;
                if (infoTax.IsActive.ToString() == "True")
                {
                    cbxActive.Checked = true;
                }
                else
                {
                    cbxActive.Checked = false;
                }
                strTaxName = infoTax.TaxName;
                decTaxIdForEdit = infoTax.TaxId;
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                DataTable dtbl = new DataTable();
                dtbl = spTax.TaxIdForTaxSelectionUpdate(decTaxId);
                foreach (DataRow dr in dtbl.Rows)
                {
                    string strTaxId = dr["selectedtaxId"].ToString();
                    for (int i = 0; i < inRowCount; i++)
                    {
                        if (dgvTaxSelection.Rows[i].Cells["dgvtxtTaxId"].Value.ToString() == strTaxId)
                        {
                            dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = true;
                        }
                    }
                }

                AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                decLedgerId = spAccountLedger.AccountLedgerIdGetByName(txtTaxName.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("TC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #8
0
 /// <summary>
 /// update function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         TaxInfo infoTax = new TaxInfo();
         TaxSP spTax = new TaxSP();
         TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
         TaxDetailsSP spTaxDetails = new TaxDetailsSP();
         infoTax.TaxName = txtTaxName.Text.Trim();
         infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString());
         infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString();
         if (cmbCalculationMode.Enabled != true)
         {
             infoTax.CalculatingMode = string.Empty;
         }
         else
         {
             infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString();
         }
         infoTax.Narration = txtNarration.Text.Trim();
         if (cbxActive.Checked)
         {
             infoTax.IsActive = true;
         }
         else
         {
             infoTax.IsActive = false;
         }
         infoTax.Extra1 = string.Empty;
         infoTax.Extra2 = string.Empty;
         if (txtTaxName.Text.ToString() != strTaxName)
         {
             if (spTax.TaxCheckExistence(decTaxIdForEdit, txtTaxName.Text.Trim()) == false)
             {
                 infoTax.TaxId = decTaxId;
                 spTax.TaxEdit(infoTax);
                 //-- Delete And Add Tax details --//
                 spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
                 if (dgvTaxSelection.RowCount > 0)
                 {
                     bool isOk = false;
                     foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows)
                     {
                         isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value);
                         if (isOk)
                         {
                             infoTaxDetails.TaxId = decTaxId;
                             infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString();
                             infoTaxDetails.ExtraDate = DateTime.Now;
                             infoTaxDetails.Extra1 = string.Empty;
                             infoTaxDetails.Extra2 = string.Empty;
                             spTaxDetails.TaxDetailsAddWithoutId(infoTaxDetails);
                         }
                     }
                 }
                 LedgerEdit();
                 Messages.UpdatedMessage();
                 Clear();
             }
             else
             {
                 Messages.InformationMessage(" Tax or ledger already exist");
                 txtTaxName.Focus();
             }
         }
         else
         {
             infoTax.TaxId = decTaxId;
             spTax.TaxEdit(infoTax);
             spTaxDetails.TaxDetailsDeleteWithTaxId(decTaxId);
             if (dgvTaxSelection.RowCount > 0)
             {
                 bool isOk = false;
                 foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows)
                 {
                     isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value);
                     if (isOk)
                     {
                         infoTaxDetails.TaxId = decTaxId;
                         infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString();
                         infoTaxDetails.ExtraDate = DateTime.Now;
                         infoTaxDetails.Extra1 = string.Empty;
                         infoTaxDetails.Extra2 = string.Empty;
                         spTaxDetails.TaxDetailsAddWithoutId(infoTaxDetails);
                     }
                 }
             }
             LedgerEdit();
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #9
0
 /// <summary>
 /// save function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         TaxInfo infoTax = new TaxInfo();
         TaxSP spTax = new TaxSP();
         TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo();
         TaxDetailsSP spTaxDetails = new TaxDetailsSP();
         infoTax.TaxName = txtTaxName.Text.Trim();
         infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString());
         infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString();
         if (cmbCalculationMode.Enabled != true)
         {
             infoTax.CalculatingMode = string.Empty;
         }
         else
         {
             infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString();
         }
         infoTax.Narration = txtNarration.Text.Trim();
         if (cbxActive.Checked)
         {
             infoTax.IsActive = true;
         }
         else
         {
             infoTax.IsActive = false;
         }
         infoTax.Extra1 = string.Empty;
         infoTax.Extra2 = string.Empty;
         if (spTax.TaxCheckExistence(0, txtTaxName.Text.Trim()) == false)
         {
             decTaxId = spTax.TaxAddWithIdentity(infoTax);
             decIdForOtherForms = decTaxId;
             if (dgvTaxSelection.RowCount > 0)
             {
                 bool isOk = false;
                 foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows)
                 {
                     isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value);
                     if (isOk)
                     {
                         infoTaxDetails.TaxId = decTaxId;
                         infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString();
                         infoTaxDetails.ExtraDate = DateTime.Now;
                         infoTaxDetails.Extra1 = string.Empty;
                         infoTaxDetails.Extra2 = string.Empty;
                         spTaxDetails.TaxDetailsAddWithoutId(infoTaxDetails);
                     }
                 }
             }
             CreateLedger();
             Messages.SavedMessage();
             Clear();
             SearchClear();
         }
         else
         {
             Messages.InformationMessage(" Tax or ledger already exist");
             txtTaxName.Focus();
         }
         if (frmProductCreationObj != null)
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("TC4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #10
0
 /// <summary>
 ///  Grid fill function Againest DeliveryNote
 /// </summary>
 public void gridFillAgainestDeliveryNote()
 {
     DeliveryNoteMasterSP SPDeliveryNoteMaster = new DeliveryNoteMasterSP();
     DeliveryNoteDetailsSP SPDeliveryNoteDetails = new DeliveryNoteDetailsSP();
     ProductInfo infoproduct = new ProductInfo();
     SalesMasterSP spSalesMaster = new SalesMasterSP();
     BrandInfo InfoBrand = new BrandInfo();
     TaxInfo infoTax = new TaxInfo();
     TaxSP SPTax = new TaxSP();
     try
     {
         if (cmbSalesModeOrderNo.SelectedIndex > 0)
         {
             inMaxCount = 0;
             isValueChange = false;
             for (int i = 0; i < dgvSalesInvoice.RowCount - 1; i++)
             {
                 if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != string.Empty)
                 {
                     lstArrOfRemove.Add(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString());
                 }
             }
             dgvSalesInvoice.Rows.Clear();
             isValueChange = true;
             DataTable dtblMaster = SPDeliveryNoteMaster.SalesInvoiceGridfillAgainestDeliveryNote(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()));
             cmbPricingLevel.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["pricingLevelId"].ToString());
             cmbCurrency.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["exchangeRateId"].ToString());
             cmbPricingLevel.Enabled = false;
             cmbCurrency.Enabled = false;
             DataTable dtblDetails = SPDeliveryNoteDetails.SalesInvoiceGridfillAgainestDeliveryNoteUsingDeliveryNoteDetails(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()), decSalesInvoiceIdToEdit, DecSalesInvoiceVoucherTypeId);
             dtblDeliveryNoteDetails = dtblDetails;
             int inRowIndex = 0;
             foreach (DataRow drowDetails in dtblDetails.Rows)
             {
                 dgvSalesInvoice.Rows.Add();
                 IsSetGridValueChange = false;
                 isValueChange = false;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = drowDetails["deliveryNoteDetailsId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductCode"].Value = drowDetails["productCode"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBarcode"].Value = drowDetails["barcode"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = drowDetails["voucherNo"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = drowDetails["invoiceNo"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value = "0";
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInRowIndex"].Value = drowDetails["deliveryNoteDetailsId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value = drowDetails.ItemArray[2].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = drowDetails["unitConversionId"].ToString();
                 infoproduct = spSalesMaster.ProductViewByProductIdforSalesInvoice(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductName"].Value = infoproduct.ProductName;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceMrp"].Value = infoproduct.Mrp;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = infoproduct.PurchaseRate;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceSalesRate"].Value = infoproduct.SalesRate;
                 InfoBrand = new BrandSP().BrandView(infoproduct.BrandId);
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBrand"].Value = InfoBrand.BrandName;
                 infoTax = SPTax.TaxViewByProductId(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceTaxName"].Value = infoTax.TaxId;
                 isValueChange = false;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceQty"].Value = drowDetails["Qty"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceRate"].Value = drowDetails["rate"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceAmount"].Value = drowDetails["amount"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceConversionRate"].Value = drowDetails["conversionRate"].ToString();
                 isFromAgainest = true;
                 gridColumnMakeEnables();
                 int intIndex = 0;
                 intIndex = Convert.ToInt32(drowDetails["deliveryNoteDetailsId"].ToString());
                 if (inMaxCount < intIndex)
                     inMaxCount = intIndex;
                 inRowIndex++;
                 isValueChange = true;
                 isFromAgainest = false;
                 GrossValueCalculation(dgvSalesInvoice.Rows.Count - 2);
                 discountCalculation(dgvSalesInvoice.Rows.Count - 2);
                 taxAndGridTotalAmountCalculation(dgvSalesInvoice.Rows.Count - 2);
             }
             IsSetGridValueChange = true;
             for (int i = inRowIndex; i < dgvSalesInvoice.Rows.Count; ++i)
                 dgvSalesInvoice["dgvtxtSalesInvoiceInRowIndex", i].Value = GetNextinRowIndex().ToString();
             SerialNoforSalesInvoice();
             strVoucherNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString();
             strInvoiceNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString();
             decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value);
         }
         else
         {
             SiGridTotalAmountCalculation();
             ClearGridAgainest();
         }
         SiGridTotalAmountCalculation();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 53" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #11
0
        /// <summary>
        /// Function for Amount Calculations for Gross value, Net amount, Tax amount and Total amount
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="inIndexOfRow"></param>
        public void AmountCalculation(string columnName, int inIndexOfRow)
        {
            try
            {
                string strTaxRate = string.Empty;
                decimal decTaxAmt = 0;
                decimal decTotalAmnt = 0;
                decimal decdgvtxtgrossValue = 0, decDiscountCalc = 0, decNetAmount = 0;
                decimal decTaxPercent = 0;
                decimal decTaxId = 0;
                DataGridViewRow dgrow = dgvPurchaseReturn.Rows[inIndexOfRow];
                ProductInfo infoProduct = new ProductInfo();
                ProductSP spProduct = new ProductSP();
                TaxInfo infotax = new TaxInfo();
                TaxSP spTax = new TaxSP();

                if (dgrow.Cells["dgvtxtqty"].Value != null && dgrow.Cells["dgvtxtqty"].Value.ToString() != string.Empty)
                {
                    decQty = Convert.ToDecimal(dgrow.Cells["dgvtxtqty"].Value.ToString());
                }

                if (dgrow.Cells["dgvtxtrate"].Value != null && dgrow.Cells["dgvtxtrate"].Value.ToString() != string.Empty)
                {
                    decRate = Convert.ToDecimal(dgrow.Cells["dgvtxtrate"].Value.ToString());
                    decdgvtxtgrossValue = decQty * decRate;
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgrow.Cells["dgvtxtgrossValue"].Value != null && dgrow.Cells["dgvtxtgrossValue"].Value.ToString() != string.Empty)
                {
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                    if (dgrow.Cells["dgvtxtdiscount"].Value != null && dgrow.Cells["dgvtxtdiscount"].Value.ToString() != string.Empty)
                    {
                        decDiscountCalc = Convert.ToDecimal(dgrow.Cells["dgvtxtdiscount"].Value.ToString());
                        if (decdgvtxtgrossValue >= decDiscountCalc)
                        {
                            decNetAmount = Math.Round((decdgvtxtgrossValue - decDiscountCalc), PublicVariables._inNoOfDecimalPlaces);
                            dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                        else
                        {
                            dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        }
                    }
                    else
                    {
                        dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                    }
                }
                if (dgrow.Cells["dgvtxtNetAmount"].Value != null && dgrow.Cells["dgvtxtNetAmount"].Value.ToString() != string.Empty)
                {
                    decNetAmount = Math.Round(decdgvtxtgrossValue - decDiscountCalc, PublicVariables._inNoOfDecimalPlaces);
                    decNetAmount = Convert.ToDecimal(dgrow.Cells["dgvtxtNetAmount"].Value.ToString());
                    dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgvcmbTax.Visible)
                {
                    if (dgrow.Cells["dgvtxtproductId"].Value != null && dgrow.Cells["dgvtxtproductId"].Value.ToString() != string.Empty)
                    {
                        if (dgrow.Cells["dgvcmbTax"].Value != null && dgrow.Cells["dgvcmbTax"].Value.ToString() != string.Empty && dgrow.Cells["dgvcmbTax"].Value.ToString() != "NA")
                        {
                            decTaxId = Convert.ToDecimal(dgrow.Cells["dgvcmbTax"].Value.ToString());
                            infotax = spTax.TaxView(decTaxId);
                            decTaxPercent = infotax.Rate;
                            if (decTaxPercent != 0)
                            {
                                if (strTaxComboFill != string.Empty)
                                {
                                    decTaxAmt = ((decNetAmount * decTaxPercent) / 100);
                                }
                                else
                                {
                                    dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                }
                                decTotalAmnt = Math.Round((decNetAmount + decTaxAmt), PublicVariables._inNoOfDecimalPlaces);
                                dgrow.Cells["dgvtxttaxAmount"].Value = Math.Round(decTaxAmt, PublicVariables._inNoOfDecimalPlaces);
                                decTaxAmt = Convert.ToDecimal(dgrow.Cells["dgvtxttaxAmount"].Value.ToString());
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decTotalAmnt, PublicVariables._inNoOfDecimalPlaces);
                            }
                            else
                            {
                                dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                            }
                        }
                        else
                        {
                            decTaxPercent = 0;
                            dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                            dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                    }
                    Calculate();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR:34 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #12
0
 /// <summary>
 /// Function for Tax View By ProductId
 /// </summary>
 /// <param name="strProductCode"></param>
 /// <returns></returns>
 public TaxInfo TaxViewByProductId(string strProductCode)
 {
     TaxInfo taxInfo = new TaxInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("TaxViewByProductId", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.VarChar);
         sprmparam.Value = strProductCode;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             taxInfo.TaxId = Convert.ToDecimal(sdrreader["taxId"].ToString());
             taxInfo.TaxName = sdrreader["taxName"].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return taxInfo;
 }
Пример #13
0
 /// <summary>
 /// Function for insert values and return id
 /// </summary>
 /// <param name="taxinfo"></param>
 /// <returns></returns>
 public decimal TaxAddWithIdentity(TaxInfo taxinfo)
 {
     decimal decTaxId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("TaxAddWithIdentity", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@taxName", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.TaxName;
         sprmparam = sccmd.Parameters.Add("@applicableOn", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.ApplicableOn;
         sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = taxinfo.Rate;
         sprmparam = sccmd.Parameters.Add("@calculatingMode", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.CalculatingMode;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit);
         sprmparam.Value = taxinfo.IsActive;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = taxinfo.Extra2;
         object objTaxId = sccmd.ExecuteScalar();
         if (objTaxId != null)
         {
             decTaxId = decimal.Parse(objTaxId.ToString());
         }
         else
         {
             decTaxId = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decTaxId;
 }
Пример #14
0
 /// <summary>
 /// Function to get particular values from Tax Table based on the parameter
 /// </summary>
 /// <param name="taxId"></param>
 /// <returns></returns>
 public TaxInfo TaxView(decimal taxId)
 {
     TaxInfo taxinfo = new TaxInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("TaxView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@taxId", SqlDbType.Decimal);
         sprmparam.Value = taxId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             taxinfo.TaxId = decimal.Parse(sdrreader[0].ToString());
             taxinfo.TaxName = sdrreader[1].ToString();
             taxinfo.ApplicableOn = sdrreader[2].ToString();
             taxinfo.Rate = decimal.Parse(sdrreader[3].ToString());
             taxinfo.CalculatingMode = sdrreader[4].ToString();
             taxinfo.Narration = sdrreader[5].ToString();
             taxinfo.IsActive = bool.Parse(sdrreader[6].ToString());
             taxinfo.ExtraDate = DateTime.Parse(sdrreader[7].ToString());
             taxinfo.Extra1 = sdrreader[8].ToString();
             taxinfo.Extra2 = sdrreader[9].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return taxinfo;
 }
Пример #15
0
 /// <summary>
 /// Function to calculate total amount
 /// </summary>
 /// <param name="inRowIndex"></param>
 public void Calculate(int inRowIndex)
 {
     decimal decDiscount = 0;
     decimal decDiscountPercent = 0;
     decimal decGrossValue = 0;
     decimal decNetValue = 0;
     decimal decTaxAmount = 0;
     decimal decTaxPercent = 0;
     decimal decTaxId = 0;
     decimal decAmount = 0;
     decimal decTotalAmount = 0;
     decimal decProductId = 0;
     decimal decDefaultTotalAmount = 0;
     decimal decProductRate = 0;
     decimal decQuantity = 0;
     ProductInfo infoProduct = new ProductInfo();
     ProductSP spProduct = new ProductSP();
     TaxInfo infotax = new TaxInfo();
     TaxSP spTax = new TaxSP();
     ExchangeRateSP spExchangeRate = new ExchangeRateSP();
     try
     {
         if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value != null)
         {
             if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString() != string.Empty)
             {
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty && dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString() != ".")
                     {
                         decProductRate = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString());
                     }
                 }
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString() != string.Empty && dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString() != ".")
                     {
                         decQuantity = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString());
                     }
                 }
                 decGrossValue = decProductRate * decQuantity;
                 dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtGrossValue"].Value = Math.Round(decGrossValue, PublicVariables._inNoOfDecimalPlaces);
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value.ToString() != string.Empty)
                     {
                         decDiscountPercent = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value.ToString());
                     }
                     else
                     {
                         dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0;
                     }
                 }
                 else
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0;
                 }
                 if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value != null)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value.ToString() != string.Empty)
                     {
                         decDiscount = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value.ToString());
                     }
                     else
                     {
                         dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0;
                     }
                 }
                 else
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0;
                 }
                 /*------------------------------Calculate-----------------------------------*/
                 /*------------------------------Discount Calculation-----------------------------------*/
                 if (decGrossValue >= decDiscount)
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = Math.Round(decDiscount, PublicVariables._inNoOfDecimalPlaces);
                 }
                 else
                 {
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0;
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0;
                     decDiscount = 0;
                 }
                 decNetValue = decGrossValue - decDiscount;
                 dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtNetValue"].Value = Math.Round(decNetValue, PublicVariables._inNoOfDecimalPlaces);
                 /*------------------------------Tax Calculation-----------------------------------*/
                 if (dgvcmbTax.Visible)
                 {
                     if (dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value != null)
                     {
                         if (dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString() != string.Empty &&
                             dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString() != "0")
                         {
                             decTaxId = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString());
                             infotax = spTax.TaxView(decTaxId);
                             decTaxPercent = infotax.Rate;
                         }
                         else
                         {
                             decTaxPercent = 0;
                         }
                     }
                     else
                     {
                         decTaxPercent = 0;
                     }
                     decProductId = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString());
                     infoProduct = spProduct.ProductView(decProductId);
                     if (infoProduct.TaxapplicableOn == "MRP")
                     {
                         decTaxAmount = infoProduct.Mrp * decTaxPercent / 100;
                     }
                     else
                     {
                         decTaxAmount = decNetValue * decTaxPercent / 100;
                     }
                     dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtTaxAmount"].Value = Math.Round(decTaxAmount, PublicVariables._inNoOfDecimalPlaces);
                 }
                 decAmount = decNetValue + decTaxAmount;
                 dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = Math.Round(decAmount, PublicVariables._inNoOfDecimalPlaces);
                 decTotalAmount = decTotalAmount + decAmount;
                 decDefaultTotalAmount = decTotalAmount * 1;
                 //CalculateTotalAmount();
                 //if (dgvTax.Visible)
                 //{
                 //    TotalTaxAmount();
                 //}
                 //CalculateGrandTotal();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI84:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }