/// <summary>
 /// Function to insert values to PricingLevel Table
 /// </summary>
 /// <param name="pricinglevelinfo"></param>
 public void PricingLevelAdd(PricingLevelInfo pricinglevelinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PricingLevelAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = pricinglevelinfo.PricinglevelId;
         sprmparam = sccmd.Parameters.Add("@pricinglevelName", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.PricinglevelName;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 public decimal PricingLevelAddWithoutSamePricingLevel(PricingLevelInfo pricinglevelinfo)
 {
     decimal decPricingLevelId = 0;
        try
        {
        decPricingLevelId = spPricingLevel.PricingLevelAddWithoutSamePricingLevel(pricinglevelinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PRL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return decPricingLevelId;
 }
 public bool PricingLevelEditParticularFields(PricingLevelInfo pricinglevelinfo)
 {
     bool isEdit = false;
        try
        {
        isEdit = spPricingLevel.PricingLevelEditParticularFields(pricinglevelinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PRL3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return isEdit;
 }
 public PricingLevelInfo PricingLevelWithNarrationView(decimal decPricinglevelId)
 {
     PricingLevelInfo pricinglevelinfo = new PricingLevelInfo();
        try
        {
        pricinglevelinfo = spPricingLevel.PricingLevelWithNarrationView(decPricinglevelId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PRL7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return pricinglevelinfo;
 }
 /// <summary>
 /// PricingLevel Name View For PriceList PopUp
 /// </summary>
 /// <param name="decPricingLevel"></param>
 /// <param name="decProductId"></param>
 /// <param name="decUnitId"></param>
 /// <returns></returns>
 public PricingLevelInfo PricingLevelNameViewForPriceListPopUp(decimal decPricingLevel, decimal decProductId, decimal decUnitId)
 {
     PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
        try
        {
        infoPricingLevel = spPricingLevel.PricingLevelNameViewForPriceListPopUp(decPricingLevel, decProductId, decUnitId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("PRL7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return infoPricingLevel;
 }
 /// <summary>
 /// Function to view all pricinglevel with narration
 /// </summary>
 /// <param name="decPricinglevelId"></param>
 /// <returns></returns>
 public PricingLevelInfo PricingLevelWithNarrationView(decimal decPricinglevelId)
 {
     PricingLevelInfo pricinglevelinfo = new PricingLevelInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PricingLevelWithNarrationView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = decPricinglevelId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             pricinglevelinfo.PricinglevelId = Convert.ToDecimal(sdrreader[0].ToString());
             pricinglevelinfo.PricinglevelName = sdrreader[1].ToString();
             pricinglevelinfo.Narration = sdrreader[2].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return pricinglevelinfo;
 }
 /// <summary>
 /// PricingLevel Name View For PriceList PopUp
 /// </summary>
 /// <param name="decPricingLevel"></param>
 /// <param name="decProductId"></param>
 /// <param name="decUnitId"></param>
 /// <returns></returns>
 public PricingLevelInfo PricingLevelNameViewForPriceListPopUp(decimal decPricingLevel, decimal decProductId, decimal decUnitId)
 {
     PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
     SqlDataReader sqldr = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sqlcmd = new SqlCommand("PricingLevelNameViewForPriceListPopUp", sqlcon);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal).Value = decPricingLevel;
         sqlcmd.Parameters.Add("@productId", SqlDbType.Decimal).Value = decProductId;
         sqlcmd.Parameters.Add("@unitId", SqlDbType.Decimal).Value = decUnitId;
         sqldr = sqlcmd.ExecuteReader();
         while (sqldr.Read())
         {
             infoPricingLevel.PricinglevelId = Convert.ToDecimal(sqldr["pricinglevelId"].ToString());
             infoPricingLevel.PricinglevelName = sqldr["pricinglevelName"].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         sqlcon.Close();
         sqldr.Close();
     }
     return infoPricingLevel;
 }
 /// <summary>
 /// Function to Update values in PricingLevel Table
 /// </summary>
 /// <param name="pricinglevelinfo"></param>
 /// <returns></returns>
 public bool PricingLevelEditParticularFields(PricingLevelInfo pricinglevelinfo)
 {
     bool isEdit = false;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PricingLevelEditParticularField", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = pricinglevelinfo.PricinglevelId;
         sprmparam = sccmd.Parameters.Add("@pricinglevelName", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.PricinglevelName;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.Narration;
         int inAffectedRows = sccmd.ExecuteNonQuery();
         if (inAffectedRows > 0)
         {
             isEdit = true;
         }
         else
         {
             isEdit = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return isEdit;
 }
 /// <summary>
 /// Function to insert values to PricingLevel table without same PricingLevel
 /// </summary>
 /// <param name="pricinglevelinfo"></param>
 /// <returns></returns>
 public decimal PricingLevelAddWithoutSamePricingLevel(PricingLevelInfo pricinglevelinfo)
 {
     decimal decPricingLevelId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PricingLevelAddWithoutSamePricingLevel", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@pricinglevelName", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.PricinglevelName;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = pricinglevelinfo.Extra2;
         object obj = sccmd.ExecuteScalar();
         if (obj != null)
         {
             decPricingLevelId = Convert.ToDecimal(obj.ToString());
         }
         else
         {
             decPricingLevelId = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decPricingLevelId;
 }