コード例 #1
0
        //删除账户信息
        private void menuDeletedOperator_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("确认删除此账户的数据吗?", "提醒", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                bool isAddBalanceSuccess;
                bool isOperatorSuccess;
                using (TransactionScope ts = new TransactionScope())
                {
                    isAddBalanceSuccess = new BalanceBLL().DeleteByOperatorId(LoginWindow.GetOperatorId());
                    isOperatorSuccess   = new OperatorBLL().DeleteOperator(LoginWindow.GetOperatorId());
                    ts.Complete();
                }

                if (isOperatorSuccess && isAddBalanceSuccess)
                {
                    MessageBox.Show("用户删除成功!");
                    this.Close();
                    //注销重启
                    Application.Current.Shutdown();
                    System.Reflection.Assembly.GetEntryAssembly();
                    string startpath = System.IO.Directory.GetCurrentDirectory();
                    System.Diagnostics.Process.Start(startpath + "/PAMSystem.UI.exe");
                }
                else
                {
                    MessageBox.Show("用户删除失败!");
                }
            }
        }
コード例 #2
0
        public static Balance Balance(this Organization node)
        {
            var ctx   = new BalanceBLL();
            var model = ctx.Filter(x => x.TargetId == node.Id && x.TargetCategory == (int)CategoryDictionary.Organization).OrderByDescending(x => x.AuditDate).FirstOrDefault();

            return(model);
        }
コード例 #3
0
    private void GetTotalRecords()
    {
        List <SearchRow> SearchRowsList = Session["SearchRowsList"] as List <SearchRow>;


        string where = "(" + new SearchBLL().GetSearchSql(SearchRowsList) + ")" + BasicFilter;

        if (SearchType == Common.Tools.CaseTableType)
        {
            this.lblTitle.Text = CompanyName + " : 案件记录";
            TotalRecords       = new CaseBLL(int.Parse(CompanyID)).GetCaseTotalItems(where).ToString();
        }
        else if (SearchType == Common.Tools.BalanceTableType)
        {
            this.lblTitle.Text = CompanyName + " : 余额记录";
            TotalRecords       = new BalanceBLL(int.Parse(CompanyID)).GetBalanceTotalItems(where).ToString();
        }

        else if (SearchType == Common.Tools.PaymentTableType)
        {
            this.lblTitle.Text = CompanyName + " : 每日还款记录";
            TotalRecords       = new PaymentBLL(int.Parse(CompanyID)).GetPaymentTotalItems(where).ToString();
        }

        PagingControl1.TotalRecords = int.Parse(TotalRecords);
    }
コード例 #4
0
        private void rCompra_Load(object sender, EventArgs e)
        {
            int id = 1;

            foreach (var item in BalanceBLL.GetList(f => f.BalanceId == id))
            {
                BalancetextBox.Text = item.Monto.ToString();
            }
        }
コード例 #5
0
        public void CustomDataImport(DataTable dt, string token, string itemId)
        {
            using (cnn = GetConnection())
            {
                var ts = cnn.BeginTransaction();

                try
                {
                    var           user    = this.UserInfoGet(token, ts);
                    AccountSetBLL account = new AccountSetBLL(cnn);
                    var           period  = account.GetActivePeriod(user.AccountId, ts);

                    BalanceBLL balanceBLL = new BalanceBLL(cnn);
                    PeriodBLL  periodBLL  = new PeriodBLL(cnn);

                    string sql = string.Empty;
                    sql = @"delete from TKS_FAS_CaculateHelperDetail where AccountId=@AccountId and ParentId=@ParentId";
                    cnn.Execute(sql, new { AccountId = user.AccountId, ParentId = itemId }, ts);
                    if (dt.DefaultView.ToTable(true, "Name").Rows.Count < dt.Rows.Count)
                    {
                        throw new NormalException("名称不能重复");
                    }
                    for (var i = 0; i < dt.Rows.Count; i++)
                    {
                        var rowItem = dt.Rows[i];
                        TKS_FAS_CaculateHelperDetail fix = new TKS_FAS_CaculateHelperDetail();
                        fix.Id        = Guid.NewGuid().ToString("N");
                        fix.AccountId = user.AccountId;
                        fix.ParentId  = itemId;//当前期间为录入期间
                        fix.IsValid   = 1;
                        fix.Code      = (i + 1).ToString().PadLeft(3, '0');
                        fix.Name      = rowItem["Name"].ToString();
                        fix.Memo      = rowItem["Memo"].ToString();
                        fix.Custom1   = "#nodata#";
                        fix.Custom2   = "#nodata#";
                        fix.Custom3   = "#nodata#";
                        fix.Custom4   = "#nodata#";
                        fix.Custom5   = "#nodata#";
                        fix.Custom6   = "#nodata#";
                        fix.Custom7   = "#nodata#";
                        fix.Custom8   = "#nodata#";
                        cnn.Insert <TKS_FAS_CaculateHelperDetail>(fix, ts);
                    }
                    ts.Commit();
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    throw ex;
                }
            }
        }
コード例 #6
0
        // GET: OverPay
        public ActionResult Index()
        {
            string     strno      = Request["strno"];
            BalanceBLL balancebll = new BalanceBLL();

            // HistoryBillData billdata = balancebll.GetPayOrder(12, "owDsuwF-DB_0UXfM_DEhbNJYOjug");


            balancebll.PayOk(strno).ConfigureAwait(true);


            return(View());
        }
コード例 #7
0
ファイル: DocBLL.cs プロジェクト: ph3405/FAS-CSZJ-SAAS
        public ResponseDocAdd DocAdd(RequestDocAdd request)
        {
            ResponseDocAdd response = new ResponseDocAdd();

            using (cnn = GetConnection())
            {
                BalanceBLL balBLL = new BalanceBLL(cnn);
                var        ts     = cnn.BeginTransaction();
                try
                {
                    var user = this.UserInfoGet(request.Token, ts);

                    #region modify by andy 期间根据凭证日期计算
                    //AccountSetBLL account = new FAS.AccountSetBLL(cnn);
                    //var period = account.GetActivePeriod(user.AccountId, ts);
                    var       pzDate     = request.Head.PZDate;
                    PeriodBLL balanceBLL = new PeriodBLL(cnn);
                    var       period     = balanceBLL.GetPeriod(user.AccountId, pzDate?.Year ?? 0, pzDate?.Month ?? 0, ts);
                    #endregion

                    request.Head.Id     = Guid.NewGuid().ToString("N");
                    request.Head.Source = "LR";
                    Add(request, ts, user);

                    DealByPZType(request, ts, user);

                    #region 新增凭证时,对余额表进行操作 Add by Hero.Zhang

                    balBLL.UpdateBalance(request, ts, user);

                    #endregion
                    ts.Commit();
                    response.Id = request.Head.Id;

                    response.IsSuccess = true;
                    response.Message   = "新增成功";
                    return(response);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    return(this.DealException(response, ex) as ResponseDocAdd);
                }
            }
        }
コード例 #8
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (IsShowBalance)
     {
         txtBalance.IsReadOnly = true;                                         //查询时txtBalance为只读
         Balance b = new BalanceBLL().GetBalance(LoginWindow.GetOperatorId()); //根据用户Id查询余额
         txtBalance.Text   = b.Balances.ToString();
         btnYes.Visibility = Visibility.Collapsed;                             //隐藏“确定”按钮
         if (b.Balances < 0)
         {
             MessageBox.Show("你已经入不敷出了,快点赚钱吧!");
         }
     }
     else
     {
         tbBalanceText.Text = "添加余额";
     }
 }
