コード例 #1
0
        private void iLoaiGiaoDich_EditValueChanged(object sender, EventArgs e) //Giói hạn tiền
        {
            O_LOAIGIAODICH _NCCO = iLoaiGiaoDich.GetSelectedDataRow() as O_LOAIGIAODICH;
            decimal        a     = iSoTien.Value;

            if (_NCCO != null)
            {
                if (_NCCO.Am && _NCCO.Duong)
                {
                    iSoTien.Properties.MaxValue = 20000000000;
                    iSoTien.Properties.MinValue = -20000000000;
                }
                else
                {
                    if (_NCCO.Duong)
                    {
                        iSoTien.Properties.MaxValue = 20000000000;
                    }
                    else
                    {
                        iSoTien.Properties.MaxValue = 0;
                    }

                    if (_NCCO.Am)
                    {
                        iSoTien.Properties.MinValue = -20000000000;
                    }
                    else
                    {
                        iSoTien.Properties.MinValue = 0;
                    }
                }

                if ((iSoTien.Properties.MinValue == 0 && a < 0) || (iSoTien.Properties.MaxValue == 0 && a > 0))
                {
                    iSoTien.Value = 0 - a;
                }
            }
        }
コード例 #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (gridView2.RowCount > 0 && gridView2.Columns["SoTien"].SummaryItem.SummaryValue.ToString() != (iSoTien.Value * (iLoaiKhachHang.EditValue.ToString() == "8" ? -1 : 1)).ToString())
            {
                XuLyGiaoDien.Alert("Tổng tiền chi tiết không bằng giao dịch", Form_Alert.enmType.Warning);
                return;
            }

            List <KiemTra> kiemTras = new List <KiemTra>()
            {
                new KiemTra()
                {
                    _Control = iNganHangID, _Tu = 2, _Den = 50
                },
                new KiemTra()
                {
                    _Control = iLoaiGiaoDich, _Tu = 2, _Den = 50
                },
                new KiemTra()
                {
                    _Control = iMaDL, _Tu = 2, _Den = 50, _ChoQuaThang = new List <int>()
                    {
                        6, 9
                    }.Contains((int)iLoaiKhachHang.EditValue)
                },
                new KiemTra()
                {
                    _Control = iLoaiKhachHang, _Tu = 2, _Den = 50
                }
            };

            XuLyGiaoDien.KiemTra(kiemTras, dxValidationProvider1);
            if (!dxValidationProvider1.Validate())
            {
                XuLyGiaoDien.Alert("Thông tin không hợp lệ", Form_Alert.enmType.Warning);
                return;
            }

            List <Dictionary <string, object> > lstDic = new List <Dictionary <string, object> >();
            Dictionary <string, object>         dic    = new Dictionary <string, object>();

            dic = XuLyDuLieu.FormToDictionary(this, dic);

            bool ThanhCong = false;

            if (int.Parse(iLoaiKhachHang.EditValue.ToString()) == 7)
            {
                Dictionary <string, object> dicnh = new Dictionary <string, object>();
                dicnh.Add("NgayGD", iNgayGD.DateTime);
                dicnh.Add("NganHangID", iMaDL.EditValue);
                dicnh.Add("MaDL", iNganHangID.EditValue);
                dicnh.Add("SoTien", 0 - iSoTien.Value);
                dicnh.Add("GhiChu", iGhiChu.Text);
                dicnh.Add("TrangThaiID", iTrangThaiID.EditValue);
                dicnh.Add("NgayHT", iNgayHT.DateTime);
                dicnh.Add("LoaiGiaoDich", ((int)iLoaiGiaoDich.EditValue % 2 == 0) ? int.Parse(iLoaiGiaoDich.EditValue.ToString()) - 1 : int.Parse(iLoaiGiaoDich.EditValue.ToString()) + 1);
                dicnh.Add("LoaiKhachHang", iLoaiKhachHang.EditValue);
                dicnh.Add("NVGiaoDich", iNVGiaoDich.EditValue);
                dicnh.Add("GhiChuNV", iGhiChuNV.Text);
                if (CTM.ID == 0)
                {
                    string Ma = ct.LayGioServer().ToString("yyyyMMddhhmmssttt");
                    dicnh.Add("MaLienKet", Ma);
                    dic.Add("MaLienKet", Ma);
                    lstDic.Add(dic);
                    lstDic.Add(dicnh);
                    ThanhCong = ct.ThemNhieu1Ban(lstDic) > 1;
                }
                else
                {
                    List <string> lstCTV = new List <string>()
                    {
                        string.Format("WHERE ID = {0}", CTM.ID), string.Format("WHERE MaLienKet = '{1}' and ID <> {0}", CTM.ID, CTM.MaLienKet)
                    };
                    lstDic.Add(dic);
                    lstDic.Add(dicnh);
                    if ((int)iLoaiGiaoDich.EditValue != CTM.LoaiGiaoDich)
                    {
                        string Ma = ct.LayGioServer().ToString("yyyyMMddhhmmssttt");
                        dicnh.Add("MaLienKet", Ma);
                        dic.Add("MaLienKet", Ma);
                        List <string> lstTb   = new List <string>();
                        List <string> lstThem = new List <string>();
                        lstThem.Add("S");
                        lstThem.Add("T");
                        lstTb.Add("CTNGANHANG");
                        lstTb.Add("CTNGANHANG");
                        ThanhCong = ct.CapNhat_ThemNhieu(lstDic, lstTb, lstCTV, lstThem) > 1;
                    }
                    else
                    {
                        ThanhCong = ct.SuaNhieu1Ban(lstDic, lstCTV) > 1;
                    }
                }
            }
            else
            {
                ThanhCong = ((CTM.ID == 0) ? ct.ThemMoi(dic) : ct.CapNhat(dic, CTM.ID)) > 0;
            }

            if (XuLyGiaoDien.ThongBao(iLoaiGiaoDich.Text + (CTM.ID != 0 ? " sửa" : " thêm"), ThanhCong))
            {
                if (_GiaoDichOLD.Count > 0 || _GiaoDich.Count > 0)
                {
                    List <Dictionary <string, object> > lstDicT = new List <Dictionary <string, object> >();
                    List <string> lstTb   = new List <string>();
                    List <string> lstThem = new List <string>();
                    List <string> lstCTV  = new List <string>();
                    foreach (O_BAOCAOCTNH d in _GiaoDich)
                    {
                        if (_GiaoDichOLD.Contains(d))
                        {
                            lstDicT.Add(XuLyDuLieu.ConvertClassToDic(d));
                            lstThem.Add("S");
                        }
                        else
                        {
                            lstDicT.Add(XuLyDuLieu.ConvertClassToDic(d));
                            lstThem.Add("T");
                        }
                        lstCTV.Add(string.Format("WHERE ID = {0}", d.ID));
                        lstTb.Add("BAOCAOCTNH");
                    }
                    new D_BAOCAOCTNH().CapNhat_ThemNhieu(lstDicT, lstTb, lstCTV, lstThem);

                    List <object> lstCTVBC = new List <object>();
                    foreach (O_BAOCAOCTNH d in _GiaoDichOLD)
                    {
                        if (!_GiaoDich.Contains(d))
                        {
                            lstCTVBC.Add(d.ID);
                        }
                    }

                    if (lstCTVBC.Count > 0)
                    {
                        new D_BAOCAOCTNH().XoaNhieu1Ban(lstCTVBC, "BAOCAOCTNH");
                    }
                }
                new D_NGANHANG().ChayLaiSD();
                O_LOAIGIAODICH _NCCO = iLoaiGiaoDich.GetSelectedDataRow() as O_LOAIGIAODICH;
                if (CTM.NganHangID == 1)
                {
                    (Owner.ActiveMdiChild as frmTienMat).TaiLaiDuLieu();
                }
                else
                {
                    (Owner.ActiveMdiChild as frmNganHang).LayDLNganHang();
                    (Owner.ActiveMdiChild as frmNganHang).TaiLaiDuLieu();
                }
                GhiChuCmt(CTM.ID);
                Close();
            }
        }