Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (isCheck == 0)
            {
                try
                {
                    nsx.TenSx   = txtTenNhaSx.Text;
                    nsx.QuocGia = txtQuocGia.Text;

                    bool result = nsxbll.InserNhaSx(nsx);
                    if (result)
                    {
                        DialogResult dialogResultInsert = MessageBox.Show("Insert Successful!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (dialogResultInsert == DialogResult.OK)
                        {
                            EnableHome();
                            TurnOffTextBox(false);
                            HienThiNhaSanxuat();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Insert Error!" + "\n\n\t" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (isCheck == 1)
            {
                try
                {
                    nsx.MaSx    = int.Parse(txtMaNhaSx.Text);
                    nsx.TenSx   = txtTenNhaSx.Text;
                    nsx.QuocGia = txtQuocGia.Text;

                    bool result = nsxbll.EditNhaSx(nsx);
                    if (result)
                    {
                        DialogResult dialogResultInsert = MessageBox.Show("Edit Successful!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (dialogResultInsert == DialogResult.OK)
                        {
                            EnableHome();
                            TurnOffTextBox(false);
                            btnDelete.Enabled = true;
                            HienThiNhaSanxuat();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Edit Error!" + "\n\n\t" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            nsx.TenSx   = txtTenNhaSx.Text;
            nsx.QuocGia = txtQuocGia.Text;
            nsx.MaSx    = int.Parse(txtMaNhaSx.Text);

            bool result = nsxbll.EditNhaSx(nsx);

            if (result)
            {
                HienThiNhaSanXuat();
            }
            else
            {
                MessageBox.Show("Inser Provider not success !");
            }
        }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool check = false;

            if (isCheck == 0)
            {
                try
                {
                    int n = 0;
                    if (txtTenSx.Text == "")
                    {
                        lbTenSx.Visible = true;
                        check           = false;
                        lbTenSx.Text    = "* Tên Nhà Sản Xuất không được để trống! *";
                    }
                    else
                    {
                        if (int.TryParse(txtTenSx.Text, out n))
                        {
                            lbTenSx.Visible = true;
                            check           = false;
                            lbTenSx.Text    = "* Tên Nhà Sản Xuất không được phép là số! *";
                        }
                        else
                        {
                            lbTenSx.Visible = false;
                            check           = true;
                            nsx.TenSx       = txtTenSx.Text;
                        }
                    }

                    if (txtQuocGia.Text == "")
                    {
                        lbQuocGia.Visible = true;
                        check             = false;
                        lbQuocGia.Text    = "* Trường Quốc Gia không được để trống! *";
                    }
                    else
                    {
                        if (int.TryParse(txtQuocGia.Text, out n))
                        {
                            lbQuocGia.Visible = true;
                            check             = false;
                            lbQuocGia.Text    = "* Giá trị trường Quốc Gia không được phép là số *";
                        }
                        else
                        {
                            lbQuocGia.Visible = false;
                            check             = true;
                            nsx.QuocGia       = txtQuocGia.Text;
                        }
                    }

                    if (check == true)
                    {
                        bool result = nsxbll.InserNhaSx(nsx);
                        if (result)
                        {
                            DialogResult dialogResultInsert = MessageBox.Show("Insert Successful!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            if (dialogResultInsert == DialogResult.OK)
                            {
                                EnableHome();
                                TurnOffTextBox(false);
                                HienThiNhaSanxuat();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Insert Error!" + "\n\n\t" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (isCheck == 1)
            {
                try
                {
                    int n = 0;
                    if (txtMaSx.Text == "")
                    {
                        lbMaSx.Visible = true;
                        check          = false;
                        lbMaSx.Text    = "* Bạn phải chọn nhà sản xuất cần sửa trước!*";
                        return;
                    }
                    else
                    {
                        lbMaSx.Visible = false;
                        check          = true;
                        nsx.MaSx       = int.Parse(txtMaSx.Text);
                    }

                    if (txtTenSx.Text == "")
                    {
                        lbTenSx.Visible = true;
                        check           = false;
                        lbTenSx.Text    = "* Tên Nhà Sản Xuất không được để trống! *";
                        return;
                    }
                    else
                    {
                        if (int.TryParse(txtTenSx.Text, out n))
                        {
                            lbTenSx.Visible = true;
                            check           = false;
                            lbTenSx.Text    = "* Tên Nhà Sản Xuất không được phép là số! *";
                            return;
                        }
                        else
                        {
                            lbTenSx.Visible = false;
                            check           = true;
                            nsx.TenSx       = txtTenSx.Text;
                        }
                    }

                    if (txtQuocGia.Text == "")
                    {
                        lbQuocGia.Visible = true;
                        check             = false;
                        lbQuocGia.Text    = "* Trường Quốc Gia không được để trống! *";
                        return;
                    }
                    else
                    {
                        if (int.TryParse(txtQuocGia.Text, out n))
                        {
                            lbQuocGia.Visible = true;
                            check             = false;
                            lbQuocGia.Text    = "* Giá trị trường Quốc Gia không được phép là số *";
                            return;
                        }
                        else
                        {
                            lbQuocGia.Visible = false;
                            check             = true;
                            nsx.QuocGia       = txtQuocGia.Text;
                        }
                    }

                    if (check == true)
                    {
                        bool result = nsxbll.EditNhaSx(nsx);
                        if (result)
                        {
                            DialogResult dialogResultInsert = MessageBox.Show("Edit Successful!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            if (dialogResultInsert == DialogResult.OK)
                            {
                                EnableHome();
                                TurnOffTextBox(false);
                                btnDelete.Enabled = true;
                                HienThiNhaSanxuat();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Edit Error!" + "\n\n\t" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }