Exemplo n.º 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);
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Function to insert values to Bom Table
 /// </summary>
 /// <param name="bominfo"></param>
 /// <param name="decId"></param>
 public void BomFromDatatable(BomInfo bominfo, decimal decId)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("BomFromDatatable", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = decId;
         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();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Function to Edit tbl_Bom
        /// </summary>
        public void BomTableEditFill()
        {

            try
            {
                BomInfo infoBom = new BomInfo();
                BomSP spBom = new BomSP();
                for (int i = 0; i < dtblFromBomForUpdate.Rows.Count; i++)
                {

                    infoBom.RowmaterialId = Convert.ToDecimal(dtblFromBomForUpdate.Rows[i]["dgvcmbRawMaterial"]);
                    infoBom.UnitId = Convert.ToDecimal(dtblFromBomForUpdate.Rows[i]["dgvtxtUnitId"]);
                    infoBom.Quantity = Convert.ToDecimal(dtblFromBomForUpdate.Rows[i]["dgvtxtQty"]);
                    infoBom.Extra1 = dtblFromBomForUpdate.Rows[i]["extra1"].ToString();
                    infoBom.Extra2 = dtblFromBomForUpdate.Rows[i]["extra2"].ToString();
                    infoBom.ExtraDate = Convert.ToDateTime(dtblFromBomForUpdate.Rows[i]["extraDate"]);
                    infoBom.BomId = Convert.ToDecimal(dtblFromBomForUpdate.Rows[i]["bomId"]);
                    infoBom.ProductId = decProductIdForEdit;
                    spBom.UpdateBom(infoBom);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:10" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Function for new row added for Bom
        /// </summary>
        public void NewRowAddedForBom()
        {

            try
            {
                BomInfo infoBom = new BomInfo();
                BomSP spBom = new BomSP();
                for (int inI = 0; inI < dtblFromBomForUpdate.Rows.Count; inI++)
                {
                    if (Convert.ToDecimal(dtblFromBomForUpdate.Rows[inI]["bomId"]) == 0)
                    {
                        infoBom.RowmaterialId = Convert.ToDecimal(dtblFromBomForUpdate.Rows[inI]["dgvcmbRawMaterial"]);
                        infoBom.UnitId = Convert.ToDecimal(dtblFromBomForUpdate.Rows[inI]["dgvtxtUnitId"]);
                        infoBom.Quantity = Convert.ToDecimal(dtblFromBomForUpdate.Rows[inI]["dgvtxtQty"]);
                        infoBom.Extra1 = dtblFromBomForUpdate.Rows[inI]["extra1"].ToString();
                        infoBom.Extra2 = dtblFromBomForUpdate.Rows[inI]["extra2"].ToString();
                        infoBom.ExtraDate = Convert.ToDateTime(dtblFromBomForUpdate.Rows[inI]["extraDate"]);

                        spBom.BomFromDatatable(infoBom, decProductIdForEdit);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:78" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Function for delete data from tbl_BOM
        /// </summary>
        public void RemoveBom()
        {
            try
            {

                BomInfo infoBom = new BomInfo();
                BomSP spBom = new BomSP();
                int inC = 0;
                while (strArrOfRemoveForBom[inC] != null)
                {
                    decimal decId = Convert.ToDecimal(strArrOfRemoveForBom[inC]);
                    spBom.BomRemoveRows(decId);
                    inC++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:65" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
Exemplo n.º 7
0
        /// <summary>
        /// Function to add data to tbl_Bom
        /// </summary>
        public void BomTableFill()
        {

            try
            {
                BomInfo infoBom = new BomInfo();
                BomSP spBom = new BomSP();
                decimal decProductId;
                if (btnSave.Text == "Update")
                {
                    decProductId = decProductIdForEdit;
                }
                else
                {
                    decProductId = decSaveProduct;
                }

                for (int i = 0; i < dtblBom.Rows.Count; i++)
                {

                    infoBom.RowmaterialId = Convert.ToDecimal(dtblBom.Rows[i]["dgvcmbRawMaterial"]);
                    infoBom.UnitId = Convert.ToDecimal(dtblBom.Rows[i]["dgvtxtUnitId"]);
                    infoBom.Quantity = Convert.ToDecimal(dtblBom.Rows[i]["dgvtxtQty"]);
                    infoBom.Extra1 = dtblBom.Rows[i]["extra1"].ToString();
                    infoBom.Extra2 = dtblBom.Rows[i]["extra2"].ToString();
                    infoBom.ExtraDate = Convert.ToDateTime(dtblBom.Rows[i]["extraDate"]);
                    spBom.BomFromDatatable(infoBom, decProductId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 8
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;
 }