예제 #1
0
        private void BtnThem_Click(object sender, EventArgs e)
        {
            //1. Map data from GUI
            if (txtMaKH.Text.Length == 0)
            {
                MessageBox.Show("Nhập mã khách hàng");
                return;
            }
            if (txtCMND.Text.Length == 0)
            {
                MessageBox.Show("Nhập CMND");
                return;
            }

            if (txtDiaChi.Text.Length == 0)
            {
                MessageBox.Show("Nhập địa chỉ");
                return;
            }

            if (txtSoTienGui.Text.Length == 0)
            {
                MessageBox.Show("Nhập số tiền gửi");
                return;
            }

            //1.1 info từ form Sổ tiết kiểm
            SoTietKiemDTO stk = new SoTietKiemDTO();

            stk.StrMaSoSTK  = txtMaSoSTK.Text;
            stk.StrMaKH     = txtMaKH.Text;
            stk.DSoTienGui  = double.Parse(txtSoTienGui.Text);
            stk.StrMaLTK    = cmbLoaiTietKiem.Text;
            stk.StrNgayMoSo = (DateTime.Now).ToString();
            stk.DSoDu       = double.Parse(txtSoTienGui.Text);
            //----------------------------------------


            //1.2 info từ table tblLoaiTietKiem
            LoaiTietKiemDTO ltk = ltkBUS.getLoaiTietKiem(cmbLoaiTietKiem.Text);

            stk.FLaiSuatCamKet = ltk.FLaiSuat;
            stk.IKyHanCamKet   = ltk.IKyHan;
            //----------------------------------------------

            //2. Kiểm tra data hợp lệ or not

            //3. Thêm vào DB
            bool kq = stkBUS.themSoTietKiem(stk);

            if (kq == false)
            {
                MessageBox.Show("Thêm Sổ tiết kiệm thất bại. Vui lòng kiểm tra lại dũ liệu");
            }
            else
            {
                MessageBox.Show("Thêm Sổ tiết kiệm thành công");
            }
            //--------------------------------------------
        }
예제 #2
0
        private void cmsXoaSTK_Click(object sender, EventArgs e)
        {
            // ' Get the current cell location.
            int currentRowIndex = dgvSoTietKiem.CurrentCellAddress.Y;// 'current row selected


            //'Verify that indexing OK
            if (-1 < currentRowIndex && currentRowIndex < dgvSoTietKiem.RowCount)
            {
                SoTietKiemDTO stk = (SoTietKiemDTO)dgvSoTietKiem.Rows[currentRowIndex].DataBoundItem;
                if (stk != null)
                {
                    bool kt = stkBUS.dongSoTietKiem(stk);
                    if (kt == false)
                    {
                        MessageBox.Show("Đóng sổ tiết kiệm thất bại. Vui lòng kiểm tra lại dũ liệu");
                    }
                    else
                    {
                        MessageBox.Show("Đóng sổ tiết kiệm thành công");
                        this.LoadData();
                    }
                }
            }
        }
예제 #3
0
 private void cmbMaSoSTK_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbMaSoSTK.Text != "1")
     {
         SoTietKiemDTO stk = stkBUS.getSoTietKiem(cmbMaSoSTK.Text);
         txtSoTienRut.Text     = stk.DSoDu.ToString();
         txtSoTienRut.ReadOnly = true;
     }
 }
예제 #4
0
        private void txtSoTienRut_Leave(object sender, EventArgs e)
        {
            if (cmbMaSoSTK.Text == "1")
            {
                SoTietKiemDTO stk = stkBUS.getSoTietKiem(cmbMaSoSTK.Text);

                if (double.Parse(txtSoTienRut.Text) > double.Parse(stk.DSoDu.ToString()))
                {
                    MessageBox.Show("Số tiền rút không hợp lệ");
                }
            }
        }
예제 #5
0
        public frmSoTietKiem(SoTietKiemDTO stk)
        {
            InitializeComponent();

            khBUS = new KhachHangBUS();
            KhachHangDTO kh = khBUS.getKhachHang(stk.StrMaKH);

            txtMaSoSTK.Text      = stk.StrMaSoSTK;
            txtMaKH.Text         = stk.StrMaKH;
            txtCMND.Text         = kh.StrCMND;
            txtDiaChi.Text       = kh.StrDiaChi;
            txtSoTienGui.Text    = stk.DSoDu.ToString();
            cmbLoaiTietKiem.Text = stk.StrMaLTK;
        }
예제 #6
0
        private void btnLuuVaXuatPhieu_Click(object sender, EventArgs e)
        {
            //1. Map data from GUI


            SoTietKiemDTO stk = stkBUS.getSoTietKiem(cmbMaSoSTK.Text);

            if (stk.StrMaLTK == "1")
            {
                PhieuGuiTienDTO pgt = new PhieuGuiTienDTO();
                pgt.StrMaSoPGT = txtMaSoPGT.Text;
                pgt.StrMaSTK   = cmbMaSoSTK.Text;
                pgt.DSoTienGui = double.Parse(txtSoTienGui.Text);
                pgt.StrNgayGui = DateTime.Now.ToString();

                {
                    //3. Thêm vào DB
                    {
                        bool kq = pgtBUS.them(pgt);
                        if (kq == false)
                        {
                            MessageBox.Show("Thêm Phiếu gửi tiền thất bại. Vui lòng kiểm tra lại dũ liệu");
                        }
                        else
                        {
                            MessageBox.Show("Thêm Phiếu gửi tiền thành công");
                            stk.DSoTienGui = stk.DSoDu + double.Parse(txtSoTienGui.Text);
                            kq             = stkBUS.suaSoTietKiem(stk);
                            if (kq == true)
                            {
                                MessageBox.Show("Cập nhật sổ tiết kiệm thành công");
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Cập nhật sổ tiết kiệm thất bại");
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Bạn không thể gởi thêm tiền vào sổ tiết kiệm có kỳ hạn");
            }
            //--------------------------------------------
        }
예제 #7
0
        private void cmsSuaSTK_Click(object sender, EventArgs e)
        {
            // ' Get the current cell location.
            int currentRowIndex = dgvSoTietKiem.CurrentCellAddress.Y;// 'current row selected


            //'Verify that indexing OK
            if (-1 < currentRowIndex && currentRowIndex < dgvSoTietKiem.RowCount)
            {
                SoTietKiemDTO kn = (SoTietKiemDTO)dgvSoTietKiem.Rows[currentRowIndex].DataBoundItem;
                if (kn != null)
                {
                    frmSoTietKiem frm = new frmSoTietKiem(kn);
                    frm.ShowDialog();
                }
            }
        }
예제 #8
0
        private void BtnDongSo_Click(object sender, EventArgs e)
        {
            //1. Map key primary from GUI
            SoTietKiemDTO stk = new SoTietKiemDTO();

            stk.StrMaSoSTK = txtMaSoSTK.Text;
            //2. Kiểm tra data hợp lệ

            //3. Xóa khỏi DB
            bool kq = stkBUS.dongSoTietKiem(stk);

            if (kq == false)
            {
                MessageBox.Show("Đóng Sổ Tiết Kiệm thất bại. Vui lòng kiểm tra lại dũ liệu");
            }
            else
            {
                MessageBox.Show("Đóng Sổ tiết kiệm thành công");
            }
        }
예제 #9
0
        public bool suaSoTietKiem(SoTietKiemDTO stkDTO)
        {
            bool re = stkDAL.suaSoTietKiem(stkDTO);

            return(re);
        }
예제 #10
0
        public bool dongSoTietKiem(SoTietKiemDTO stkDTO)
        {
            bool re = stkDAL.xoaSoTietKiem(stkDTO);

            return(re);
        }
예제 #11
0
        public bool themSoTietKiem(SoTietKiemDTO stkDTO)
        {
            bool re = stkDAL.themSoTietKiem(stkDTO);

            return(re);
        }
예제 #12
0
        private void btnLuuVaXuatPhieu_Click(object sender, EventArgs e)
        {
            //1. Map data from GUI
            PhieuRutTienDTO prt = new PhieuRutTienDTO();

            prt.StrMaSoPRT = txtMaSoPRT.Text;
            prt.StrMaSTK   = cmbMaSoSTK.Text;
            prt.DSoTienRut = double.Parse(txtSoTienRut.Text);
            prt.StrNgayRut = DateTime.Now.ToString();
            SoTietKiemDTO stk = stkBUS.getSoTietKiem(cmbMaSoSTK.Text);

            //----------------------------------------

            //2. Kiểm tra data hợp lệ or not

            if (stk.StrMaLTK == "1")
            {
                if (double.Parse(txtSoTienRut.Text) > double.Parse(stk.DSoDu.ToString()))
                {
                    MessageBox.Show("Số tiền rút không hợp lệ");
                }
                else
                {
                    //3. Thêm vào DB
                    bool kq = prtBUS.them(prt);
                    if (kq == false)
                    {
                        MessageBox.Show("Thêm Phiếu rút tiền thất bại. Vui lòng kiểm tra lại dũ liệu");
                    }
                    else
                    {
                        MessageBox.Show("Thêm Phiếu rút tiền thành công");
                        stk.DSoTienGui = stk.DSoDu - double.Parse(txtSoTienRut.Text);
                        kq             = stkBUS.suaSoTietKiem(stk);
                        if (kq == false)
                        {
                            MessageBox.Show("Cập nhật sổ tiết kiệm thất bại. Vui lòng kiểm tra lại dũ liệu");
                        }
                        else
                        {
                            MessageBox.Show("Cập nhật sổ tiết kiệm thành công.");
                        }
                    }
                }
            }
            else
            {
                bool kq = prtBUS.them(prt);
                if (kq == false)
                {
                    MessageBox.Show("Thêm Phiếu rút tiền thất bại. Vui lòng kiểm tra lại dũ liệu");
                }
                else
                {
                    MessageBox.Show("Thêm Phiếu rút tiền thành công");
                }
                stk.DSoTienGui = 0;
                kq             = stkBUS.suaSoTietKiem(stk);
                if (kq == false)
                {
                    MessageBox.Show("Cập nhật sổ tiết kiệm thất bại. Vui lòng kiểm tra lại dũ liệu");
                }
                else
                {
                    MessageBox.Show("Sổ đóng");
                }
            }

            //--------------------------------------------
        }