예제 #1
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to transfer all data of " + textBox1.Text + " to " + textBox2.Text, "Transfer", MessageBoxButtons.YesNo);

            SupplierBL bl = new SupplierBL();
            SupplierBO bo = new SupplierBO();

            bo.supp1 = textBox2.Text;
            bool notExistTextBox2 = true;

            foreach (DataRow row in bl.searchSupp(bo).Rows)
            {
                notExistTextBox2 = false;
            }
            bo.supp1 = textBox1.Text;
            bool notExistText1 = true;

            foreach (DataRow row in bl.searchSupp(bo).Rows)
            {
                notExistText1 = false;
            }
            if (dialogResult == DialogResult.Yes)
            {
                if (!notExistTextBox2)
                {
                    if (!notExistText1)
                    {
                        bo.supp1 = textBox2.Text;
                        bo.supp2 = textBox1.Text;
                        bl.updateIngSuppOnly(bo);
                        textBox2.Text = "";
                        textBox1.Text = "";
                        loadSupplier();
                        MessageBox.Show("Success!");
                    }
                    else
                    {
                        MessageBox.Show("There's no such a supplier named " + textBox1.Text);
                    }
                }
                else
                {
                    MessageBox.Show("There's no such a supplier named " + textBox2.Text);
                }
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to rename supplier named " + textBox1.Text + " to " + textBox2.Text, "Update", MessageBoxButtons.YesNo);
            SupplierBL   BL           = new SupplierBL();
            SupplierBO   BO           = new SupplierBO();

            BO.supp1 = textBox1.Text;
            bool notExistText1 = true;

            foreach (DataRow row in BL.searchSupp(BO).Rows)
            {
                notExistText1 = false;
            }
            try
            {
                if (!notExistText1)
                {
                    if (textBox2.Text != "")
                    {
                        BO.old   = selectedsupp;
                        BO.supp1 = textBox2.Text.Trim();
                        BL.updateSupplier(BO);
                        loadSupplier();
                        textBox1.Text = "";
                        textBox2.Text = ""; MessageBox.Show("Success!");
                    }
                    else
                    {
                        MessageBox.Show("Please input the altered name of supplier!");
                    }
                }
                else
                {
                    MessageBox.Show("There's no such a supplier named " + textBox1.Text);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Entered supplier is already registered!");
            }
        }
예제 #3
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            SupplierBL   bl           = new SupplierBL();
            SupplierBO   bo           = new SupplierBO();
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + textBox1.Text + " and transfer the data to " + textBox2.Text + Environment.NewLine + Environment.NewLine +
                                                        "NOTE : All data of deleted supplier will be transfered to " + textBox2.Text + Environment.NewLine + Environment.NewLine +
                                                        "ADVICE : If you there's no substitute for the deletion , create a temporary supplier that will be dummy of deleted supplier to keep the data accurate", "Delete Supplier", MessageBoxButtons.YesNo);

            bo.supp1 = textBox2.Text;
            bool notExistTextBox2 = true;

            foreach (DataRow row in bl.searchSupp(bo).Rows)
            {
                notExistTextBox2 = false;
            }
            if (dialogResult == DialogResult.Yes)
            {
                if (textBox2.Text != "")
                {
                    if (!notExistTextBox2)
                    {
                        bo.supp1 = textBox1.Text;
                        bo.supp2 = textBox2.Text;
                        bl.delSupp(bo);
                        textBox2.Text = "";
                        textBox1.Text = "";
                        loadSupplier(); MessageBox.Show("Success!");
                    }
                    else
                    {
                        MessageBox.Show("There's no such a supplier named " + textBox2.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Please input the destination of deleted supplier's data");
                }
            }
        }