public void BatchAddParticularFields(BatchInfo batchinfo)
        {
            try
            {

                SPBatch.BatchAddParticularFields(batchinfo);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BBll3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public decimal BatchAddReturnIdentity(BatchInfo batchinfo)
        {
            decimal decReturnValue = 0;
            try
            {
                decReturnValue=SPBatch.BatchAddReturnIdentity(batchinfo);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BBll15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return decReturnValue;
        }
        public decimal BatchAddAndDelete(BatchInfo batchinfo, decimal decProductIdForEdit)
        {
            decimal decReturnValue = 0;
            try
            {
                decReturnValue=SPBatch.BatchAddAndDelete(batchinfo, decProductIdForEdit);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BBll29:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return decReturnValue;
        }
        public int BatchAddWithBarCode(BatchInfo batchinfo)
        {
            int inReturnValue = 0;
               try
               {
               inReturnValue=SPBatch.BatchAddWithBarCode(batchinfo);
               }
               catch (Exception ex)
               {

               MessageBox.Show("BBll18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
               }
               return inReturnValue;
        }
        public bool BatchEditForProductEdit(BatchInfo batchinfo)
        {
            bool isResult = false;
               try
               {

              isResult= SPBatch.BatchEditForProductEdit(batchinfo);
               }
               catch (Exception ex)
               {

               MessageBox.Show("BBll21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
               }
               return isResult;
        }
        public BatchInfo BatchView(decimal batchId)
        {
            BatchInfo batchinfo = new BatchInfo();
            try
            {
                batchinfo=SPBatch.BatchView(batchId);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BBll7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return batchinfo;
        }
        public BatchInfo BatchAndProductViewByBarcode(string strBarcode)
        {
            BatchInfo batchinfo = new BatchInfo();
            try
            {
                batchinfo=SPBatch.BatchAndProductViewByBarcode(strBarcode);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BBll16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return batchinfo;
        }
        public void BatchEdit(BatchInfo batchinfo)
        {
            try
            {

                SPBatch.BatchEdit(batchinfo);
            }
            catch (Exception ex)
            {

                MessageBox.Show("BBll4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to get particular values from Batch Table based on the parameter
 /// </summary>
 /// <param name="batchId"></param>
 /// <returns></returns>
 public BatchInfo BatchView(decimal batchId)
 {
     BatchInfo batchinfo = new BatchInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("BatchView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
         sprmparam.Value = batchId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             batchinfo.BatchId = decimal.Parse(sdrreader["BatchId"].ToString());
             batchinfo.BatchNo = sdrreader["BatchNo"].ToString();
             batchinfo.ProductId = decimal.Parse(sdrreader["ProductId"].ToString());
             batchinfo.ManufacturingDate = DateTime.Parse(sdrreader["ManufacturingDate"].ToString());
             batchinfo.ExpiryDate = DateTime.Parse(sdrreader["ExpiryDate"].ToString());
             batchinfo.Extra1 = sdrreader["Extra1"].ToString();
             batchinfo.Extra2 = sdrreader["Extra2"].ToString();
             batchinfo.narration = (sdrreader["narration"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return batchinfo;
 }
 /// <summary>
 /// Function to Batch Edit For Product Edit
 /// </summary>
 /// <param name="batchinfo"></param>
 /// <returns></returns>
 public bool BatchEditForProductEdit(BatchInfo batchinfo)
 {
     decimal decResult = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("BatchEditForProductEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
         sprmparam.Value = batchinfo.BatchId;
         sprmparam = sccmd.Parameters.Add("@batchNo", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.BatchNo;
         sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = batchinfo.ProductId;
         sprmparam = sccmd.Parameters.Add("@manufacturingDate", SqlDbType.DateTime);
         sprmparam.Value = batchinfo.ManufacturingDate;
         sprmparam = sccmd.Parameters.Add("@expiryDate", SqlDbType.DateTime);
         sprmparam.Value = batchinfo.ExpiryDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.Extra2;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.narration;
         decResult = sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     if (decResult > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
 /// <summary>
 /// Function to Batch And Product View By Barcode
 /// </summary>
 /// <param name="strBarcode"></param>
 /// <returns></returns>
 public BatchInfo BatchAndProductViewByBarcode(string strBarcode)
 {
     BatchInfo batchinfo = new BatchInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("BatchAndProductViewByBarcode", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@barcode", SqlDbType.VarChar);
         sprmparam.Value = strBarcode;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             batchinfo.BatchId = decimal.Parse(sdrreader[0].ToString());
             batchinfo.BatchNo = sdrreader[1].ToString();
             batchinfo.ProductId = decimal.Parse(sdrreader[2].ToString());
             batchinfo.barcode = sdrreader[3].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return batchinfo;
 }
 /// <summary>
 /// Function to Batch Add With BarCode
 /// </summary>
 /// <param name="batchinfo"></param>
 /// <returns></returns>
 public int BatchAddWithBarCode(BatchInfo batchinfo)
 {
     int inResultId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("BatchAddWithBarCode", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@batchNo", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.BatchNo;
         sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = batchinfo.ProductId;
         sprmparam = sccmd.Parameters.Add("@manufacturingDate", SqlDbType.DateTime);
         sprmparam.Value = batchinfo.ManufacturingDate;
         sprmparam = sccmd.Parameters.Add("@expiryDate", SqlDbType.DateTime);
         sprmparam.Value = batchinfo.ExpiryDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.Extra2;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = batchinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.narration;
         sprmparam = sccmd.Parameters.Add("@barcode", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.barcode;
         sprmparam = sccmd.Parameters.Add("@partNo", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.partNo;
         inResultId = Convert.ToInt32(sccmd.ExecuteScalar());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return inResultId;
 }
 /// <summary>
 /// Function to add a Batch with purticular table
 /// </summary>
 /// <param name="batchinfo"></param>
 public void BatchAddParticularFields(BatchInfo batchinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("BatchAddParticularFields", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@batchNo", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.BatchNo;
         sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = batchinfo.ProductId;
         sprmparam = sccmd.Parameters.Add("@barcode", SqlDbType.Decimal);
         sprmparam.Value = batchinfo.barcode;
         sprmparam = sccmd.Parameters.Add("@manufacturingDate", SqlDbType.DateTime);
         sprmparam.Value = batchinfo.ManufacturingDate;
         sprmparam = sccmd.Parameters.Add("@expiryDate", SqlDbType.DateTime);
         sprmparam.Value = batchinfo.ExpiryDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.Extra2;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = batchinfo.narration;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }