Пример #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (!SaveValidatetion())
            {
                MessageBox.Show("Nhập đầy đủ thông tin", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            HangHoaObj hhObj = new HangHoaObj();

            addData(hhObj);
            if (flagLuu == 0)
            {
                if (hhCtr.AddData(hhObj))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (flagLuu == 1)
            {
                if (hhCtr.UpdData(hhObj))
                {
                    MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Không được sửa Mã!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (hhCtr.UpdData(hhObj))
                {
                    MessageBox.Show("Nhập hàng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Nhập hàng không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            frmHangHoa_Load(sender, e);
        }
Пример #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            HangHoaObj hhObj = new HangHoaObj();

            addData(hhObj);
            if (flagLuu == 0)
            {
                if (hhCtr.AddData(hhObj))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (flagLuu == 1)
            {
                if (hhCtr.UpdData(hhObj))
                {
                    MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (hhCtr.UpdData(hhObj))
                {
                    MessageBox.Show("Nhập hàng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Nhập hàng không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            frmHangHoa_Load(sender, e);
        }
Пример #3
0
        private void btnSaveHH_Click(object sender, EventArgs e)
        {
            //if (txtMa.Text == "")
            //{
            //    errorProvider1.SetError(txtMa, "Bạn chưa nhập password");
            //    return;
            //}
            //if (txtTen.Text == "")
            //{
            //    errorProvider1.SetError(txtTen, "Bạn chưa nhập password");
            //    return;
            //}
            //if (txtSL.Text == "")
            //{
            //    errorProvider1.SetError(txtSL, "Bạn chưa nhập password");
            //    return;
            //}
            //if (txtDonGia.Text == "")
            //{
            //    errorProvider1.SetError(txtDonGia, "Bạn chưa nhập password");
            //    return;
            //}
            //if (txtMaNCC.Text == "")
            //{
            //    errorProvider1.SetError(txtMaNCC, "Bạn chưa nhập password");
            //    return;
            //}

            HangHoaObj hhObj = new HangHoaObj();

            addDataHH(hhObj);
            if (flagLuu == 2)
            {
                if (hhCtr.AddData(hhObj))
                {
                    MessageBox.Show("Thêm thành công", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Thêm thất bại,mã đã tồn tại!!!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (flagLuu == 3)
            {
                if (hhCtr.UpdData(hhObj))
                {
                    MessageBox.Show("Sửa thành công", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Không thành công!!!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (flagLuu == 4)
            {
                if (hhCtr.UpdData(hhObj))
                {
                    MessageBox.Show("Nhập thành công !", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Nhập thất bại !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Form1_Load(sender, e);
        }