コード例 #9
0
        //删除选中数据
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Account account = (Account)dataGridShow.SelectedItem;

            //判断是否选中数据
            if (account == null)
            {
                MessageBox.Show("请选择一条数据!");
                return;
            }
            if (MessageBox.Show("确认删除此条数据吗?", "提醒", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                IdName idname = new IdNameBLL().GetByName("收入");
                int    i;         //deleted返回
                bool   isSuceess; //判断余额是否更新成功
                using (TransactionScope ts = new TransactionScope())
                {
                    i = new AccountBLL().DeleteById(account.Id);
                    Balance balance = new Balance();
                    if (idname.Id == account.CostType)//要删除的为收入
                    {
                        balance.Balances = (decimal)(-account.Money);
                        isSuceess        = new BalanceBLL().Update(account.OperatorId, balance.Balances);
                    }
                    else
                    {
                        balance.Balances = (decimal)account.Money;
                        isSuceess        = new BalanceBLL().Update(account.OperatorId, balance.Balances);
                    }
                    if (i > 0 && isSuceess)
                    {
                        MessageBox.Show("删除成功!");
                    }
                    else
                    {
                        MessageBox.Show("删除失败!");
                    }
                    ts.Complete();
                }
                LoadData();
            }
        }
コード例 #10
0
 //添加余额
 private void btnYes_Click(object sender, RoutedEventArgs e)
 {
     if (!IsShowBalance)
     {
         Balance balance = new Balance();
         balance.Balances = decimal.Parse(txtBalance.Text);    //把string类型转为decimal
         bool i = new BalanceBLL().Update(LoginWindow.GetOperatorId(), balance.Balances);
         if (i)
         {
             new OperationLogBLL().Insert(LoginWindow.GetOperatorId(), "添加余额成功!");
             MessageBox.Show("添加数据成功!");
             this.Close();
         }
         else
         {
             new OperationLogBLL().Insert(LoginWindow.GetOperatorId(), "添加余额失败!");
             MessageBox.Show("添加数据错误!");
             this.Close();
         }
     }
 }
コード例 #11
0
    private DataSet GetDataGridSource()
    {
        List <SearchRow> SearchRowsList = Session["SearchRowsList"] as List <SearchRow>;


        string where = "(" + new SearchBLL().GetSearchSql(SearchRowsList) + ")" + BasicFilter;
        DataSet ds = null;

        if (SearchType == Common.Tools.CaseTableType)
        {
            ds = new CaseBLL(int.Parse(CompanyID)).GetCasePagingitems(this.PagingControl1.ListRecordNumPerPage, this.PagingControl1.CurrentPage, where);
        }
        else if (SearchType == Common.Tools.BalanceTableType)
        {
            ds = new BalanceBLL(int.Parse(CompanyID)).GetBalancePagingitems(this.PagingControl1.ListRecordNumPerPage, this.PagingControl1.CurrentPage, where);
        }

        else if (SearchType == Common.Tools.PaymentTableType)
        {
            ds = new PaymentBLL(int.Parse(CompanyID)).GetPaymentPagingitems(this.PagingControl1.ListRecordNumPerPage, this.PagingControl1.CurrentPage, where);
        }

        if (ds == null || ds.Tables[0].Rows.Count == 0)
        {
            spanExcel.Style.Add("display", "none");
        }
        else
        {
            DataSet reportDs = ds.Copy();
            AdoptToExcelFormat(reportDs);
            ChangeColumnTitle(reportDs);
            Session["ExportData"] = reportDs;

            ChangeColumnTitle(ds);
        }
        return(ds);
    }
