/// <summary>
 /// Function to insert values to Counter Table
 /// </summary>
 /// <param name="counterinfo"></param>
 public void CounterAdd(CounterInfo counterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CounterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@counterName", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.CounterName;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 public bool CounterEditParticularField(CounterInfo counterinfo)
 {
     bool isEdit = false;
     try
     {
         isEdit = spCounter.CounterEditParticularField(counterinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CBLL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return isEdit;
 }
 public decimal CounterAddWithIdentity(CounterInfo CounterInfo)
 {
     decimal decLedgerId = 0;
     try
     {
         decLedgerId = spCounter.CounterAddWithIdentity(CounterInfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CBLL:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return decLedgerId;
 }
 /// <summary>
 /// Function to insert values to Counter Table
 /// </summary>
 /// <param name="counterinfo"></param>
 /// <returns></returns>
 public bool CounterAddSpecificFeilds(CounterInfo counterinfo)
 {
     bool isSave = false;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CounterAddSpecificFeilds", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@counterName", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.CounterName;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.Extra2;
         int inWork = sccmd.ExecuteNonQuery();
         if (inWork > 0)
         {
             isSave = true;
         }
         else
         {
             isSave = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return isSave;
 }
 public CounterInfo CounterWithNarrationView(decimal decCounterId)
 {
     CounterInfo counterinfo = new CounterInfo();
     try
     {
         counterinfo = spCounter.CounterWithNarrationView(decCounterId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CBLL:5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return counterinfo;
 }
 /// <summary>
 /// Counter view with narration 
 /// </summary>
 /// <param name="decCounterId"></param>
 /// <returns></returns>
 public CounterInfo CounterWithNarrationView(decimal decCounterId)
 {
     CounterInfo counterinfo = new CounterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CounterWithNarrationView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@counterId", SqlDbType.Decimal);
         sprmparam.Value = decCounterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             counterinfo.CounterId = Convert.ToDecimal(sdrreader[0].ToString());
             counterinfo.CounterName = sdrreader[1].ToString();
             counterinfo.Narration = sdrreader[2].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return counterinfo;
 }
 /// <summary>
 /// Function to Update values in Counter Table
 /// </summary>
 /// <param name="counterinfo"></param>
 /// <returns></returns>
 public bool CounterEditParticularField(CounterInfo counterinfo)
 {
     bool isEdit = false;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("counterEditParticularField", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@counterId", SqlDbType.Decimal);
         sprmparam.Value = counterinfo.CounterId;
         sprmparam = sccmd.Parameters.Add("@counterName", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.CounterName;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = counterinfo.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 Counter Table
 /// </summary>
 /// <param name="CounterInfo"></param>
 /// <returns></returns>
 public decimal CounterAddWithIdentity(CounterInfo CounterInfo)
 {
     decimal decLedgerId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CounterAddWithIdentity", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@counterName", SqlDbType.VarChar);
         sprmparam.Value = CounterInfo.CounterName;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = CounterInfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = CounterInfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = CounterInfo.Extra2;
         object obj = sccmd.ExecuteScalar();
         if (obj != null)
         {
             decLedgerId = Convert.ToDecimal(obj.ToString());
         }
         else
         {
             decLedgerId = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decLedgerId;
 }