protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnupdate.Visible = false;
                ItemName.Visible  = false;
                lblnewqty.Visible = false;
                newQty.Visible    = false;
                LoadData();
                LoadDataItem();

                if (Request.QueryString["ID"] != null)
                {
                    ItemName.Visible  = true;
                    Quentity.Enabled  = false;
                    dropItem.Visible  = false;
                    btnupdate.Visible = true;
                    lblnewqty.Visible = true;
                    newQty.Visible    = true;
                    btnsave.Visible   = false;
                    StockID           = Request.QueryString["ID"];
                    REF_Stock oREF_Stock = new REF_Stock();
                    oREF_Stock.ID = StockID;
                    LoadData(oREF_Stock);
                }
                else
                {
                }
            }
            StockID = Request.QueryString["ID"];
        }
Example #2
0
        public DataTable SelectStockID(REF_Stock oREF_Stock)
        {
            DBConnecton db;

            db = new DBConnecton();
            DataTable dataTable = new DataTable();
            string    query     = "SELECT * FROM `tblstock` WHERE `ID`='" + oREF_Stock.ID + "'";

            //Open connection
            if (db.OpenConnection() == true)
            {
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, db.getConnetion());
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                DataSet ds = new DataSet();

                ds.Tables.Add(dataTable);
                ds.EnforceConstraints = false;
                dataTable.Load(dataReader);
                dataReader.Close();

                //close Connection
                db.CloseConnection();

                //return list to be displayed
                return(dataTable);
            }
            else
            {
                return(dataTable);
            }
        }
Example #3
0
        public void Insert(REF_Stock oREF_Stock)
        {
            DBConnecton db;

            db = new DBConnecton();
            string     sqlQuery;
            SqlCommand oSqlCommand;

            try

            {
                sqlQuery = "INSERT INTO `tblstock` (`ID`, `ItemID`, `Qty`, `Status`) VALUES (NULL, '" + oREF_Stock.ItemID + "', '" + oREF_Stock.Qty + "', '0');";

                //open connection
                if (db.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(sqlQuery, db.getConnetion());

                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    db.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        public void Update(REF_Stock oREF_Stock)
        {
            DBConnecton db;

            db = new DBConnecton();
            string     sqlQuery;
            SqlCommand oSqlCommand;

            try

            {
                sqlQuery = "UPDATE `tblstock` SET `Qty` = '" + oREF_Stock.Qty + "' WHERE `tblstock`.`ID` = " + oREF_Stock.ID + "";

                //open connection
                if (db.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(sqlQuery, db.getConnetion());

                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    db.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void btnupdate_Click(object sender, EventArgs e)
        {
            REF_Stock oREF_Stock = new REF_Stock();
            DAC_Stock oDAC_Stock = new DAC_Stock();

            oREF_Stock.ID     = StockID;
            oREF_Stock.ItemID = ItemName.Text;
            int Qty = Convert.ToInt32(Quentity.Text) + Convert.ToInt32(newQty.Text);

            oREF_Stock.Qty = Qty.ToString();
            oDAC_Stock.Update(oREF_Stock);
            Response.Redirect("./frmStock.aspx", true);
        }
 public void LoadData(REF_Stock oREF_Stock)
 {
     try
     {
         DataTable dt;
         DAC_Stock oDAC_Stock = new DAC_Stock();
         dt = oDAC_Stock.SelectStockID(oREF_Stock);
         ItemName.Enabled = false;
         ItemName.Text    = dt.Rows[0][1].ToString();
         Quentity.Text    = dt.Rows[0][2].ToString();
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                REF_Stock oREF_Stock = new REF_Stock();
                DAC_Stock oDAC_Stock = new DAC_Stock();

                oREF_Stock.ItemID = dropItem.Value;
                oREF_Stock.Qty    = Quentity.Text;
                oDAC_Stock.Insert(oREF_Stock);
                Response.Redirect("./frmStock.aspx", true);
            }
            catch (Exception ex)
            {
                ShowMessage("Something went wrong! Please try again!");
            }
        }