コード例 #1
0
        public Task <SupplierPayDto> Update(SupplierPayDto supplierPayDto)
        {
            SupplierPay supplierPay = ObjectMapper.Map <SupplierPay>(supplierPayDto);

            supplierPay = _supplierPayRepository.Update(supplierPay);
            return(Task.FromResult <SupplierPayDto>(supplierPayDto));
        }
コード例 #2
0
 /// <summary>
 /// 清除引用
 /// </summary>
 /// <param name="model"></param>
 public static void ClearReferences(this SupplierPay model)
 {
     model.tb_admin    = null;
     model.tb_device   = null;
     model.tb_supplier = null;
     model.tb_balance  = null;
 }
コード例 #3
0
        public async Task <SupplierPayDto> GetById(int id)
        {
            SupplierPay result = await _supplierPayRepository.GetAsync(id);

            SupplierPayDto dto = ObjectMapper.Map <SupplierPayDto>(result);

            return(dto);
        }
コード例 #4
0
        public Task <SupplierPayDto> Create(SupplierPayDto supplierPayDto)
        {
            supplierPayDto.CreatorUserId = AbpSession.UserId.Value;
            supplierPayDto.CreationTime  = DateTime.Now;
            SupplierPay supplierPay = ObjectMapper.Map <SupplierPay>(supplierPayDto);

            supplierPayDto.Id = _supplierPayRepository.InsertAndGetId(supplierPay);
            return(Task.FromResult <SupplierPayDto>(supplierPayDto));
        }
コード例 #5
0
ファイル: CommonPayModel.cs プロジェクト: oybab/TradingSystem
 public CommonPayModel(SupplierPay model)
 {
     this.ParentId           = model.SupplierId;
     this.BalanceId          = model.BalanceId;
     this.SupplierId         = model.SupplierId;
     this.BalancePrice       = model.BalancePrice;
     this.OriginalPrice      = model.OriginalPrice;
     this.Price              = model.Price;
     this.Supplier           = model.tb_supplier;
     this.AddTime            = model.AddTime;
     this.Remark             = model.Remark;
     this.Type               = "SupplierPay";
     this.PayId              = model.SupplierPayId;
     this.ParentBalancePrice = model.ParentBalancePrice;
 }
コード例 #6
0
ファイル: CommonPayModel.cs プロジェクト: oybab/TradingSystem
        public SupplierPay GetSupplierPay()
        {
            SupplierPay model = new SupplierPay();

            model.SupplierId = ParentId;
            model.BalanceId  = BalanceId ?? 0;

            model.BalancePrice  = BalancePrice;
            model.OriginalPrice = OriginalPrice;

            model.Price              = Price;
            model.AddTime            = AddTime;
            model.Remark             = Remark;
            model.SupplierPayId      = PayId;
            model.ParentBalancePrice = ParentBalancePrice;

            return(model);
        }
