private void btnHuy_Click(object sender, EventArgs e)
        {
            FDonViTinh fdonvitinh = new FDonViTinh();

            fdonvitinh.MdiParent = main;
            fdonvitinh.main      = main;
            fdonvitinh.Show();
            this.Close();
        }
示例#2
0
        private void đơnVịTínhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form form = CheckTonTai(typeof(FDonViTinh));

            if (form != null)
            {
                form.Activate();
            }
            else
            {
                FDonViTinh newform = new FDonViTinh();
                newform.MdiParent = this;
                newform.main      = this;
                newform.Show();
            }
        }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (labTacVu.Text == "Thêm")
            {
                if (txtTenDonVi.Text != "")
                {
                    if (txtMaDonVi.Text != "")
                    {
                        try
                        {
                            //byte[] imageData = ReadFile(lbimgpath.Text);
                            DonViTinh.MaDonViTinh  = txtMaDonVi.Text;
                            DonViTinh.TenDonViTinh = txtTenDonVi.Text;

                            Act.AddDonViTinh(DonViTinh);
                            AutoID.UpdateAutoID(10);
                            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("Mã Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                        txtMaDonVi.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Tên Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                    txtTenDonVi.Focus();
                }
            }
            else if (labTacVu.Text == "Sửa")
            {
                if (txtTenDonVi.Text != "")
                {
                    try
                    {
                        //byte[] imageData = ReadFile(lbimgpath.Text);
                        DonViTinh.MaDonViTinh  = txtMaDonVi.Text;
                        DonViTinh.TenDonViTinh = txtTenDonVi.Text;

                        Act.UpdateDonViTinh(DonViTinh);
                        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);
                    txtTenDonVi.Focus();
                }
            }
            else
            {
                try
                {
                    DonViTinh.MaDonViTinh  = txtMaDonVi.Text;
                    DonViTinh.TenDonViTinh = txtTenDonVi.Text;

                    Act.DeleteDonViTinh(DonViTinh);
                    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);
                }
            }

            //this.Hide();
            FDonViTinh fdonvitinh = new FDonViTinh();

            fdonvitinh.MdiParent = main;
            fdonvitinh.main      = main;
            fdonvitinh.Show();
            this.Close();
        }