Example #1
0
        /// <summary>
        /// Function to insert values to DebitNoteMaster Table
        /// </summary>
        /// <param name="debitnotemasterinfo"></param>
        /// <returns></returns>
        public decimal DebitNoteMasterAdd(DebitNoteMasterInfo debitnotemasterinfo)
        {
            decimal decDebitNoteMasterId = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DebitNoteMasterAdd", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam            = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.VoucherNo;
                sprmparam            = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.InvoiceNo;
                sprmparam            = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.SuffixPrefixId;
                sprmparam            = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value      = debitnotemasterinfo.Date;
                sprmparam            = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.UserId;
                sprmparam            = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.TotalAmount;
                sprmparam            = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.Narration;
                sprmparam            = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.FinancialYearId;
                sprmparam            = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.Extra1;
                sprmparam            = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value      = debitnotemasterinfo.Extra2;
                sprmparam            = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value      = debitnotemasterinfo.VoucherTypeId;
                decDebitNoteMasterId = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decDebitNoteMasterId);
        }
Example #2
0
        /// <summary>
        /// Function to get particular values from DebitNoteMaster table based on the parameter
        /// </summary>
        /// <param name="debitNoteMasterId"></param>
        /// <returns></returns>
        public DebitNoteMasterInfo DebitNoteMasterView(decimal debitNoteMasterId)
        {
            DebitNoteMasterInfo debitnotemasterinfo = new DebitNoteMasterInfo();
            SqlDataReader       sdrreader           = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DebitNoteMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@debitNoteMasterId", SqlDbType.Decimal);
                sprmparam.Value = debitNoteMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    debitnotemasterinfo.DebitNoteMasterId = decimal.Parse(sdrreader[0].ToString());
                    debitnotemasterinfo.VoucherNo         = sdrreader[1].ToString();
                    debitnotemasterinfo.InvoiceNo         = sdrreader[2].ToString();
                    debitnotemasterinfo.SuffixPrefixId    = decimal.Parse(sdrreader[3].ToString());
                    debitnotemasterinfo.Date            = DateTime.Parse(sdrreader[4].ToString());
                    debitnotemasterinfo.VoucherTypeId   = decimal.Parse(sdrreader[5].ToString());
                    debitnotemasterinfo.UserId          = decimal.Parse(sdrreader[6].ToString());
                    debitnotemasterinfo.TotalAmount     = decimal.Parse(sdrreader[7].ToString());
                    debitnotemasterinfo.Narration       = sdrreader[8].ToString();
                    debitnotemasterinfo.FinancialYearId = decimal.Parse(sdrreader[9].ToString());
                    debitnotemasterinfo.ExtraDate       = DateTime.Parse(sdrreader[10].ToString());
                    debitnotemasterinfo.Extra1          = sdrreader[11].ToString();
                    debitnotemasterinfo.Extra2          = sdrreader[12].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(debitnotemasterinfo);
        }