/// <summary>
 /// Function to insert values to PriceList Table
 /// </summary>
 /// <param name="pricelistinfo"></param>
 public void PriceListAdd(PriceListInfo pricelistinfo)
 {
     try
        {
        spPriceList.PriceListAdd(pricelistinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
 }
 /// <summary>
 /// Function to insert values to PriceList Table
 /// </summary>
 /// <param name="pricelistinfo"></param>
 public void PriceListAdd(PriceListInfo pricelistinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PriceListAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         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();
     }
 }
 /// <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;
 }
 /// <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;
 }
 public PriceListInfo PriceListViewByBatchIdORProduct(decimal dcBatchId)
 {
     PriceListInfo infoPriceList = new PriceListInfo();
        try
        {
        infoPriceList = spPriceList.PriceListViewByBatchIdORProduct(dcBatchId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return infoPriceList;
 }
 /// <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();
        try
        {
        pricelistinfo = spPriceList.PriceListView(pricelistId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return pricelistinfo;
 }