예제 #1
0
        private void BtnUpdateMinStock_Click(object sender, EventArgs e)
        {
            StockBAL sb = new StockBAL();
            StockDAL sd = new StockDAL();

            if (TxtMinStockQty.Text.Trim() != "")
            {
                sb.ProductID = ProductID;
                sb.Quantity  = Convert.ToInt32(TxtMinStockQty.Text.Trim());
                int Result = sd.UpdateMinimumStock(sb);
                if (Result == 1)
                {
                    MessageBox.Show("Minimum Stock Updated Succesfully");
                    LoadDGVStock();
                }
                else
                {
                    MessageBox.Show("Something Went Wrong");
                }
            }
            else
            {
                MessageBox.Show("Minimum Stock Cannot be empty");
            }
        }
예제 #2
0
        private void BtnAddStock_Click(object sender, EventArgs e)
        {
            StockBAL sb = new StockBAL();
            StockDAL sd = new StockDAL();

            if (TxtProductName.Text.Trim() != "")
            {
                LoadProductID();
                sb.ProductID = ProductID;
                sb.Quantity  = Convert.ToInt32(TxtQuantity.Text.Trim());
                int Result = sd.AddStockDetails(sb);
                if (Result == 1)
                {
                    MessageBox.Show("Product Added Succesfully");
                    LoadDGVStock();
                }
                else
                {
                    MessageBox.Show("Something Went Wrong");
                }
            }
            else
            {
                MessageBox.Show("Product Name Cannot be empty");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //System.Timers.Timer aTimer = new System.Timers.Timer();
            //aTimer.Elapsed += new ElapsedEventHandler(Page_Load);
            //aTimer.Interval = 1000;
            //aTimer.Enabled = true;
            if (!IsPostBack)
            {
                List <Stock> stockes = StockBAL.GetAll();
                grd_view.Visible = true;
                //grd_view2.Visible = true;
                DataTable dt  = new DataTable();
                DataTable dt2 = new DataTable();

                for (int i = 0; i < stockes.Capacity; i++)
                {
                    DataRow toInsert  = dt.NewRow();
                    DataRow toInsert2 = dt.NewRow();
                    dt.Rows.InsertAt(toInsert, i);
                    dt.Rows.InsertAt(toInsert2, i);
                }

                grd_view2.DataSource = stockes;
                grd_view.DataSource  = stockes;
                grd_view.DataBind();
                grd_view2.DataBind();

                //Response.AppendHeader("Refresh", "10");
            }
        }
        protected void Timer1_Tick(object sender, EventArgs e)
        {
            //var labels = new List<Label> { lbl0 , lbl1 };

            //foreach (var label in labels)
            //{
            //    label.Text = StockBAL.GetStockPrice();
            //}

            //Label1.Text = StockBAL.GetStockPrice();
            txt.Text         = StockBAL.GetStockPrice();
            TimeOfPrice.Text = DateTime.Now.ToLongTimeString();
        }
예제 #5
0
 public int AddStockDetails(StockBAL S)
 {
     try
     {
         DataTable dt  = CheckProductByID(S.ProductID);
         int       Res = 0;
         foreach (DataRow dr in dt.Rows)
         {
             Res = Convert.ToInt32(dr[0].ToString());
         }
         if (Res == 0)
         {
             using (C.Con)
             {
                 MySqlCommand cmd = new MySqlCommand("AddStock", C.Con)
                 {
                     CommandType = CommandType.StoredProcedure
                 };
                 cmd.Parameters.Add(new MySqlParameter("P_ID", S.ProductID));
                 cmd.Parameters.Add(new MySqlParameter("Quantity", S.Quantity));
                 cmd.Connection.Open();
                 int Result = cmd.ExecuteNonQuery();
                 C.Con.Close();
                 return(Result);
             }
         }
         else
         {
             using (C.Con)
             {
                 MySqlCommand cmd = new MySqlCommand("UpdateStock", C.Con)
                 {
                     CommandType = CommandType.StoredProcedure
                 };
                 cmd.Parameters.Add(new MySqlParameter("Pro_ID", S.ProductID));
                 cmd.Parameters.Add(new MySqlParameter("Quantity", S.Quantity));
                 cmd.Connection.Open();
                 int Result = cmd.ExecuteNonQuery();
                 C.Con.Close();
                 return(Result);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         throw;
     }
 }
예제 #6
0
        private void TxtQuantity_KeyPress(object sender, KeyPressEventArgs e)
        {
            const int BACKSPACE = 8;
            const int ZERO      = 48;
            const int NINE      = 57;
            //const int NOT_FOUND = -1;
            int keyvalue = (int)e.KeyChar;

            if ((keyvalue == BACKSPACE) ||
                ((keyvalue >= ZERO) && (keyvalue <= NINE)))
            {
                return;
            }
            //Allow the first (but only the first) decimal point
            //if ((keyvalue == DECIMAL_POINT) &&
            //(TextPostCode.Text.IndexOf(".") == NOT_FOUND)) return;
            //Allow nothing else
            e.Handled = true;

            if (e.KeyChar == 13)
            {
                StockBAL sb = new StockBAL();
                StockDAL sd = new StockDAL();
                if (TxtProductName.Text.Trim() != "")
                {
                    LoadProductID();
                    sb.ProductID = ProductID;
                    sb.Quantity  = Convert.ToInt32(TxtQuantity.Text.Trim());
                    int Result = sd.AddStockDetails(sb);
                    if (Result == 1)
                    {
                        MessageBox.Show("Product Added Succesfully");
                        LoadDGVStock();
                    }
                    else
                    {
                        MessageBox.Show("Something Went Wrong");
                    }
                }
                else
                {
                    MessageBox.Show("Product Name Cannot be empty");
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Label3.Text = Session[0].ToString();
         List <Broker> brokers = BrokerBAL.GetBrokers();
         List <Person> persons = PersonBAL.GetPersons();
         List <Stock>  stockes = StockBAL.GetTwoStock();
         List <Order>  orders  = OrderBAL.GetAllOrders();
         grd_view.Visible = true;
         DataTable dt = new DataTable();
         //dt.Columns.Add("Quantity", typeof(int));
         grd_view.DataSource = orders;
         grd_view.DataBind();
         grd_view2.DataSource = stockes;
         grd_view2.DataBind();
         grd_view3.DataSource = persons;
         grd_view3.DataBind();
         grd_view4.DataSource = brokers;
         grd_view4.DataBind();
     }
 }
예제 #8
0
 public int UpdateMinimumStock(StockBAL S)
 {
     try
     {
         using (C.Con)
         {
             MySqlCommand cmd = new MySqlCommand("UpdateMinStockQty", C.Con)
             {
                 CommandType = CommandType.StoredProcedure
             };
             cmd.Parameters.Add(new MySqlParameter("Pro_ID", S.ProductID));
             cmd.Parameters.Add(new MySqlParameter("Quantity", S.Quantity));
             cmd.Connection.Open();
             int Result = cmd.ExecuteNonQuery();
             C.Con.Close();
             return(Result);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         throw;
     }
 }