コード例 #7
0
        /// <summary>
        /// 删除数据
        /// </summary>
        private void Delete()
        {
            long Id = -1;

            try
            {
                //确认删除
                var confirm = KryptonMessageBox.Show(this, Resources.GetRes().GetString("SureDelete"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (confirm != DialogResult.Yes)
                {
                    return;
                }

                Id = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmSupplierPayId"].Value.ToString());

                //如果是没添加过的记录,就直接删除
                if (Id == -1)
                {
                    KryptonMessageBox.Show(this, Resources.GetRes().GetString("DeleteSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    krpdgList.Rows.Remove(krpdgList.SelectedRows[0]);
                    return;
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                {
                    KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }), false, Resources.GetRes().GetString("DeleteFailt"));
                return;
            }

            StartLoad(this, null);


            Task.Factory.StartNew(() =>
            {
                SupplierPay supplierPay     = resultList.Where(x => x.SupplierPayId == Id).FirstOrDefault();
                double originalBalancePrice = Supplier.BalancePrice;
                ResultModel result          = new ResultModel();
                try
                {
                    Supplier.BalancePrice = Supplier.BalancePrice - supplierPay.Price;

                    Supplier newSupplier;


                    result = OperatesService.GetOperates().ServiceDelSupplierPay(Supplier, supplierPay, out newSupplier);
                    this.BeginInvoke(new Action(() =>
                    {
                        if (result.Result)
                        {
                            KryptonMessageBox.Show(this, Resources.GetRes().GetString("DeleteSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);

                            SupplierPay oldModel = resultList.Where(x => x.SupplierPayId == Id).FirstOrDefault();
                            krpdgList.Rows.Remove(krpdgList.SelectedRows[0]);
                            resultList.Remove(oldModel);

                            CommonPayModel oldCommonModel = this.commonPayList.Where(x => x.PayId == Id && x.Type == "SupplierPay").FirstOrDefault();
                            commonPayList.Remove(oldCommonModel);

                            this.ReturnValue = newSupplier;
                            this.Supplier    = newSupplier;
                        }
                        else
                        {
                            if (result.IsDataHasRefrence)
                            {
                                KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUsed"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else if (result.UpdateModel)
                            {
                                KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                KryptonMessageBox.Show(this, Resources.GetRes().GetString("DeleteFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }));
                }
                catch (Exception ex)
                {
                    this.BeginInvoke(new Action(() =>
                    {
                        ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                        {
                            if (result.Result)
                            {
                                Supplier.BalancePrice = originalBalancePrice;
                            }

                            KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }), false, Resources.GetRes().GetString("DeleteFailt"));
                    }));
                }
                StopLoad(this, null);
            });
        }
コード例 #8
0
        /// <summary>
        /// 保存新增或改动的数据
        /// </summary>
        private void Save()
        {
            if (null != krpdgList.SelectedRows[0])
            {
                //如果是插入
                if (krpdgList.SelectedRows[0].Cells["krpcmSupplierPayId"].Value.ToString().Equals("-1"))
                {
                    SupplierPay supplierPay = new SupplierPay();
                    try
                    {
                        supplierPay.SupplierPayId = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmSupplierPayId"].Value.ToString());
                        supplierPay.Price         = Math.Round(double.Parse(krpdgList.SelectedRows[0].Cells["krpcmPrice"].Value.ToString()), 2);
                        supplierPay.BalanceId     = GetBalanceTypeId(krpdgList.SelectedRows[0].Cells["krpcmBalanceType"].Value.ToString());
                        supplierPay.Remark        = GetValueOrNull(krpdgList.SelectedRows[0].Cells["krpcmRemark"].Value.ToString());
                        supplierPay.SupplierId    = this.Supplier.SupplierId;


                        if (this.Supplier.IsAllowBorrow == 0 && this.Supplier.BalancePrice + supplierPay.Price < 0)
                        {
                            KryptonMessageBox.Show(this, Resources.GetRes().GetString("SupplierBalanceNotEnough"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                        {
                            KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }), false, Resources.GetRes().GetString("SaveFailt"));
                        return;
                    }

                    StartLoad(this, null);

                    Task.Factory.StartNew(() =>
                    {
                        ResultModel result          = new ResultModel();
                        double originalBalancePrice = Supplier.BalancePrice;
                        try
                        {
                            Supplier.BalancePrice = Supplier.BalancePrice + supplierPay.Price;

                            Supplier newSupplier;
                            SupplierPay newSupplierPay;
                            result = OperatesService.GetOperates().ServiceAddSupplierPay(Supplier, supplierPay, out newSupplier, out newSupplierPay);
                            this.BeginInvoke(new Action(() =>
                            {
                                if (result.Result)
                                {
                                    KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    krpdgList.SelectedRows[0].Cells["krpcmSupplierPayId"].Value = newSupplierPay.SupplierPayId;
                                    krpdgList.SelectedRows[0].Cells["krpcmEdit"].Value          = "";

                                    krpdgList.SelectedRows[0].Cells["krpcmAddTime"].Value = DateTime.ParseExact(newSupplierPay.AddTime.ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm");
                                    this.Supplier    = newSupplier;
                                    this.ReturnValue = newSupplier;
                                    this.resultList.Insert(0, newSupplierPay);
                                    this.commonPayList.Insert(0, new CommonPayModel(newSupplierPay));

                                    krpdgList.SelectedRows[0].Cells["krpcmPrice"].ReadOnly       = true;
                                    krpdgList.SelectedRows[0].Cells["krpcmBalanceType"].ReadOnly = true;
                                    krpdgList.SelectedRows[0].Cells["krpcmRemark"].ReadOnly      = true;

                                    krptbEndTime.Text = DateTime.Now.AddMinutes(5).ToString("yyyyMMddHHmm");
                                }
                                else
                                {
                                    if (result.IsDataHasRefrence)
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUsed"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else if (result.UpdateModel)
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }
                            }));
                        }
                        catch (Exception ex)
                        {
                            this.BeginInvoke(new Action(() =>
                            {
                                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                                {
                                    if (result.Result)
                                    {
                                        Supplier.BalancePrice = originalBalancePrice;
                                    }

                                    KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }), false, Resources.GetRes().GetString("SaveFailt"));
                            }));
                        }
                        StopLoad(this, null);
                    });
                }
                //如果是编辑
                else
                {
                    // 没有编辑, 也不能编辑
                }
            }
        }
コード例 #9
0
        private void krplMemberName_MouseClick(object sender, MouseEventArgs e)
        {
            if (krpcbBalancePay.Items.Count > 0 && null != CurrentBalance && CurrentBalance.IsBalance && null != CurrentBalance.Balance)
            {
                BalanceItemModel model = krpcbBalancePay.Items[krpcbBalancePay.Items.Count - 1] as BalanceItemModel;


                double changePrice = double.Parse(this.krptChangePrice.Text);

                if (changePrice != 0 && null != model && null != model.Member && model.IsChange)
                {
                    string memberName  = "";
                    string balanceName = "";


                    if (Resources.GetRes().MainLangIndex == 0)
                    {
                        memberName = model.Member.MemberName0;
                    }
                    else if (Resources.GetRes().MainLangIndex == 1)
                    {
                        memberName = model.Member.MemberName1;
                    }
                    else if (Resources.GetRes().MainLangIndex == 2)
                    {
                        memberName = model.Member.MemberName2;
                    }


                    if (Resources.GetRes().MainLangIndex == 0)
                    {
                        balanceName = CurrentBalance.Balance.BalanceName0;
                    }
                    else if (Resources.GetRes().MainLangIndex == 1)
                    {
                        balanceName = CurrentBalance.Balance.BalanceName1;
                    }
                    else if (Resources.GetRes().MainLangIndex == 2)
                    {
                        balanceName = CurrentBalance.Balance.BalanceName2;
                    }



                    var confirm = KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("ConfirmAddPay"), Resources.GetRes().PrintInfo.PriceSymbol, ChangePrice, balanceName, memberName), Resources.GetRes().GetString("Warn"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (confirm != DialogResult.Yes)
                    {
                        return;
                    }


                    MemberPay memberpay = new MemberPay();


                    memberpay.Price     = changePrice;
                    memberpay.BalanceId = CurrentBalance.Balance.BalanceId;
                    memberpay.MemberId  = model.Member.MemberId;


                    // 开始支付
                    StartLoad(this, null);

                    Task.Factory.StartNew(() =>
                    {
                        ResultModel result          = new ResultModel();
                        double originalBalancePrice = model.Member.BalancePrice;
                        try
                        {
                            // 更新会员信息
                            model.Member.BalancePrice = model.Member.BalancePrice + memberpay.Price;

                            Member newMember;
                            MemberPay newMemberPay;
                            result = OperatesService.GetOperates().ServiceAddMemberPay(model.Member, memberpay, out newMember, out newMemberPay);
                            this.BeginInvoke(new Action(() =>
                            {
                                if (result.Result)
                                {
                                    KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);



                                    // 去掉当前最后一个会员并重新添加
                                    btnMemberRemove_Click(null, null);
                                    AddMember(newMember, null);
                                }
                                else
                                {
                                    if (result.IsDataHasRefrence)
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUsed"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else if (result.UpdateModel)
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }
                            }));
                        }
                        catch (Exception ex)
                        {
                            this.BeginInvoke(new Action(() =>
                            {
                                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                                {
                                    // 失败了就复原会员信息
                                    if (result.Result)
                                    {
                                        model.Member.BalancePrice = originalBalancePrice;
                                    }

                                    KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }), false, Resources.GetRes().GetString("SaveFailt"));
                            }));
                        }
                        StopLoad(this, null);
                    });
                }
                else if (changePrice != 0 && null != model && null != model.Supplier && model.IsChange)
                {
                    string supplierName = "";
                    string balanceName  = "";


                    if (Resources.GetRes().MainLangIndex == 0)
                    {
                        supplierName = model.Supplier.SupplierName0;
                    }
                    else if (Resources.GetRes().MainLangIndex == 1)
                    {
                        supplierName = model.Supplier.SupplierName1;
                    }
                    else if (Resources.GetRes().MainLangIndex == 2)
                    {
                        supplierName = model.Supplier.SupplierName2;
                    }


                    if (Resources.GetRes().MainLangIndex == 0)
                    {
                        balanceName = CurrentBalance.Balance.BalanceName0;
                    }
                    else if (Resources.GetRes().MainLangIndex == 1)
                    {
                        balanceName = CurrentBalance.Balance.BalanceName1;
                    }
                    else if (Resources.GetRes().MainLangIndex == 2)
                    {
                        balanceName = CurrentBalance.Balance.BalanceName2;
                    }



                    var confirm = KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("ConfirmAddPay"), Resources.GetRes().PrintInfo.PriceSymbol, ChangePrice, balanceName, supplierName), Resources.GetRes().GetString("Warn"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (confirm != DialogResult.Yes)
                    {
                        return;
                    }


                    SupplierPay supplierpay = new SupplierPay();


                    supplierpay.Price      = changePrice;
                    supplierpay.BalanceId  = CurrentBalance.Balance.BalanceId;
                    supplierpay.SupplierId = model.Supplier.SupplierId;


                    // 开始支付
                    StartLoad(this, null);

                    Task.Factory.StartNew(() =>
                    {
                        ResultModel result          = new ResultModel();
                        double originalBalancePrice = model.Supplier.BalancePrice;
                        try
                        {
                            // 更新供应者信息
                            model.Supplier.BalancePrice = model.Supplier.BalancePrice + supplierpay.Price;

                            Supplier newSupplier;
                            SupplierPay newSupplierPay;
                            result = OperatesService.GetOperates().ServiceAddSupplierPay(model.Supplier, supplierpay, out newSupplier, out newSupplierPay);
                            this.BeginInvoke(new Action(() =>
                            {
                                if (result.Result)
                                {
                                    KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);



                                    // 去掉当前最后一个供应者并重新添加
                                    btnMemberRemove_Click(null, null);
                                    AddMember(null, newSupplier);
                                }
                                else
                                {
                                    if (result.IsDataHasRefrence)
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUsed"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else if (result.UpdateModel)
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }
                            }));
                        }
                        catch (Exception ex)
                        {
                            this.BeginInvoke(new Action(() =>
                            {
                                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                                {
                                    // 失败了就复原供应者信息
                                    if (result.Result)
                                    {
                                        model.Supplier.BalancePrice = originalBalancePrice;
                                    }

                                    KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }), false, Resources.GetRes().GetString("SaveFailt"));
                            }));
                        }
                        StopLoad(this, null);
                    });
                }
            }
        }