示例#1
0
        /// <summary>
        /// Function to get particular values from Bom Table based on the parameter
        /// </summary>
        /// <param name="bomId"></param>
        /// <returns></returns>
        public BomInfo BomView(decimal bomId)
        {
            BomInfo       bominfo   = new BomInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("BomView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@bomId", SqlDbType.Decimal);
                sprmparam.Value = bomId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    bominfo.BomId         = decimal.Parse(sdrreader[0].ToString());
                    bominfo.ProductId     = decimal.Parse(sdrreader[1].ToString());
                    bominfo.RowmaterialId = decimal.Parse(sdrreader[2].ToString());
                    bominfo.Quantity      = decimal.Parse(sdrreader[3].ToString());
                    bominfo.UnitId        = decimal.Parse(sdrreader[4].ToString());
                    bominfo.Extra1        = sdrreader[5].ToString();
                    bominfo.Extra2        = sdrreader[6].ToString();
                    bominfo.ExtraDate     = DateTime.Parse(sdrreader[7].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(bominfo);
        }
示例#2
0
 /// <summary>
 /// Function to Update values in Bom table
 /// </summary>
 /// <param name="bominfo"></param>
 public void UpdateBom(BomInfo bominfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("UpdateBom", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@bomId", SqlDbType.Decimal);
         sprmparam.Value = bominfo.BomId;
         sprmparam       = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = bominfo.ProductId;
         sprmparam       = sccmd.Parameters.Add("@rowmaterialId", SqlDbType.Decimal);
         sprmparam.Value = bominfo.RowmaterialId;
         sprmparam       = sccmd.Parameters.Add("@quantity", SqlDbType.Decimal);
         sprmparam.Value = bominfo.Quantity;
         sprmparam       = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal);
         sprmparam.Value = bominfo.UnitId;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = bominfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = bominfo.Extra2;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = bominfo.ExtraDate;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }