/// <summary>
        /// Function to insert values to PurchaseOrderMaster Table
        /// </summary>
        /// <param name="purchaseordermasterinfo"></param>
        /// <returns></returns>
        public decimal PurchaseOrderMasterAdd(PurchaseOrderMasterInfo purchaseordermasterinfo)
        {
            decimal decIdentity = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("PurchaseOrderMasterAdd", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                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("@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("@exchangeRateId", SqlDbType.Decimal);
                sprmparam.Value = purchaseordermasterinfo.exchangeRateId;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = purchaseordermasterinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = purchaseordermasterinfo.Extra2;
                decIdentity     = Convert.ToDecimal(sccmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decIdentity);
        }
        /// <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);
        }