private void btnHuy_Click(object sender, EventArgs e)
        {
            FNhomHang fnhomhang = new FNhomHang();

            fnhomhang.main      = main;
            fnhomhang.MdiParent = main;
            this.Hide();
            fnhomhang.Show();
        }
Пример #2
0
        private void nhómHàngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form form = CheckTonTai(typeof(FNhomHang));

            if (form != null)
            {
                form.Activate();
                //form.Show();
            }
            else
            {
                FNhomHang newform = new FNhomHang();
                newform.MdiParent = this;
                newform.main      = this;
                newform.Show();
            }
        }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (labTacVu.Text == "Thêm")
            {
                if (txtMaNhom.Text != "")
                {
                    if (txtTenNhom.Text != "")
                    {
                        try
                        {
                            //byte[] imageData = ReadFile(lbimgpath.Text);
                            NhomHang.MaNhomHang  = txtMaNhom.Text;
                            NhomHang.TenNhomHang = txtTenNhom.Text;

                            Act.AddNhomHang(NhomHang);
                            AutoID.UpdateAutoID(13);
                            MessageBox.Show("Đã Thêm Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Tên không được để trống", "Chú Ý", MessageBoxButtons.OK);
                        txtTenNhom.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Mã không được để trống", "Chú Ý", MessageBoxButtons.OK);
                    txtMaNhom.Focus();
                }
            }
            else if (labTacVu.Text == "Sửa")
            {
                if (txtTenNhom.Text != "")
                {
                    try
                    {
                        //byte[] imageData = ReadFile(lbimgpath.Text);
                        NhomHang.MaNhomHang  = txtMaNhom.Text;
                        NhomHang.TenNhomHang = txtTenNhom.Text;

                        Act.UpdateNhomHang(NhomHang);
                        MessageBox.Show("Đã sửa Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Tên không được để trống", "Chú Ý", MessageBoxButtons.OK);
                    txtTenNhom.Focus();
                }
            }
            else
            {
                try
                {
                    NhomHang.MaNhomHang  = txtMaNhom.Text;
                    NhomHang.TenNhomHang = txtTenNhom.Text;

                    Act.DeleteNhomHang(NhomHang);
                    MessageBox.Show("Đã Xóa Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            FNhomHang fnhomhang = new FNhomHang();

            fnhomhang.main      = main;
            fnhomhang.MdiParent = main;
            this.Hide();
            //fnhomhang.MdiParent =
            fnhomhang.Show();
        }