Exemplo n.º 1
0
        private void btnDongy_Click(object sender, EventArgs e)
        {
            tblHangsanxuat objhangsx;

            try
            {
                objhangsx = new tblHangsanxuat(txtMahangsx.Text, txtTenhangsx.Text);
            }
            catch (Exception ex)
            {
                string erro = ex.Message;
                MessageBox.Show(erro, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (erro.Contains("mã"))
                {
                    txtMahangsx.Focus();
                }
                else
                {
                    txtTenhangsx.Focus();
                }
                return;
            }
            tblHangsanxuat objHangsx = new tblHangsanxuat(txtMahangsx.Text, txtTenhangsx.Text);
            int            result    = objHangsx.themNhaSX();

            if (result == 0)
            {
                MessageBox.Show("Thêm nhà sản xuất [" + txtTenhangsx.Text + "] thành công !");
            }
            else
            {
                MessageBox.Show("Chưa thêm được nhà sản xuất mới!");
            }
            this.DialogResult = DialogResult.OK;
        }
        private void btnDongy_Click(object sender, EventArgs e)
        {
            tblHangsanxuat objhangsx;

            try
            {
                objhangsx = new tblHangsanxuat(txtManhasx.Text, txtTenNhasx.Text);
            }
            catch (Exception ex)
            {
                string erro = ex.Message;
                MessageBox.Show(erro, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (erro.Contains("mã"))
                {
                    txtManhasx.Focus();
                }
                else
                {
                    txtTenNhasx.Focus();
                }
                return;
            }
            tblHangsanxuat objhang = new tblHangsanxuat(txtManhasx.Text, txtTenNhasx.Text);
            int            result  = objhang.capnhapNhaSX();

            if (result == 0)
            {
                MessageBox.Show("Cập nhật thành công [" + txtTenNhasx.Text + "] thành công!");
            }
            else
            {
                MessageBox.Show("Cập nhật thất bại.Mời bạn làm lại!");
            }
            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void btnXoaHangsx_Click(object sender, EventArgs e)
        {
            if (listHangsx.SelectedItems.Count == 0)
            {
                return;
            }
            DialogResult tb = MessageBox.Show("Bạn có muốn xóa Hãng sản xuất[" + listHangsx.GetItemText(listHangsx.SelectedItem) + "] không!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (tb == DialogResult.Cancel)
            {
                return;
            }
            string         masx = listHangsx.SelectedValue.ToString();
            tblHangsanxuat dt   = new tblHangsanxuat(masx);
            int            kq   = dt.xoaNhaSX();

            if (kq == 0)
            {
                MessageBox.Show("Bạn đã xóa thành công Hãng sản xuất[" + listHangsx.GetItemText(listHangsx.SelectedItem) + "] thành công!", "Thông báo");
            }
            else
            {
                MessageBox.Show("Bạn chưa xóa được hãng sản xuất!");
            }
            load_NhaSanXuat();
        }