コード例 #12
0
        //点击保存按钮的
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Account    account    = (Account)gridEditAccount.DataContext;
            AccountBLL accountBll = new AccountBLL();

            //判断金额大于0
            if (cbType.SelectedIndex > -1)
            {
                if (account.Money <= 0)
                {
                    MessageBox.Show("你输入的收入金额不合法,请重新输入!");
                    return;
                }
            }
            if (cbType.SelectedIndex < 0)
            {
                MessageBox.Show("请选择收支!");
                return;
            }
            else if (cbItem.SelectedIndex < 0)
            {
                MessageBox.Show("请选择项目!");
                return;
            }
            //有问题
            else
            {
                //获得名字为收入的Id值
                IdName  idname  = new IdNameBLL().GetByName("收入");
                Balance balance = new Balance();
                #region 添加收支
                //添加收支
                if (IsAddNew)
                {
                    int i;
                    //分布式事务处理收支和余额,可实现回滚
                    using (TransactionScope ts = new TransactionScope())
                    {
                        i = accountBll.AddNew(account);
                        //判断是否为收入,收入为正的,支出为负数
                        if (account.CostType == idname.Id)    //收入
                        {
                            balance.Balances = (decimal)account.Money;
                        }
                        else //支出
                        {
                            balance.Balances = (decimal)(-account.Money);
                        }

                        new BalanceBLL().Update(account.OperatorId, balance.Balances);
                        ts.Complete();//表示已完成
                    }
                    //严谨点Update也应该返回true or false
                    if (i < 0)
                    {
                        new OperationLogBLL().Insert(LoginWindow.GetOperatorId(), "添加收支,更新余额失败!");
                        MessageBox.Show("添加错误!");
                    }
                    else if (i > 1)
                    {
                        new OperationLogBLL().Insert(LoginWindow.GetOperatorId(), "添加收支时错误!");
                        throw new Exception("数据发生错误!");
                    }
                    else
                    {
                        new OperationLogBLL().Insert(LoginWindow.GetOperatorId(), "添加收支,更新余额成功!");//日志
                        MessageBox.Show("添加成功!");
                        this.Close();
                    }
                }
                #endregion

                #region 编辑收支
                //编辑收支
                else
                {
                    bool i;               //插入余额是否成功
                    bool isAddbalanceSuc; //插入余额是否成功
                    //分布式处理
                    using (TransactionScope ts = new TransactionScope())
                    {
                        //更新收支
                        i = accountBll.Update(account);

                        //更新前的数据类型是否为收入,并计算出差额,
                        if (BeforeCostType == idname.Id)
                        {
                            //收入改为收入 只是金额的更改
                            if (account.CostType == idname.Id)                                      //更改后收支类型,为收入
                            {
                                if ((decimal)account.Money != BeforeEditingMoney)                   //更新后的钱不等更新前的前
                                {
                                    balance.Balances = (decimal)account.Money - BeforeEditingMoney; //加上前后的差额(后大于前取+,否则为—)
                                }
                                else
                                {
                                    balance.Balances = 0;
                                }
                            }
                            //收入改为支出,前为收,后为支
                            else
                            {
                                // 先减去更新前的收入,再减去更新后的支出金额
                                balance.Balances = -BeforeEditingMoney - (decimal)account.Money;
                            }
                        }
                        //若更新前为支出,计算出差额
                        else
                        {
                            //判断更新后的类型
                            if (account.CostType == idname.Id)                                  //更新后的类型为收入,更新前为支出
                            {
                                balance.Balances = BeforeEditingMoney + (decimal)account.Money; //先加上更新前的支出,再加上更新后的收入
                            }
                            //更新后为支出,更新前为支出
                            else
                            {
                                if (BeforeEditingMoney != (decimal)account.Money)                   //更新前的钱不等于更新后的钱,求钱差额
                                {
                                    balance.Balances = BeforeEditingMoney - (decimal)account.Money; //更新前 减去更新后  若更新前大,那就加上差额
                                }
                                else
                                {
                                    balance.Balances = 0;
                                }
                            }
                        }
                        isAddbalanceSuc = new BalanceBLL().Update(account.OperatorId, balance.Balances);
                        ts.Complete();
                    }
                    if (i && isAddbalanceSuc)
                    {
                        new OperationLogBLL().Insert(LoginWindow.GetOperatorId(), "编辑收支成功!");
                        MessageBox.Show("更改成功!");
                        this.Close();
                    }
                    else
                    {
                        new OperationLogBLL().Insert(LoginWindow.GetOperatorId(), "编辑收支失败!");
                        MessageBox.Show("更新失败!");
                    }
                }
                #endregion
            }
        }
コード例 #13
0
ファイル: DocBLL.cs プロジェクト: ph3405/FAS-CSZJ-SAAS
        public ResponseDocDelete DocDelete(RequestDocDelete request)
        {
            ResponseDocDelete response = new ResponseDocDelete();

            using (cnn = GetConnection())
            {
                var ts = cnn.BeginTransaction();
                try
                {
                    BalanceBLL     balanceBLL = new BalanceBLL(cnn);
                    var            user       = this.UserInfoGet(request.Token, ts);
                    FixedAssetsBLL fixBLL     = new FixedAssetsBLL(cnn);
                    var            flag       = fixBLL.IsDocHasChangeRecord(request.Data.Id, ts);
                    if (flag)
                    {
                        //取消此判断 update by Hero.Zhang 20180404
                        //throw new NormalException("该凭证通过固定资产生成,无法删除");
                    }


                    string sql     = @"select * from tks_fas_doc where id=@Id";
                    var    DocDate = cnn.Query(sql, new { Id = request.Data.Id }, ts);
                    if (DocDate.Count() <= 0)
                    {
                        throw new NormalException("该凭证已经删除");
                    }
                    var       data   = cnn.QueryFirst <TKS_FAS_Doc>(sql, new { Id = request.Data.Id }, ts);
                    PeriodBLL period = new PeriodBLL(cnn);
                    flag = period.IsPeriodPaid(data.PeriodId, ts);
                    if (flag)
                    {
                        throw new NormalException("该凭证已经期末结转,无法删除");
                    }
                    #region 先回滚余额表 Hero.Zhang
                    List <TKS_FAS_DocDetail> Detail = cnn.Query <TKS_FAS_DocDetail>("select *  from TKS_FAS_DocDetail where parentId=@ParentId", new { ParentId = request.Data.Id }, ts).ToList();
                    var doc = cnn.QueryFirst <TKS_FAS_Doc>("select * from TKS_FAS_Doc where id=@Id",
                                                           new { Id = request.Data.Id }, ts);
                    RequestDocAdd oldDoc = new RequestDocAdd();
                    oldDoc.Head   = doc;
                    oldDoc.Detail = Detail;
                    foreach (var det in oldDoc.Detail)
                    {
                        det.Money_Debit  = -1 * det.Money_Debit;
                        det.Money_Credit = -1 * det.Money_Credit;
                        det.Quantity     = -1 * det.Quantity;
                    }
                    balanceBLL.UpdateBalance(oldDoc, ts, user);
                    #endregion

                    sql = @" delete from TKS_FAS_Doc where id=@Id";

                    cnn.Execute(sql, request.Data, ts);

                    sql = "delete from TKS_FAS_DocDetail where parentId=@ParentId";
                    cnn.Execute(sql, new { ParentId = request.Data.Id }, ts);

                    //发票状态置为 递交财务
                    sql = "update tks_fas_invoice set status=1 where pzId=@PZId and AccountId=@AccountId";
                    cnn.Execute(sql, new { PZId = data.Id, AccountId = data.AccountId }, ts);

                    sql = "delete from TKS_FAS_TPL2PZ where pzId=@PZID and AccountId=@AccountId ";
                    cnn.Execute(sql, new { PZID = data.Id, AccountId = data.AccountId }, ts);
                    // add by Hero.Zhang 20180404

                    /*判断次凭证号是否在变更记录及生成凭证表TKS_FAS_FixedAssetsChange中,如果存在,则
                     * 将这笔数据还原成新增并且没有生成凭证的状态;同时将固定资产表TKS_FAS_FixedAssets中这笔固定资产变更为‘未生成凭证状态’,同时将折旧相关数据回冲一个月*/
                    var check     = "select * from TKS_FAS_FixedAssetsChange where docid=@docid and AccountId=@AccountId";
                    var datacheck = cnn.Query(check, new { docid = data.Id, AccountId = data.AccountId }, ts);
                    if (datacheck.Count() > 0)
                    {
                        var dataUpdate = cnn.QueryFirst <TKS_FAS_FixedAssetsChange>(check, new { docid = data.Id, AccountId = data.AccountId }, ts);
                        if (dataUpdate != null)
                        {
                            sql = "update TKS_FAS_FixedAssetsChange set ChangeType=1,DocId='',DocPZZ='' where id=@id  and AccountId=@AccountId";
                            //cnn.Execute(sql, new { id = request.TKS_FAS_FixedAssetsChange_Id, AccountId = data.AccountId }, ts);
                            cnn.Execute(sql, new { id = dataUpdate.Id, AccountId = data.AccountId }, ts);
                            sql = "update TKS_FAS_FixedAssets set IsGenPZ=0 where id=@id  and AccountId=@AccountId";
                            //cnn.Execute(sql, new { id = request.TKS_FAS_FixedAssets_Id, AccountId = data.AccountId }, ts);
                            cnn.Execute(sql, new { id = dataUpdate.ParentId, AccountId = data.AccountId }, ts);
                        }
                    }
                    //add by Hero.Zhang 20180903 删除计提折旧凭证,回滚固定资产计提折旧数据
                    if (data.Source == PZType.GD.ToString())
                    {
                        //add by Hero.Zhang 删除折旧凭证判断,如果改凭证的日期之后有折旧凭证,则不允许删除
                        var checkPZ = @"select * from tks_fas_doc where source='GD' and PZDate>@PZDate AND AccountId=@AccountId";
                        var PZcheck = cnn.Query(checkPZ, new { PZDate = data.PZDate, AccountId = data.AccountId }, ts);
                        if (PZcheck.Count() > 0)
                        {
                            throw new NormalException("该计提折旧凭证无法删除,请先删除下一个期间的计提折旧凭证");
                        }

                        //回滚固定资产
                        fixBLL.RollbackFixedAssets(user.AccountId, data.PeriodId, ts);
                    }
                    ts.Commit();
                    response.IsSuccess = true;
                    response.Message   = "删除成功";
                    return(response);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    return(this.DealException(response, ex) as ResponseDocDelete);
                }
            }
        }
コード例 #14
0
ファイル: DocBLL.cs プロジェクト: ph3405/FAS-CSZJ-SAAS
        public ResponseDocUpdate DocUpdate(RequestDocUpdate request)
        {
            ResponseDocUpdate response = new ResponseDocUpdate();

            using (cnn = GetConnection())
            {
                var        ts     = cnn.BeginTransaction();
                BalanceBLL balBLL = new BalanceBLL(cnn);
                try
                {
                    var user = this.UserInfoGet(request.Token, ts);

                    var doc = cnn.QueryFirst <TKS_FAS_Doc>("select * from TKS_FAS_Doc where id=@Id",
                                                           new { Id = request.Head.Id }, ts);
                    PeriodBLL period = new PeriodBLL(cnn);
                    bool      flag   = period.IsPeriodPaid(doc.PeriodId, ts);
                    if (flag)
                    {
                        throw new NormalException("该凭证已经期末结转,无法修改");
                    }

                    flag = period.IsHasPeriod(doc.PeriodId, ts);

                    if (!flag)
                    {
                        throw new NormalException("该凭证期间非激活状态,无法修改");
                    }
                    List <TKS_FAS_DocDetail> Detail = cnn.Query <TKS_FAS_DocDetail>("select *  from TKS_FAS_DocDetail where parentId=@ParentId", new { ParentId = request.Head.Id }, ts).ToList();

                    #region 先回滚余额表 Hero.Zhang
                    RequestDocAdd oldDoc = new RequestDocAdd();
                    oldDoc.Head   = doc;
                    oldDoc.Detail = Detail;
                    foreach (var det in oldDoc.Detail)
                    {
                        det.Money_Debit  = -1 * det.Money_Debit;
                        det.Money_Credit = -1 * det.Money_Credit;
                        det.Quantity     = -1 * det.Quantity;
                    }
                    balBLL.UpdateBalance(oldDoc, ts, user);
                    #endregion

                    string sql = @" delete from TKS_FAS_Doc where id=@Id";

                    cnn.Execute(sql, request.Head, ts);

                    sql = "delete from TKS_FAS_DocDetail where parentId=@ParentId";
                    cnn.Execute(sql, new { ParentId = request.Head.Id }, ts);


                    request.Head.Id     = request.Head.Id;
                    request.Head.Source = "LR";
                    var id = Add(new RequestDocAdd
                    {
                        Token  = request.Token,
                        Head   = request.Head,
                        Detail = request.Detail
                    }, ts, user);

                    #region 更新余额表 Hero.Zhang
                    RequestDocAdd docRequest = new RequestDocAdd();
                    docRequest.Head   = request.Head;
                    docRequest.Detail = request.Detail;
                    docRequest.Type   = request.Type;
                    docRequest.TPLId  = request.TPLId;
                    docRequest.Key    = request.Key;
                    balBLL.UpdateBalance(docRequest, ts, user);
                    #endregion
                    ts.Commit();

                    response.IsSuccess = true;
                    response.Id        = id;
                    response.Message   = "更新成功";



                    return(response);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    return(this.DealException(response, ex) as ResponseDocUpdate);
                }
            }
        }
