示例#1
0
        void Xoa(object sender, ToolStripItemClickedEventArgs e)
        {
            DialogResult drl = MessageBox.Show("Bạn có chắc chắn muốn xóa!", "Thông báo!", MessageBoxButtons.YesNo);

            if (drl == DialogResult.No)
            {
                return;
            }
            LoaiViSaDTO loaiVS = new LoaiViSaDTO();

            loaiVS.MaLVS = tempList[selectRow].MaLVS;

            bool kq = visabus.xoa(loaiVS);

            if (kq == false)
            {
                lb_thongBao.ForeColor = Color.Red;
                lb_thongBao.Text      = "Xóa địa chỉ nhập cảnh thất bại! Có thể còn dữ liệu phụ thuộc liên quan!";
            }
            else
            {
                FrmDanhMucViSa_Load(sender, e);
                lb_thongBao.ForeColor = Color.Green;
                lb_thongBao.Text      = "Xóa địa chỉ nhập cảnh thành công!";
            }
        }
示例#2
0
        private void Btn_Sua_Click(object sender, EventArgs e)
        {
            if (tbLoaiViSa.Text == "" || tbChiPhi.Text == "")
            {
                lb_thongBao.ForeColor = Color.Red;
                lb_thongBao.Text      = "Có trường dữ liệu còn trống! Vui lòng điền đầy đủ!";
                return;
            }

            LoaiViSaDTO loaiVS = new LoaiViSaDTO();

            loaiVS.MaLVS  = tempList[selectRow].MaLVS;
            loaiVS.Ten    = tbLoaiViSa.Text;
            loaiVS.ChiPhi = int.Parse(tbChiPhi.Text);

            bool kq = visabus.sua(loaiVS);

            if (kq == false)
            {
                lb_thongBao.ForeColor = Color.Red;
                lb_thongBao.Text      = "Sửa loại VISA thất bại! Kiểm tra lại dữ liệu!";
            }
            else
            {
                FrmDanhMucViSa_Load(sender, e);
                lb_thongBao.ForeColor = Color.Green;
                lb_thongBao.Text      = "Sửa loại VISA thành công!";
                btn_Sua.Hide();
                btnThem.Show();
            }
        }
示例#3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (tbLoaiViSa.Text == "" || tbChiPhi.Text == "")
            {
                lb_thongBao.ForeColor = Color.Red;
                lb_thongBao.Text      = "Có trường dữ liệu còn trống! Vui lòng điền đầy đủ!";
                return;
            }

            LoaiViSaDTO loaiVS = new LoaiViSaDTO();
            string      maLoaiVS;
            string      numZeroStr = ""; // String chứa có bao nhiêu số 0 trong mã

            loaiVS.Ten    = tbLoaiViSa.Text;
            loaiVS.ChiPhi = int.Parse(tbChiPhi.Text.ToString());

            for (int i = 0; i < tempList.Count; i++)
            {
                if (int.Parse(tempList[i].MaLVS.Substring(3)) != i + 1)   // Căt pahàn số sau chữ "DC"
                {
                    i++;                                                  // Cộng giá trị lên 1 để tránh số 0
                    maLoaiVS = i.ToString();
                    int numZero = sizeMaLoaiVS - i.ToString().Length - 3; // tính số số 0 trong chuõi
                    for (int j = 0; j < numZero; j++)
                    {
                        numZeroStr = numZeroStr + "0";
                    }
                    loaiVS.MaLVS = "LVS" + numZeroStr + i.ToString(); // Mã = LSV + Số 0 + mã số
                    break;
                }
            }

            if (loaiVS.MaLVS == null)            // tra hết list nếu ko có thêm phần tử mnói
            {
                int numZero = sizeMaLoaiVS - (tempList.Count + 1).ToString().Length - 3;
                for (int j = 0; j < numZero; j++)
                {
                    numZeroStr = numZeroStr + "0";
                }

                loaiVS.MaLVS = "LVS" + numZeroStr + (tempList.Count + 1).ToString();
            }
            bool kq = visabus.them(loaiVS);

            if (kq == false)
            {
                lb_thongBao.ForeColor = Color.Red;
                lb_thongBao.Text      = "Thêm loại VISA thất bại! Dữ liệu có thể còn liên hệ với các bảng dữ liệu khác!";
            }
            else
            {
                FrmDanhMucViSa_Load(sender, e);
                lb_thongBao.ForeColor = Color.Green;
                lb_thongBao.Text      = "Thêm loại VISA mới thành công!";
            }
        }
        public bool sua(LoaiViSaDTO dc)
        {
            bool re = dcDAL.sua(dc);

            return(re);
        }
        public bool them(LoaiViSaDTO dc)
        {
            bool re = dcDAL.them(dc);

            return(re);
        }