Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            UpdateDBlink ul = new UpdateDBlink();

            ai = ul.getAdmin(textBox1.Text);

            string pass;

            if (textBox1.Text == ai.UName && ai.UStatus == "Admin")
            {
                if (textBox2.Text == ai.Pword)
                {
                    /* HomeAdmin h = new HomeAdmin(ai);
                     * h.Show();
                     * this.Visible = false;
                     */
                    AdminHome h = new AdminHome(ai);
                    h.Show();
                    this.Visible = false;
                }
                else
                {
                    MessageBox.Show("Wrong Password or Username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                ui   = ul.getUser(textBox1.Text);
                pass = ul.getPassword(textBox1.Text);

                if (textBox2.Text == pass)
                {
                    UserHome h = new UserHome(ui);
                    h.Show();
                    this.Visible = false;
                }
                else
                {
                    MessageBox.Show("Wrong Password or Username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || comboBox1.SelectedIndex.ToString() == "Select" || comboBox2.SelectedIndex.ToString() == "Select" || numericUpDown1.Value == 0)
            {
                MessageBox.Show("Please fill all the field properly", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                pp.ProductName  = textBox1.Text;
                pp.PID          = textBox2.Text;
                pp.Quantity     = Convert.ToInt32(numericUpDown1.Value);
                pp.BuyingPrice  = Convert.ToSingle(textBox3.Text);
                pp.SellingPrice = Convert.ToSingle(textBox4.Text);
                pp.Product_Type = textBox5.Text;
                pp.DivisionP    = comboBox1.SelectedItem.ToString();
                pp.DistrictsP   = comboBox2.SelectedItem.ToString();



                ProductInfo p = new ProductInfo
                {
                    Name         = pp.ProductName,
                    ProductType  = pp.Product_Type,
                    Division     = pp.DivisionP,
                    Districts    = pp.DistrictsP,
                    Quantity     = pp.Quantity,
                    BuyingPrice  = pp.BuyingPrice,
                    SellingPrice = pp.SellingPrice,
                    PId          = pp.PID,
                    Profit       = Convert.ToSingle(textBox4.Text) - Convert.ToSingle(textBox3.Text),
                };
                pm.ProductInfos.InsertOnSubmit(p);
                pm.SubmitChanges();
                MessageBox.Show("Add Successfully", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);


                AdminHome h = new AdminHome(ai);
                h.Show();
                this.Visible = false;
            }
        }