コード例 #15
0
ファイル: WxPayController.cs プロジェクト: ztxyzu/wx_public
        }                                               //H5调起JS API参数

        public ActionResult Index(string amountid, string hidopenid)
        {
            BalanceBLL balancebll = new BalanceBLL();

            Log.Debug(this.GetType().ToString(), "amount: " + amountid);
            Log.Debug(this.GetType().ToString(), "openid: " + hidopenid);
            ViewBag.nowdata = DateTime.Now.ToString();
            // string out_trade_no = WxPayApi.GenerateOutTradeNo();
            string out_trade_no = "";

            JsApiPay jsApiPay = new JsApiPay(System.Web.HttpContext.Current);

            //JSAPI支付预处理
            try
            {
                ViewBag.Amount = amountid;

                double value = double.Parse(amountid);

                decimal dvalue = decimal.Parse(amountid);

                int payamount = int.Parse((value * 100).ToString());
                Log.Debug(this.GetType().ToString(), "payamount : " + payamount);

                HistoryBillData billdata = balancebll.GetPayOrder(dvalue, hidopenid);

                out_trade_no = billdata.Id.ToString();
                out_trade_no = WxPayApi.GenerateOutTradeNo() + out_trade_no;

                ViewBag.orderno = billdata.Id.ToString();
                //Log.Debug(this.GetType().ToString(), "out_trade_no : " + out_trade_no);
                //Log.Debug(this.GetType().ToString(), "out_trade_no23 : " + out_trade_no.Substring(25));


                //这里先写入数据库,写好了在发起API的调用付款


                //result=WriteData(out_trade_no,hidopenid,amountid);


                if (!string.IsNullOrEmpty(out_trade_no))
                {
                    //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数
                    jsApiPay.openid    = hidopenid;
                    jsApiPay.total_fee = payamount;// 订单金额(1表示分,正式金额要*100)

                    ViewBag.out_trade_no = out_trade_no;
                    WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(out_trade_no);
                    wxJsApiParam         = jsApiPay.GetJsApiParameters(); //获取H5调起JS API参数
                    ViewBag.wxJsApiParam = wxJsApiParam;                  //前台页面js调用


                    //在页面上显示订单信息
                }
            }
            catch (Exception ex)
            {
                Log.Error(this.GetType().ToString(), "ex : " + ex.Message);
            }



            return(View());
        }
コード例 #16
0
        public TKS_FAS_MonthPeriodInfo CreateNextPeriod(TKS_FAS_MonthPeriodInfo curPeriod, IDbTransaction ts)
        {
            BalanceBLL balanceBLL = new BalanceBLL(cnn);
            int        month      = 1;
            int        year       = 1997;

            if (curPeriod.Month == 12)
            {
                month = 1;
                year  = curPeriod.Year + 1;
            }
            else
            {
                month = curPeriod.Month + 1;
                year  = curPeriod.Year;
            }

            string sql = @"select * from TKS_FAS_MonthPeriodInfo 
                            where accountId=@AccountId and year=@Year and month=@Month";

            var data = cnn.QueryFirstOrDefault <TKS_FAS_MonthPeriodInfo>
                           (sql, new { AccountId = curPeriod.AccountId, Year = year, Month = month }, ts);

            if (data != null)
            {
                //balanceBLL.BalanceAddup(data, curPeriod, ts);
                return(data);
            }
            else
            {
                #region 插入新的期间

                sql = @"select * from tks_fas_periodTrack where fromId=@FromId";
                var trackData = cnn.QueryFirstOrDefault <TKS_FAS_PeriodTrack>(sql, new { FromId = curPeriod.Id }, ts);

                TKS_FAS_MonthPeriodInfo newPeriod = new TKS_FAS_MonthPeriodInfo();
                if (trackData == null)
                {
                    newPeriod.Id = Guid.NewGuid().ToString("N");
                }
                else
                {
                    newPeriod.Id = trackData.ToId;
                }

                newPeriod.AccountId = curPeriod.AccountId;
                newPeriod.IsActive  = 0;
                newPeriod.IsPay     = 0;

                if (curPeriod.Month == 12)
                {
                    newPeriod.Month = 1;
                    newPeriod.Year  = curPeriod.Year + 1;
                    //如果是12月份,则把年度期间也更新为激活,插入新的年度期间
                    sql = @"update TKS_FAS_YearPeriodInfo set isClose=1,isActive=0 where id=@Id and isClose=0 and isActive=1";
                    cnn.Execute(sql, new { Id = curPeriod.ParentId }, ts);

                    TKS_FAS_YearPeriodInfo newYearPeriod = new TKS_FAS_YearPeriodInfo();
                    newYearPeriod.Id        = Guid.NewGuid().ToString("N");
                    newYearPeriod.IsActive  = 0;
                    newYearPeriod.IsClose   = 0;
                    newYearPeriod.AccountId = curPeriod.AccountId;
                    newYearPeriod.StartDate = DateTime.Parse(newPeriod.Year + "-01-01");
                    newYearPeriod.EndDate   = DateTime.Parse(newPeriod.Year + "-12-31 23:59:59");
                    newYearPeriod.PeriodNUM = 12;
                    newYearPeriod.Year      = newPeriod.Year;
                    cnn.Insert <TKS_FAS_YearPeriodInfo>(newYearPeriod, ts);

                    newPeriod.ParentId = newYearPeriod.Id;
                }
                else
                {
                    newPeriod.ParentId = curPeriod.ParentId;
                    newPeriod.Month    = curPeriod.Month + 1;
                    newPeriod.Year     = curPeriod.Year;
                }
                newPeriod.StartDate = DateTime.Parse(newPeriod.Year + "-" + newPeriod.Month + "-01");
                newPeriod.EndDate   = newPeriod.StartDate.Value.AddMonths(1).AddSeconds(-1);
                cnn.Insert <TKS_FAS_MonthPeriodInfo>(newPeriod, ts);
                if (trackData == null)
                {
                    //期间历史
                    TKS_FAS_PeriodTrack track = new TKS_FAS_PeriodTrack();
                    track.Id        = Guid.NewGuid().ToString("N");
                    track.FromId    = curPeriod.Id;
                    track.ToId      = newPeriod.Id;
                    track.FromYear  = curPeriod.Year.ToString();
                    track.ToYear    = newPeriod.Year.ToString();
                    track.FromMonth = curPeriod.Month.ToString();
                    track.ToMonth   = newPeriod.Month.ToString();
                    track.AccountId = curPeriod.AccountId;
                    cnn.Insert <TKS_FAS_PeriodTrack>(track, ts);
                }

                #endregion

                balanceBLL.BalanceAddup(newPeriod, curPeriod, ts);
                balanceBLL.FBalanceAddup(newPeriod, curPeriod, ts);
                return(newPeriod);
            }
        }