Пример #1
0
        /// <summary>
        /// Function to get particular values from StockPosting Table based on the parameter
        /// </summary>
        /// <param name="stockPostingId"></param>
        /// <returns></returns>
        public StockPostingInfo StockPostingView(decimal stockPostingId)
        {
            StockPostingInfo stockpostinginfo = new StockPostingInfo();
            SqlDataReader    sdrreader        = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("StockPostingView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@stockPostingId", SqlDbType.Decimal);
                sprmparam.Value = stockPostingId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    stockpostinginfo.StockPostingId       = decimal.Parse(sdrreader[0].ToString());
                    stockpostinginfo.Date                 = DateTime.Parse(sdrreader[1].ToString());
                    stockpostinginfo.VoucherTypeId        = decimal.Parse(sdrreader[2].ToString());
                    stockpostinginfo.VoucherNo            = sdrreader[3].ToString();
                    stockpostinginfo.InvoiceNo            = sdrreader[4].ToString();
                    stockpostinginfo.ProductId            = decimal.Parse(sdrreader[5].ToString());
                    stockpostinginfo.BatchId              = decimal.Parse(sdrreader[6].ToString());
                    stockpostinginfo.UnitId               = decimal.Parse(sdrreader[7].ToString());
                    stockpostinginfo.GodownId             = decimal.Parse(sdrreader[8].ToString());
                    stockpostinginfo.RackId               = decimal.Parse(sdrreader[9].ToString());
                    stockpostinginfo.AgainstVoucherTypeId = decimal.Parse(sdrreader[10].ToString());
                    stockpostinginfo.AgainstInvoiceNo     = sdrreader[11].ToString();
                    stockpostinginfo.AgainstVoucherNo     = sdrreader[12].ToString();
                    stockpostinginfo.InwardQty            = decimal.Parse(sdrreader[13].ToString());
                    stockpostinginfo.OutwardQty           = decimal.Parse(sdrreader[14].ToString());
                    stockpostinginfo.Rate                 = decimal.Parse(sdrreader[15].ToString());
                    stockpostinginfo.FinancialYearId      = decimal.Parse(sdrreader[16].ToString());
                    stockpostinginfo.ExtraDate            = DateTime.Parse(sdrreader[17].ToString());
                    stockpostinginfo.Extra1               = sdrreader[18].ToString();
                    stockpostinginfo.Extra2               = sdrreader[19].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(stockpostinginfo);
        }
Пример #2
0
        /// <summary>
        /// Function to Update values in StockPosting Table
        /// </summary>
        /// <param name="stockpostinginfo"></param>
        /// <returns></returns>
        public bool StockPostingEdit(StockPostingInfo stockpostinginfo)
        {
            decimal decresult = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("StockPostingEdit", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@stockPostingId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.StockPostingId;
                sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = stockpostinginfo.Date;
                sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.VoucherTypeId;
                sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value = stockpostinginfo.VoucherNo;
                sprmparam       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value = stockpostinginfo.InvoiceNo;
                sprmparam       = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.ProductId;
                sprmparam       = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.BatchId;
                sprmparam       = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.UnitId;
                sprmparam       = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.GodownId;
                sprmparam       = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.RackId;
                sprmparam       = sccmd.Parameters.Add("@againstVoucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.AgainstVoucherTypeId;
                sprmparam       = sccmd.Parameters.Add("@againstInvoiceNo", SqlDbType.VarChar);
                sprmparam.Value = stockpostinginfo.AgainstInvoiceNo;
                sprmparam       = sccmd.Parameters.Add("@againstVoucherNo", SqlDbType.VarChar);
                sprmparam.Value = stockpostinginfo.AgainstVoucherNo;
                sprmparam       = sccmd.Parameters.Add("@inwardQty", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.InwardQty;
                sprmparam       = sccmd.Parameters.Add("@outwardQty", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.OutwardQty;
                sprmparam       = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.Rate;
                sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value = stockpostinginfo.FinancialYearId;
                sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam.Value = stockpostinginfo.ExtraDate;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = stockpostinginfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = stockpostinginfo.Extra2;
                decresult       = sccmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            if (decresult > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }