コード例 #1
0
ファイル: frmSuaDaiLy.cs プロジェクト: doquyen0796/QLDaiLy
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (KiemTraDuLieu())
            {
                try
                {
                    var tb = MessageBox.Show("Bạn có chắc chắn muốn chỉnh sửa thông tin của đại lý ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (tb == DialogResult.Yes)
                    {
                        BUS_DaiLy dl   = new BUS_DaiLy();
                        var       flag = dl.SuaDaiLy(int.Parse(txtMaDaiLy.Text), txtTenDaiLy.Text, int.Parse(cbLoaiDL.EditValue.ToString()), txtDiaChi.Text, cbQuan.EditValue.ToString(), txtEmail.Text, DateTime.Parse(dtpNgayTiepNhan.EditValue.ToString()));

                        if (flag == true)
                        {
                            MessageBox.Show("Bạn đã chỉnh sửa thông tin đại lý thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            KhiSuaDaiLy(EventArgs.Empty);   //  https://msdn.microsoft.com/en-us/library/9aackb16(v=vs.110).aspx
                        }
                        else
                        {
                            MessageBox.Show("Email đã tồn tại trong hệ thống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(string.Format("Thao tác không thành công. {0} đã đạt đến số đại lý tối đa.", cbQuan.EditValue.ToString()), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #2
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            if (idDL != -1 && arrIdLDL[cbLoaiDL.SelectedIndex] >= 0 && arrIdQuan[cbQuan.SelectedIndex] >= 0 &&
                txtTienNo.Text.Equals("") == false && txtTenDaiLy.Text.Equals("") == false &&
                txtSdt.Text.Equals("") == false && txtDiaChi.Text.Equals("") == false)
            {
                DTO_DaiLy dl = new DTO_DaiLy();
                dl.IdDL     = idDL;
                dl.IdLoaiDL = arrIdLDL[cbLoaiDL.SelectedIndex];
                dl.IdQuan   = arrIdQuan[cbQuan.SelectedIndex];
                dl.TienNo   = (float)Convert.ToDouble(txtTienNo.Text);
                dl.TenDaiLy = txtTenDaiLy.Text;
                dl.Sdt      = txtSdt.Text;
                dl.DiaChi   = txtDiaChi.Text;
                dl.Cmnd     = nhanVien.Cmnd;
                dl.NgayNhan = DateTime.Now;

                int kq = BUS_DaiLy.SuaDaiLy(dl);

                if (kq == 1)
                {
                    dsDaiLy = BUS_DaiLy.DsDaiLy();
                    UpdateGvDaiLy();
                    MessageBox.Show("Cập nhật thành công");
                }
                else if (kq == 3)
                {
                    MessageBox.Show("Loại đại lý đã đủ số lượng");
                }
                else
                {
                    MessageBox.Show("Cập nhật thất bại");
                }
            }
        }