Пример #1
0
        private void buttonUpPro_Click(object sender, EventArgs e)
        {
            this.Visible  = false;
            ShowInTaskbar = false;

            FormEditPro editPro = new FormEditPro();

            editPro.Show();
        }
Пример #2
0
        private void buttonEditProSave_Click(object sender, EventArgs e)
        {
            string Name     = textBoxEditNamePro.Text;
            string Price    = textBoxEditProPrice.Text.ToString();
            string Type     = textBoxEditProType.Text;
            string Brand    = textBoxEditProBrand.Text;
            string Quantity = textBoxEditProQuan.Text;
            string AddQuan  = textBoxEditQuanPro.Text;
            string Date     = labelDateEditPro.Text;
            string Id       = labelEditProId.Text;



            if (Name == "" || Price == "" || Type == "" || Brand == "" || Quantity == "")
            {
                MessageBox.Show("Fields cannot be empty");
                return;
            }
            else

            {
                SqlConnection con = new SqlConnection(@"Data Source=EMMANUELSAL\EMAN_SQL;Initial Catalog=POS1;Integrated Security=True");

                double TotalQuan = double.Parse(textBoxEditProQuan.Text) + double.Parse(textBoxEditQuanPro.Text);
                string Total     = TotalQuan.ToString();

                con.Open();

                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = CommandType.Text;

                cmd.CommandText = "UPDATE addPro SET ProductName= '" + Name + "', UnitPrice= '" + Price + "', ProductType= '" + Type + "' , ProductBrand= '" + Brand + "' , ProductQuantity= '" + Total + "' , DateAdded= '" + Date + "' WHERE ProductId='" + labelEditProId.Text + "'";


                cmd.ExecuteNonQuery();

                con.Close();

                MessageBox.Show("SAVED!");
                this.Visible  = false;
                ShowInTaskbar = false;
                FormEditPro save = new FormEditPro();
                save.Show();
            }
        }