/// <summary>
        /// 修改
        /// </summary>
        /// <param name="obj"></param>
        public override void ModifyExecute()
        {
            //if (CurModel.AM_ID!=null)
            //{
            //    //FundsRegulatoryClient.JG_AccountManageSrv.JG_AccountManageInfo jj = (FundsRegulatoryClient.JG_AccountManageSrv.JG_AccountManageInfo)obj;
            //    ObservableCollection<JG_AccountManageInfo> temp = new ObservableCollection<JG_AccountManageInfo>();
            //    int index = this.Models.IndexOf(CurModel);
            //    OpenAccountAddToEdit page = new OpenAccountAddToEdit(CurModel, Models);
            //    page.ShowDialog();
            //    this.dg.SelectedIndex = index;
            //  //  this.Models[index] = CurModel;
            //    //foreach (JG_AccountManageInfo item in this.Models)
            //    //{
            //    //    temp.Add(item);
            //    //}
            //    //this.Models.Clear();
            //    //this.Models = temp;
            //  //  FlushExecute();
            //}
            if (CurModel.AM_ID != null)
            {
                // FundsRegulatoryClient.JG_AccountManageSrv.JG_AccountManageInfo jj = (FundsRegulatoryClient.JG_AccountManageSrv.JG_AccountManageInfo)obj;
                int index = Models.IndexOf(CurModel);//检索列表中是否存在该项
                if (index > -1)
                {
                    if (CurModel.AM_UseFlag == "正常")
                    {
                        VMHelp.ShowMessage("账户已经启用", false); return;
                    }
                    CurModel.AM_UseFlag = "正常";

                    ObservableCollection <FundsRegulatoryClient.JG_InterestRateSrv.JG_InterestRateInfo> rate = InterestRateClient.Selects();
                    int i = 0;
                    for (; i < rate.Count; i++)
                    {
                        if (rate[i].Flag == "1")
                        {
                            break;
                        }
                    }
                    if (rate.Count < 1 || i == rate.Count)
                    {
                        VMHelp.ShowMessage("未启用最新利率或设置利率", false); return;
                    }
                    FundsRegulatoryClient.InterestService.DayBalance db = new FundsRegulatoryClient.InterestService.DayBalance();
                    db.DB_ID = CurModel.AM_ID;
                    //  db.DB_Time = DateTime.Parse(DateTime.Now.ToShortDateString());
                    ObservableCollection <FundsRegulatoryClient.InterestService.DayBalance> dblist = InterestClient.SelectJG_DayBalanceInfo(db);
                    FundsRegulatoryClient.SqlTransSvr.JG_AccountManageInfo tempacc = new FundsRegulatoryClient.SqlTransSvr.JG_AccountManageInfo();

                    tempacc.AM_ID          = CurModel.AM_ID;
                    tempacc.AM_BankCode    = VMHelp.BankCode;//银行代码
                    tempacc.AM_CreateDate  = DateTime.Parse(VMHelp.NowTime);
                    tempacc.AM_CorpName    = CurModel.AM_CorpName;
                    tempacc.AM_ItemName    = CurModel.AM_ItemName;
                    tempacc.AM_JgAccount   = CurModel.AM_JgAccount;
                    tempacc.AM_ProjectCode = CurModel.AM_ProjectCode;
                    tempacc.AM_UseFlag     = CurModel.AM_UseFlag;
                    tempacc.AM_zhmc        = CurModel.AM_zhmc;
                    tempacc.AM_Person      = CurModel.AM_Person;


                    FundsRegulatoryClient.SqlTransSvr.DayBalance tempdb = new FundsRegulatoryClient.SqlTransSvr.DayBalance();
                    //每天余额表添加一条
                    tempdb.DB_ID           = CurModel.AM_ID;
                    tempdb.DB_AccountNum   = CurModel.AM_JgAccount;
                    tempdb.DB_InterestRate = rate[0].InterestRate;     //利率;
                    tempdb.DB_Time         = DateTime.Parse(DateTime.Now.ToShortDateString());
                    if (dblist.Count > 0)
                    {
                        tempdb.DB_Balance = dblist[dblist.Count - 1].DB_Balance;
                    }
                    else
                    {
                        tempdb.DB_Balance = null;
                    }
                    tempdb.ID = Guid.NewGuid().ToString();
                    //季度结息表更新
                    FundsRegulatoryClient.SqlTransSvr.SeasonInterest     si     = new FundsRegulatoryClient.SqlTransSvr.SeasonInterest();
                    FundsRegulatoryClient.InterestService.SeasonInterest tempsi = new FundsRegulatoryClient.InterestService.SeasonInterest();

                    tempsi.SI_ID = si.SI_ID = tempdb.DB_ID;
                    ObservableCollection <FundsRegulatoryClient.InterestService.SeasonInterest> silist = InterestClient.SelectJG_SeasonInterestInfo(tempsi);
                    si.SI_Time       = tempdb.DB_Time.Value.AddMonths(3);
                    si.SI_AccountNum = tempdb.DB_AccountNum;

                    if (dblist[dblist.Count - 1].DB_Time == DateTime.Parse(DateTime.Now.ToShortDateString()))
                    {
                        if (tranClient.CreateAccountSIDB(tempacc, null, null, 2))
                        {
                            VMHelp.ShowMessage("启用成功!", true);
                        }
                        else
                        {
                            VMHelp.ShowMessage("启用失败", false);
                        }
                    }
                    else if (silist[silist.Count - 1].SI_Time <= DateTime.Parse(DateTime.Now.ToShortDateString()))
                    {
                        si.ID = silist[silist.Count - 1].ID;
                        if (tranClient.CreateAccountSIDB(tempacc, si, tempdb, 2))
                        {
                            VMHelp.ShowMessage("启用成功!", true);
                            // windowClose();
                        }
                        else
                        {
                            VMHelp.ShowMessage("启用失败", false);
                        }
                    }
                    FlushExecute();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 确认按钮
        /// </summary>
        public override void OKExecute()
        {
            if (Models == null && CurrentObj.AM_JgAccount != null)
            {
                if (Check() && VMHelp.AskMessage("确认要进行开户?"))
                {
                    ObservableCollection <FundsRegulatoryClient.JG_InterestRateSrv.JG_InterestRateInfo> rate = InterestRateClient.Selects();
                    if (rate.Count > 0)
                    {
                        CurrentObj.AM_ID         = Guid.NewGuid().ToString();
                        CurrentObj.AM_BankCode   = "07";//银行代码
                        CurrentObj.AM_CreateDate = DateTime.Parse(VMHelp.NowTime);
                        //bool result = client.Add(CurrentObj);
                        //对象赋值转换
                        FundsRegulatoryClient.SqlTransSvr.JG_AccountManageInfo tempacc = new FundsRegulatoryClient.SqlTransSvr.JG_AccountManageInfo();
                        tempacc.AM_ID          = CurrentObj.AM_ID;
                        tempacc.AM_BankCode    = VMHelp.BankCode;//银行代码
                        tempacc.AM_CreateDate  = DateTime.Parse(VMHelp.NowTime);
                        tempacc.AM_CorpName    = CurrentObj.AM_CorpName;
                        tempacc.AM_ItemName    = CurrentObj.AM_ItemName;
                        tempacc.AM_JgAccount   = CurrentObj.AM_JgAccount;
                        tempacc.AM_ProjectCode = CurrentObj.AM_ProjectCode;
                        tempacc.AM_UseFlag     = CurrentObj.AM_UseFlag;
                        tempacc.AM_zhmc        = CurrentObj.AM_zhmc;
                        tempacc.AM_Person      = CurrentObj.AM_Person;;
                        FundsRegulatoryClient.SqlTransSvr.DayBalance db = new FundsRegulatoryClient.SqlTransSvr.DayBalance();
                        //每天余额表添加一条
                        db.DB_ID           = CurrentObj.AM_ID;
                        db.DB_AccountNum   = CurrentObj.AM_JgAccount;
                        db.DB_Balance      = 0;
                        db.DB_InterestRate = rate[0].InterestRate;     //利率;
                        db.DB_Time         = DateTime.Parse(DateTime.Now.ToShortDateString());
                        db.ID = Guid.NewGuid().ToString();
                        //  bool result2 = InterestClient.AddJG_DayBalanceInfo(db);
                        //季度结息表增加一条
                        FundsRegulatoryClient.SqlTransSvr.SeasonInterest si = new FundsRegulatoryClient.SqlTransSvr.SeasonInterest();
                        DateTime?dt = FinancialRegulation.Tools.HelpClass.Current.SYSCONFIG.PayAccuralDate;
                        if (dt == null || dt.Value.AddMonths(3) < DateTime.Parse(DateTime.Now.ToShortDateString()))
                        {
                            VMHelp.ShowMessage("请先设置结息日期", false);
                            return;
                        }
                        if (dt.Value < DateTime.Parse(DateTime.Now.ToShortDateString()))
                        {
                            si.SI_Time = dt.Value.AddMonths(3);
                        }
                        else
                        {
                            si.SI_Time = dt.Value;
                        }
                        //si.SI_Time = db.DB_Time.Value.AddMonths(3);
                        si.SI_ID         = CurrentObj.AM_ID;
                        si.SI_AccountNum = db.DB_AccountNum;
                        si.ID            = Guid.NewGuid().ToString();
                        // bool result3 = InterestClient.AddJG_SeasonInterestInfo(si);

                        if (tranClient.CreateAccountSIDB(tempacc, si, db, 1))
                        {
                            VMHelp.ShowMessage("开户成功!", true);
                            windowClose();
                        }
                        else
                        {
                            VMHelp.ShowMessage("开户信息保存失败", false);
                        }
                    }
                    else
                    {
                        VMHelp.ShowMessage("请先设置利率", false);
                    }
                }
            }
            else if (Check() && VMHelp.AskMessage("确认要进行修改?"))
            {
                bool result = client.Update(CurrentObj);
                if (result)
                {
                    int index = this.Models.IndexOf(para);
                    if (index > -1)
                    {
                        this.Models[index] = CurrentObj;
                    }
                    VMHelp.ShowMessage("账户修改成功!", true);
                    windowClose();
                }
                else
                {
                    VMHelp.ShowMessage("账户修改信息保存失败", false);
                }
            }
        }