/// <summary>
        /// Here get the Barcode ViewBy ProductCode
        /// </summary>
        /// <param name="strproductCode"></param>
        /// <returns></returns>
        public ProductBatchInfo BarcodeViewByProductCode(string strproductCode)
        {
            ProductBatchInfo infoProductBatch = new ProductBatchInfo();

            try
            {
                infoProductBatch = spProduct.BarcodeViewByProductCode(strproductCode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC20:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(infoProductBatch);
        }
        public ProductBatchInfo ProductBatchView(decimal productBatchId)
        {
            ProductBatchInfo productbatchinfo = new ProductBatchInfo();
            SqlDataReader    sdrreader        = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ProductBatchView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@productBatchId", SqlDbType.Decimal);
                sprmparam.Value = productBatchId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    productbatchinfo.ProductBatchId = decimal.Parse(sdrreader[0].ToString());
                    productbatchinfo.ProductId      = decimal.Parse(sdrreader[1].ToString());
                    productbatchinfo.BatchId        = decimal.Parse(sdrreader[2].ToString());
                    productbatchinfo.PartNo         = sdrreader[3].ToString();
                    productbatchinfo.Barcode        = sdrreader[4].ToString();
                    productbatchinfo.Extra1         = sdrreader[5].ToString();
                    productbatchinfo.Extra2         = sdrreader[6].ToString();
                    productbatchinfo.ExtraDate      = DateTime.Parse(sdrreader[7].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(productbatchinfo);
        }
 public void ProductBatchEdit(ProductBatchInfo productbatchinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ProductBatchEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@productBatchId", SqlDbType.Decimal);
         sprmparam.Value = productbatchinfo.ProductBatchId;
         sprmparam       = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = productbatchinfo.ProductId;
         sprmparam       = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
         sprmparam.Value = productbatchinfo.BatchId;
         sprmparam       = sccmd.Parameters.Add("@partNo", SqlDbType.VarChar);
         sprmparam.Value = productbatchinfo.PartNo;
         sprmparam       = sccmd.Parameters.Add("@barcode", SqlDbType.VarChar);
         sprmparam.Value = productbatchinfo.Barcode;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = productbatchinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = productbatchinfo.Extra2;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = productbatchinfo.ExtraDate;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
        /// <summary>
        ///  Function to fil Controls based on the ProductName
        /// </summary>
        /// <param name="decProductId"></param>
        public void FillControlsByProductName(decimal decProductId)
        {
            try
            {
                PriceListInfo InfoPriceList = new PriceListInfo();
                ProductInfo infoProduct = new ProductInfo();
                ProductCreationBll BllProductCreation = new ProductCreationBll();
                PriceListBll BllPriceList = new PriceListBll();
                ProductBatchInfo infoProductBatch = new ProductBatchInfo();
                infoProduct = BllProductCreation.ProductView(decProductId);
                txtProductCode.Text = infoProduct.ProductCode;
                infoProductBatch = BllProductCreation.BarcodeViewByProductCode(txtProductCode.Text);
                decProductId = infoProductBatch.ProductId;
                decBatchId = infoProductBatch.BatchId;
                InfoPriceList = BllPriceList.PriceListViewByBatchIdORProduct(decBatchId);
                batchcombofill();
                txtBarcode.Text = infoProductBatch.Barcode;
                cmbItem.Text = infoProduct.ProductName;
                cmbGodown.SelectedValue = infoProduct.GodownId;
                cmbRack.SelectedValue = infoProduct.RackId;
                UnitComboFill();
                UnitInfo infoUnit = new UnitInfo();
                infoUnit = new UnitBll().unitVieWForStandardRate(decProductId);
                cmbUnit.SelectedValue = infoUnit.UnitId;
                if (InfoPriceList.PricinglevelId != 0)
                {
                    cmbPricingLevel.SelectedValue = InfoPriceList.PricinglevelId;
                }
                else
                {
                    cmbPricingLevel.SelectedIndex = 0;
                }
                ComboTaxFill();
                cmbTax.SelectedValue = infoProduct.TaxId;
                if (txtProductCode.Text.Trim() != string.Empty && cmbItem.SelectedIndex != -1)
                {
                    decimal decNodecplaces = PublicVariables._inNoOfDecimalPlaces;
                    decimal dcRate = BllProductCreation.ProductRateForSales(decProductId, Convert.ToDateTime(txtDate.Text), decBatchId, decNodecplaces);
                    txtRate.Text = dcRate.ToString();
                    try
                    {
                        if (decimal.Parse(txtQuantity.Text) == 0)
                            txtQuantity.Text = "1";
                    }
                    catch { txtQuantity.Text = "1"; }
                    txtQuantity.Focus();

                }
                TaxAmountCalculation();
                isAfterFillControls = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("POS:27" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }