private void ShowAssigns() { ItemsGrid.Rows.Clear(); if (UpdatingItem == null) { return; } List <CustomerPaymentAssign> assigns = (new CustomerPaymentBLL(AppSettings.Current.ConnStr)).GetAssigns((UpdatingItem as CustomerPayment).ID).QueryObjects; if (assigns != null && assigns.Count > 0) { CustomerReceivableSearchCondition con = new CustomerReceivableSearchCondition(); con.ReceivableIDS = assigns.Select(it => it.ReceivableID).ToList(); List <CustomerReceivable> crs = (new CustomerReceivableBLL(AppSettings.Current.ConnStr)).GetItems(con).QueryObjects; if (crs != null && crs.Count > 0) { foreach (CustomerPaymentAssign assign in assigns) { CustomerReceivable cr = crs.FirstOrDefault(it => it.ID == assign.ReceivableID); int row = ItemsGrid.Rows.Add(); ItemsGrid.Rows[row].Tag = assign; ItemsGrid.Rows[row].Cells["colSheetID"].Value = cr.SheetID; ItemsGrid.Rows[row].Cells["colClassID"].Value = CustomerReceivableTypeDescription.GetDescription(cr.ClassID); ItemsGrid.Rows[row].Cells["colAssign"].Value = assign.Amount.Trim(); } } int rowTotal = ItemsGrid.Rows.Add(); ItemsGrid.Rows[rowTotal].Cells["colSheetID"].Value = "合计"; ItemsGrid.Rows[rowTotal].Cells["colAssign"].Value = assigns.Sum(item => item.Amount).Trim(); } }
protected override void ShowItemInGridViewRow(DataGridViewRow row, object item) { CustomerOtherReceivable info = item as CustomerOtherReceivable; row.Cells["colID"].Value = info.ID; row.Cells["colSheetDate"].Value = info.SheetDate.ToString("yyyy-MM-dd"); CompanyInfo customer = customerTree1.GetCustomer(info.CustomerID); row.Cells["colCustomer"].Value = customer != null ? customer.Name : info.CustomerID; row.Cells["colCurrencyType"].Value = info.CurrencyType; row.Cells["colAmount"].Value = info.Amount.Trim(); CustomerReceivable cr = _Receivables.SingleOrDefault(it => it.SheetID == info.ID); if (cr != null) { row.Cells["colPaid"].Value = cr.Haspaid.Trim(); row.Cells["colNotPaid"].Value = cr.Remain.Trim(); } row.Cells["colState"].Value = SheetStateDescription.GetDescription(info.State); row.Cells["colMemo"].Value = info.Memo; if (info.State == SheetState.Canceled) { row.DefaultCellStyle.ForeColor = Color.Red; row.DefaultCellStyle.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Strikeout, System.Drawing.GraphicsUnit.Point, ((byte)(134))); } if (!_Sheets.Exists(it => it.ID == info.ID)) { _Sheets.Add(info); } }
protected override void ShowItemInGridViewRow(DataGridViewRow row, object item) { CustomerReceivable cr = item as CustomerReceivable; row.Tag = cr; row.Cells["colSheetID"].Value = cr.SheetID; row.Cells["colOrderID"].Value = cr.OrderID; row.Cells["colCreateDate"].Value = cr.CreateDate.ToString("yyyy-MM-dd"); row.Cells["colClassID"].Value = CustomerReceivableTypeDescription.GetDescription(cr.ClassID); row.Cells["colAmount"].Value = cr.Amount.Trim(); if (cr.Haspaid != 0) { row.Cells["colHaspaid"].Value = cr.Haspaid.Trim(); } if (cr.Remain != 0) { row.Cells["colNotpaid"].Value = cr.Remain.Trim(); int days = DaysBetween(DateTime.Today, cr.CreateDate); row.Cells["colHowold"].Value = days >= 0 ? string.Format("{0}天", days) : string.Empty; } if (cr.Amount < 0) { row.DefaultCellStyle.ForeColor = Color.Red; } }
/// <summary> /// 取消客户收款和应收款已核销项 /// </summary> /// <param name="assign"></param> /// <returns></returns> public CommandResult UndoAssign(CustomerPaymentAssign assign) { if (assign == null) { return(new CommandResult(ResultCode.Fail, "没有分配项")); } IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri); CustomerPayment cp = ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).GetByID(assign.PaymentID).QueryObject; if (cp != null && cp.Assigned >= assign.Amount) { CustomerReceivable cr = ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).GetByID(assign.ReceivableID).QueryObject; if (cr != null && cr.Haspaid >= assign.Amount) { CustomerPayment cp1 = cp.Clone() as CustomerPayment; CustomerReceivable cr1 = cr.Clone() as CustomerReceivable; cp.Assigned -= assign.Amount; cr.Haspaid -= assign.Amount; ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).Update(cp, cp1, unitWork); ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Update(cr, cr1, unitWork); ProviderFactory.Create <IProvider <CustomerPaymentAssign, Guid> >(RepoUri).Delete(assign, unitWork); } } return(unitWork.Commit()); }
private void ShowItemInGridViewRow(DataGridViewRow row, CustomerReceivable cr) { row.Tag = cr; row.Cells["colSheetID"].Value = cr.SheetID; row.Cells["colOrderID"].Value = cr.OrderID; row.Cells["colCreateDate"].Value = cr.CreateDate.ToString("yyyy-MM-dd"); row.Cells["colClassID"].Value = CustomerReceivableTypeDescription.GetDescription(cr.ClassID); row.Cells["colRemain"].Value = cr.Remain; row.Cells["colAssign"].Value = 0; row.Cells["colMemo"].Value = cr.Memo; }
protected override void DoApprove(CustomerOtherReceivable info, IUnitWork unitWork, DateTime dt, string opt) { CustomerReceivable cr = new CustomerReceivable() { ID = Guid.NewGuid(), ClassID = CustomerReceivableType.CustomerOtherReceivable, SheetID = info.ID, CustomerID = info.CustomerID, CreateDate = dt, Amount = info.Amount, Haspaid = 0, Memo = info.Memo }; ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Insert(cr, unitWork); base.DoApprove(info, unitWork, dt, opt); }
public CommandResult Add(CompanyInfo info, decimal prepayment, decimal receivables) { if (string.IsNullOrEmpty(info.ID)) { info.ID = CreateCustomerID(info.ClassID); } if (!string.IsNullOrEmpty(info.ID)) { IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri); ProviderFactory.Create <IProvider <CompanyInfo, string> >(RepoUri).Insert(info, unitWork); if (receivables > 0) //增加一条客户应收项 { CustomerReceivable cr = new CustomerReceivable() { ID = Guid.NewGuid(), OrderID = info.ID + "初始应收", CreateDate = DateTime.Now, CustomerID = info.ID, Amount = receivables, Memo = "初始应收", }; ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Insert(cr, unitWork); } if (prepayment > 0) { CustomerPayment cp = new CustomerPayment() { ID = info.ID + "初始预付款", CustomerID = info.ID, PaymentMode = PaymentMode.Cash, LastActiveDate = DateTime.Now, Amount = prepayment, State = SheetState.Add, Memo = "初始预付款" }; ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).Insert(cp, unitWork); } return(unitWork.Commit()); } else { return(new CommandResult(ResultCode.Fail, "创建客户编号失败,请重试")); } }
private void AddReceivables(StackOutSheet sheet, IUnitWork unitWork) { List <CustomerReceivable> crs = new List <CustomerReceivable>(); foreach (StackOutItem si in sheet.Items) //每一个送货项生成一个应收项,因为一个送货单可能包括多个订单的货,所以分别统计 { CustomerReceivable cr = null; if (string.IsNullOrEmpty(si.OrderID)) { cr = crs.SingleOrDefault(it => string.IsNullOrEmpty(it.OrderID)); } if (!string.IsNullOrEmpty(si.OrderID)) { cr = crs.SingleOrDefault(it => it.OrderID == si.OrderID); } if (cr == null) { DateTime dt = DateTime.Now; cr = new CustomerReceivable() { ID = Guid.NewGuid(), CreateDate = dt, ClassID = CustomerReceivableType.CustomerReceivable, CustomerID = sheet.CustomerID, SheetID = sheet.ID, OrderID = si.OrderID, Amount = si.Amount, }; crs.Add(cr); } else { cr.Amount += si.Amount; } } foreach (CustomerReceivable cr in crs) { ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Insert(cr, unitWork); } }
protected override void DoNullify(CustomerOtherReceivable info, IUnitWork unitWork, DateTime dt, string opt) { CustomerReceivableSearchCondition con = new CustomerReceivableSearchCondition(); con.SheetID = info.ID; List <CustomerReceivable> items = new CustomerReceivableBLL(RepoUri).GetItems(con).QueryObjects; if (items != null && items.Count > 0) { CustomerReceivable cr = items.FirstOrDefault(it => it.ClassID == CustomerReceivableType.CustomerOtherReceivable); if (cr != null) { CustomerPaymentAssignSearchCondition con1 = new CustomerPaymentAssignSearchCondition(); con1.ReceivableIDs = new List <Guid>(); con1.ReceivableIDs.Add(cr.ID); List <CustomerPaymentAssign> assigns = (new CustomerPaymentAssignBLL(RepoUri)).GetItems(con1).QueryObjects; if (assigns != null && assigns.Count > 0) { bool allSuccess = true; foreach (CustomerPaymentAssign assign in assigns) { CommandResult ret = (new CustomerPaymentAssignBLL(AppSettings.Current.ConnStr)).UndoAssign(assign); if (ret.Result != ResultCode.Successful) { allSuccess = false; } } if (!allSuccess) { throw new Exception("某些应收核销项删除失败,请手动删除这些应收核销项后再继续\"作废\"的操作"); } } ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Delete(cr, unitWork); //删除应收 } } base.DoNullify(info, unitWork, dt, opt); }