Beispiel #1
0
        public void ProductBatchEdit(ProductBatchInfo productbatchinfo)
        {
            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ProductBatchEdit", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@productBatchId", SqlDbType.Decimal);
                sprmparam.Value = productbatchinfo.ProductBatchId;
                sprmparam       = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
                sprmparam.Value = productbatchinfo.ProductId;
                sprmparam       = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
                sprmparam.Value = productbatchinfo.BatchId;
                sprmparam       = sccmd.Parameters.Add("@partNo", SqlDbType.VarChar);
                sprmparam.Value = productbatchinfo.PartNo;
                sprmparam       = sccmd.Parameters.Add("@barcode", SqlDbType.VarChar);
                sprmparam.Value = productbatchinfo.Barcode;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = productbatchinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = productbatchinfo.Extra2;
                sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam.Value = productbatchinfo.ExtraDate;
                sccmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            finally
            {
                sqlcon.Close();
            }
        }
Beispiel #2
0
        public ProductBatchInfo ProductBatchView(decimal productBatchId)
        {
            ProductBatchInfo productbatchinfo = new ProductBatchInfo();
            SqlDataReader    sdrreader        = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ProductBatchView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@productBatchId", SqlDbType.Decimal);
                sprmparam.Value = productBatchId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    productbatchinfo.ProductBatchId = decimal.Parse(sdrreader[0].ToString());
                    productbatchinfo.ProductId      = decimal.Parse(sdrreader[1].ToString());
                    productbatchinfo.BatchId        = decimal.Parse(sdrreader[2].ToString());
                    productbatchinfo.PartNo         = sdrreader[3].ToString();
                    productbatchinfo.Barcode        = sdrreader[4].ToString();
                    productbatchinfo.Extra1         = sdrreader[5].ToString();
                    productbatchinfo.Extra2         = sdrreader[6].ToString();
                    productbatchinfo.ExtraDate      = DateTime.Parse(sdrreader[7].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            { sdrreader.Close();
              sqlcon.Close(); }
            return(productbatchinfo);
        }