コード例 #1
0
        private void btnHuy_Click(object sender, EventArgs e)
        {
            FNhaCC fnhacc = new FNhaCC();

            fnhacc.MdiParent = main;
            fnhacc.main      = main;
            fnhacc.Show();
            this.Hide();
        }
コード例 #2
0
        private void nhàCungCấpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form form = CheckTonTai(typeof(FNhaCC));

            if (form != null)
            {
                form.Activate();
            }
            else
            {
                FNhaCC newform = new FNhaCC();
                newform.MdiParent = this;
                newform.main      = this;
                newform.Show();
            }
        }
コード例 #3
0
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (labTacVu.Text == "Thêm")
            {
                if (txtMaNhaCC.Text != "")
                {
                    if (txtTenNhaCC.Text != "")
                    {
                        if (txtDiaChi.Text != "")
                        {
                            if (txtSDT.Text != "")
                            {
                                try
                                {
                                    //byte[] imageData = ReadFile(lbimgpath.Text);
                                    NhaCC.MaNhaCC   = txtMaNhaCC.Text;
                                    NhaCC.TenNhaCC  = txtTenNhaCC.Text;
                                    NhaCC.DiaChi    = txtDiaChi.Text;
                                    NhaCC.DienThoai = txtSDT.Text;

                                    Act.AddNhaCC(NhaCC);
                                    AutoID.UpdateAutoID(8);
                                    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("Điện thoại Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                                txtSDT.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Địa Chỉ Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                            txtDiaChi.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Tên Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                        txtTenNhaCC.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Mã Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                    txtMaNhaCC.Focus();
                }
            }
            else if (labTacVu.Text == "Sửa")
            {
                if (txtTenNhaCC.Text != "")
                {
                    if (txtDiaChi.Text != "")
                    {
                        if (txtSDT.Text != "")
                        {
                            try
                            {
                                //byte[] imageData = ReadFile(lbimgpath.Text);
                                NhaCC.MaNhaCC   = txtMaNhaCC.Text;
                                NhaCC.TenNhaCC  = txtTenNhaCC.Text;
                                NhaCC.DiaChi    = txtDiaChi.Text;
                                NhaCC.DienThoai = txtSDT.Text;

                                Act.UpdateNhaCC(NhaCC);
                                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("Điện thoại Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                            txtSDT.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Địa chỉ Không được để trống", "Chú Ý", MessageBoxButtons.OK);
                        txtDiaChi.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Tên không được để trống", "Chú Ý", MessageBoxButtons.OK);
                    txtTenNhaCC.Focus();
                }
            }
            else
            {
                try
                {
                    NhaCC.MaNhaCC   = txtMaNhaCC.Text;
                    NhaCC.TenNhaCC  = txtTenNhaCC.Text;
                    NhaCC.DiaChi    = txtDiaChi.Text;
                    NhaCC.DienThoai = txtSDT.Text;
                    Act.DeleteNhaCC(NhaCC);
                    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();
            FNhaCC fnhacc = new FNhaCC();

            fnhacc.MdiParent = main;
            fnhacc.main      = main;
            fnhacc.Show();
            this.Hide();
        }