public PurchaseOrderMasterInfo PurchaseOrderMasterView(decimal purchaseOrderMasterId)
 {
     PurchaseOrderMasterInfo purchaseordermasterinfo = new PurchaseOrderMasterInfo();
     PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP();
     try
     {
         purchaseordermasterinfo = SPPurchaseOrderMaster.PurchaseOrderMasterView(purchaseOrderMasterId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("PoBll 1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return purchaseordermasterinfo;
 }
        public void PurchaseOrderMasterEdit(PurchaseOrderMasterInfo purchaseordermasterinfo)
        {
            PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP();

             try
             {
                 SPPurchaseOrderMaster.PurchaseOrderMasterEdit(purchaseordermasterinfo);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("PoBll 19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
        }
 /// <summary>
 /// Function to get particular values from PurchaseOrderMaster table based on the parameter
 /// </summary>
 /// <param name="purchaseOrderMasterId"></param>
 /// <returns></returns>
 public PurchaseOrderMasterInfo PurchaseOrderMasterView(decimal purchaseOrderMasterId)
 {
     PurchaseOrderMasterInfo purchaseordermasterinfo = new PurchaseOrderMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PurchaseOrderMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@purchaseOrderMasterId", SqlDbType.Decimal);
         sprmparam.Value = purchaseOrderMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             purchaseordermasterinfo.VoucherNo = sdrreader["voucherNo"].ToString();
             purchaseordermasterinfo.InvoiceNo = sdrreader["invoiceNo"].ToString();
             purchaseordermasterinfo.SuffixPrefixId = decimal.Parse(sdrreader["suffixPrefixId"].ToString());
             purchaseordermasterinfo.VoucherTypeId = decimal.Parse(sdrreader["voucherTypeId"].ToString());
             purchaseordermasterinfo.Date = DateTime.Parse(sdrreader["date"].ToString());
             purchaseordermasterinfo.LedgerId = decimal.Parse(sdrreader["ledgerId"].ToString());
             purchaseordermasterinfo.DueDate = DateTime.Parse(sdrreader["dueDate"].ToString());
             purchaseordermasterinfo.Narration = sdrreader["narration"].ToString();
             purchaseordermasterinfo.TotalAmount = decimal.Parse(sdrreader["totalAmount"].ToString());
             purchaseordermasterinfo.exchangeRateId = decimal.Parse(sdrreader["exchangeRateId"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return purchaseordermasterinfo;
 }
 public decimal PurchaseOrderMasterAdd(PurchaseOrderMasterInfo purchaseordermasterinfo)
 {
     PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP();
      decimal decIdentity = 0;
      try
      {
          decIdentity = SPPurchaseOrderMaster.PurchaseOrderMasterAdd(purchaseordermasterinfo);
      }
      catch (Exception ex)
      {
          MessageBox.Show("PoBll 21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
      }
      return decIdentity;
 }
 /// <summary>
 /// Function to Update values in PurchaseOrderMaster Table
 /// </summary>
 /// <param name="purchaseordermasterinfo"></param>
 public void PurchaseOrderMasterEdit(PurchaseOrderMasterInfo purchaseordermasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PurchaseOrderMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@purchaseOrderMasterId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.PurchaseOrderMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = purchaseordermasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.exchangeRateId;
         sprmparam = sccmd.Parameters.Add("@dueDate", SqlDbType.DateTime);
         sprmparam.Value = purchaseordermasterinfo.DueDate;
         sprmparam = sccmd.Parameters.Add("@cancelled", SqlDbType.Bit);
         sprmparam.Value = purchaseordermasterinfo.Cancelled;
         sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.EmployeeId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }