示例#1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            string Delete;
            string Select;

            if (this.richTextBoxSQLCondition.Text == "")
            {
                Delete = "delete from Product";
                DialogConfirmationP conf = new DialogConfirmationP();
                Important.message = "Doriti sa stergeti toate datele din tabel?";
                conf.label1.Text  = Important.message;
                conf.ShowDialog();
            }

            else
            {
                Delete = "delete from Product where " + this.richTextBoxSQLCondition.Text;
                DialogConfirmationP conf = new DialogConfirmationP();
                Important.message = "Doriti sa stergeti aceste date din tabel?";
                conf.label1.Text  = Important.message;
                conf.ShowDialog();
            }

            if (Important.confirm == true)
            {
                try
                {
                    SqlCommand del = new SqlCommand(Delete, Important.conex);
                    del.ExecuteNonQuery();
                }

                catch (Exception ex)
                {
                    Important.message = ex.GetType().ToString();
                    DialogMessageP dial = new DialogMessageP();
                    dial.ShowDialog();
                }
            }

            Select = "select * from Product";
            SqlCommand     sel = new SqlCommand(Select, Important.conex);
            SqlDataAdapter da  = new SqlDataAdapter(sel);
            DataSet        ds  = new DataSet();

            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];

            this.textBox1.Text  = "";
            this.textBox2.Text  = "";
            this.textBox3.Text  = "";
            this.textBox4.Text  = "";
            this.textBox5.Text  = "";
            this.textBox6.Text  = "";
            this.textBox7.Text  = "";
            this.textBox8.Text  = "";
            this.textBox9.Text  = "";
            this.textBox10.Text = "";
            this.richTextBoxSQLCondition.Text = "";
        }
示例#2
0
        private void buttonBuy_Click(object sender, EventArgs e)
        {
            DialogMessageP dial = new DialogMessageP();
            DialogConfirmationP conf = new DialogConfirmationP();
            string Query = "Select Charge from _User where Username = '******';";

            try
            {
                if (Convert.ToInt32(this.textBoxQuan.Text) < 1)
                {
                    Important.message = "Selecteaza cantitatea dorita de produse!";
                    dial.ShowDialog();
                }

                else
                {
                    SqlCommand money = new SqlCommand(Query, Important.conex);
                    double charge = Convert.ToDouble(money.ExecuteScalar().ToString());

                    if (charge < AmountMoney)
                    {
                        Important.message = "Nu aveti bani suficienti!";
                        dial.ShowDialog();
                    }

                    else
                    {
                        Important.message = "Sunteti siguri ca doriti sa cumparati acest produs?";
                        conf.ShowDialog();

                        if (Important.confirm == true)
                        {
                            BuyProductTransaction();
                            Important.message = "Va multumim pentru ca ati cumparat acest produs!";
                            dial.ShowDialog();
                        }
                    }
                }
            }
            catch { }
        }