Example #1
0
        /// <summary>
        /// Price list get by batchid Or product
        /// </summary>
        /// <param name="dcBatchId"></param>
        /// <returns></returns>
        public PriceListInfo PriceListViewByBatchIdORProduct(decimal dcBatchId)
        {
            PriceListInfo infoPriceList = new PriceListInfo();
            SqlDataReader sqldr         = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sqlcmd = new SqlCommand("PriceListViewByBatchIdORProduct", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add("@batchId", SqlDbType.Decimal).Value = dcBatchId;
                sqldr = sqlcmd.ExecuteReader();
                while (sqldr.Read())
                {
                    infoPriceList.ProductId      = Convert.ToDecimal(sqldr["productId"].ToString());
                    infoPriceList.BatchId        = Convert.ToDecimal(sqldr["batchId"].ToString());
                    infoPriceList.PricinglevelId = Convert.ToDecimal(sqldr["pricinglevelId"].ToString());
                    infoPriceList.Rate           = Convert.ToDecimal(sqldr["rate"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                sqlcon.Close();
                sqldr.Close();
            }
            return(infoPriceList);
        }
Example #2
0
 /// <summary>
 /// Function to save the new pricelist for the product
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         PriceListSP   spPriceList   = new PriceListSP();
         PriceListInfo infoPriceList = new PriceListInfo();
         infoPriceList.ProductId      = decProductMain;
         infoPriceList.PricinglevelId = decPricingLevelMain;
         infoPriceList.UnitId         = decUnitId;
         infoPriceList.BatchId        = Convert.ToDecimal(cmbBatch.SelectedValue.ToString());
         infoPriceList.Rate           = Convert.ToDecimal(txtRate.Text);
         infoPriceList.Extra1         = string.Empty;
         infoPriceList.Extra2         = string.Empty;
         if (spPriceList.PriceListCheckExistence(0, decPricingLevelMain, Convert.ToDecimal(cmbBatch.SelectedValue.ToString()), decProductMain) == true)
         {
             spPriceList.PriceListAdd(infoPriceList);
             Messages.SavedMessage();
             Clear();
         }
         else
         {
             Messages.InformationMessage("Price List already exist for selected product and batches");
             Clear();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PLP2" + ex.Message + ex.Message;
     }
 }
Example #3
0
 /// <summary>
 /// Function to execute while calling from frmPriceList form to add new pricelist for the product
 /// </summary>
 /// <param name="decPricingLevel"></param>
 /// <param name="decProduct"></param>
 /// <param name="decPriceListId"></param>
 /// <param name="frmPriceList"></param>
 public void CallFromPriceListForPricingLevel(decimal decPricingLevel, decimal decProduct, decimal decPriceListId, frmPriceList frmPriceList)
 {
     try
     {
         ProductInfo      infoProduct      = new ProductInfo();
         ProductSP        spProduct        = new ProductSP();
         UnitSP           spunit           = new UnitSP();
         UnitInfo         infoUnit         = new UnitInfo();
         PriceListSP      spPriceList      = new PriceListSP();
         PriceListInfo    infoPriceList    = new PriceListInfo();
         PricingLevelSP   spPricingLevel   = new PricingLevelSP();
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         infoProduct          = spProduct.PriceListPopUpView(decProduct);
         txtProductCode.Text  = infoProduct.ProductCode;
         txtProductName.Text  = infoProduct.ProductName;
         decProduct           = infoProduct.ProductId;
         decProductMain       = infoProduct.ProductId;
         infoUnit             = spunit.UnitViewForPriceListPopUp(decProduct);
         decUnitId            = infoUnit.UnitId;
         txtUnitName.Text     = infoUnit.UnitName;
         decPriceLevelId      = infoPriceList.PricinglevelId;
         infoPricingLevel     = spPricingLevel.PricingLevelNameViewForPriceListPopUp(decPricingLevel, decProduct, decUnitId);
         decPriceLevelId      = infoPricingLevel.PricinglevelId;
         txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         if (txtPricingLevel.Text == string.Empty)
         {
             infoPricingLevel     = spPricingLevel.PricingLevelView(decPricingLevel);
             txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         }
         decPricingLevelMain      = infoPricingLevel.PricinglevelId;
         txtPricingLevel.ReadOnly = true;
         txtProductCode.ReadOnly  = true;
         txtProductName.ReadOnly  = true;
         txtUnitName.ReadOnly     = true;
         txtRate.Focus();
         BatchUnderProductComboFill(decProduct);
         PriceListPopupGridFill();
         deca = decPriceListId;
         this.frmPriceListobj = frmPriceList;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PLP1" + ex.Message + ex.Message;
     }
 }
Example #4
0
 /// <summary>
 /// Function to edit the pricelist
 /// </summary>
 public void EditFunction()
 {
     try
     {
         if (txtRate.Text.Trim() == String.Empty)
         {
             Messages.InformationMessage("Enter rate");
             txtRate.Focus();
         }
         else if (Convert.ToDecimal(txtRate.Text) == 0)
         {
             PriceListSP spPriceList = new PriceListSP();
             spPriceList.PriceListDelete(deca);
             Messages.UpdatedMessage();
             if (frmPriceListobj != null)
             {
                 this.Close();
             }
         }
         else
         {
             PriceListSP   spPriceList   = new PriceListSP();
             PriceListInfo infoPriceList = new PriceListInfo();
             infoPriceList.ProductId      = decProductMain;
             infoPriceList.PricelistId    = Convert.ToDecimal(dgvProductGroup.CurrentRow.Cells["dgvtxtPriceListId"].Value.ToString());
             infoPriceList.PricinglevelId = decPricingLevelMain;
             infoPriceList.UnitId         = decUnitId;
             infoPriceList.BatchId        = decBatchId;
             infoPriceList.Rate           = Convert.ToDecimal(txtRate.Text);
             infoPriceList.Extra1         = string.Empty;
             infoPriceList.Extra2         = string.Empty;
             spPriceList.PriceListEdit(infoPriceList);
             Messages.UpdatedMessage();
             Clear();
             if (frmPriceListobj != null)
             {
                 this.Close();
             }
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PLP3" + ex.Message + ex.Message;
     }
 }
Example #5
0
        /// <summary>
        /// Function to get particular values from PriceList Table based on the parameter
        /// </summary>
        /// <param name="pricelistId"></param>
        /// <returns></returns>
        public PriceListInfo PriceListView(decimal pricelistId)
        {
            PriceListInfo pricelistinfo = new PriceListInfo();
            SqlDataReader sdrreader     = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("PriceListView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@pricelistId", SqlDbType.Decimal);
                sprmparam.Value = pricelistId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    pricelistinfo.PricelistId    = Convert.ToDecimal(sdrreader[0].ToString());
                    pricelistinfo.ProductId      = Convert.ToDecimal(sdrreader[1].ToString());
                    pricelistinfo.PricinglevelId = Convert.ToDecimal(sdrreader[2].ToString());
                    pricelistinfo.UnitId         = Convert.ToDecimal(sdrreader[3].ToString());
                    pricelistinfo.BatchId        = Convert.ToDecimal(sdrreader[4].ToString());
                    pricelistinfo.Rate           = Convert.ToDecimal(sdrreader[5].ToString());
                    pricelistinfo.ExtraDate      = Convert.ToDateTime(sdrreader[6].ToString());
                    pricelistinfo.Extra1         = sdrreader[7].ToString();
                    pricelistinfo.Extra2         = sdrreader[8].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(pricelistinfo);
        }
Example #6
0
 /// <summary>
 /// Function to Update values in PriceList Table
 /// </summary>
 /// <param name="pricelistinfo"></param>
 public void PriceListEdit(PriceListInfo pricelistinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PriceListEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@pricelistId", SqlDbType.Decimal);
         sprmparam.Value = pricelistinfo.PricelistId;
         sprmparam       = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = pricelistinfo.ProductId;
         sprmparam       = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = pricelistinfo.PricinglevelId;
         sprmparam       = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal);
         sprmparam.Value = pricelistinfo.UnitId;
         sprmparam       = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = pricelistinfo.Rate;
         sprmparam       = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
         sprmparam.Value = pricelistinfo.BatchId;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = pricelistinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = pricelistinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Example #7
0
 /// <summary>
 /// Function to fill the fields while user double click on the datagridview
 /// </summary>
 public void FillControls()
 {
     try
     {
         PriceListInfo infoPricelist = new PriceListInfo();
         PriceListSP   spPricelist   = new PriceListSP();
         infoPricelist.PricelistId = decpriceListId;
         infoPricelist             = spPricelist.PriceListView(decpriceListId);
         txtRate.Text = infoPricelist.Rate.ToString();
         ProductInfo infoProduct = new ProductInfo();
         ProductSP   spProduct   = new ProductSP();
         infoProduct         = spProduct.PriceListPopUpView(decProductId);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         BatchInfo infobatch = new BatchInfo();
         BatchSP   spBatch   = new BatchSP();
         infobatch = spBatch.BatchView(decBatchId);
         cmbBatch.SelectedValue = infobatch.BatchId;
         UnitInfo infoUnit = new UnitInfo();
         UnitSP   spUnit   = new UnitSP();
         infoUnit         = spUnit.UnitView(decUnitId);
         txtUnitName.Text = infoUnit.UnitName;
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         PricingLevelSP   spPricingLevel   = new PricingLevelSP();
         infoPricingLevel         = spPricingLevel.PricingLevelView(decPriceLevelId);
         txtPricingLevel.Text     = infoPricingLevel.PricinglevelName;
         txtProductName.ReadOnly  = true;
         txtProductCode.ReadOnly  = true;
         txtUnitName.ReadOnly     = true;
         txtPricingLevel.ReadOnly = true;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PLP10" + ex.Message + ex.Message;
     }
 }