// 系统单据只能改类型 public bool UpdateShippingBillEntry2(ShippingBillEntryModel entryModel) { string sql = @" update SJShippingBillEntry set GoodsType=@GoodsType,Note=@Note where Id=@Id"; using (var connection = SqlDb.UpdateConnection) { return(connection.Execute(sql, entryModel) > 0); } }
public bool AddShipingBillEntry2(ShippingBillEntryModel entryModel) { string sql = @" insert into SJShippingBillEntry(MainId,CaseName,Quantity,BrandName,DeptName,CustName,DeptId,CustId,BrandId,CaseId,EntryId,Amount,GoodsType,Note,IsSystem,SystemQuantity) select @MainId,@CaseName,@Quantity,@BrandName,@DeptName,@CustName,@DeptId,@CustId,@BrandId,@CaseId,@EntryId,@Amount,@GoodsType,@Note,@IsSystem,0; update SJShippingBill set TotalQuantity = isnull(TotalQuantity, 0) + @Quantity,TotalAmount = isnull(TotalAmount, 0) + @Amount where Id = @MainId;"; using (var connection = SqlDb.UpdateConnection) { return(connection.Execute(sql, entryModel) > 0); } }
public bool DeleteShippingBillEntry(ShippingBillEntryModel entryModel) { string sql = @" delete from SJShippingBillEntry where Id=@Id; update SJShippingBill set TotalQuantity = isnull(TotalQuantity, 0) - @Quantity , TotalAmount = isnull(TotalAmount, 0) - @Amount , SystemApportionedQuantity = isnull(SystemApportionedQuantity, 0) - @Quantity where Id = @MainId ;"; using (var connection = SqlDb.UpdateConnection) { return(connection.Execute(sql, entryModel) > 0); } }
public bool UpdateShipingBillEntry(ShippingBillEntryModel model) { string sql = @" update SJShippingBillEntry set CaseName=@CaseName,BrandName=@BrandName,DeptName=@DeptName,CustName=@CustName,Quantity=@Quantity,Amount=@Amount,GoodsType=@GoodsType,Note=@Note where Id=@Id; "; using (var connection = SqlDb.UpdateConnection) { //DynamicParameters dp = new DynamicParameters(); //dp.Add("@Id", model.Id, DbType.Int32, ParameterDirection.Input); //dp.Add("@CaseName", model.CaseName, DbType.String, ParameterDirection.Input); //dp.Add("@BrandName", model.BrandName, DbType.String, ParameterDirection.Input); //dp.Add("@DeptName", model.DeptName, DbType.String, ParameterDirection.Input); //dp.Add("@CustName", model.CustName, DbType.String, ParameterDirection.Input); //dp.Add("@Quantity", model.Quantity, DbType.Single, ParameterDirection.Input); //dp.Add("@Amount", model.Amount, DbType.Single, ParameterDirection.Input); //dp.Add("@GoodsType", model.GoodsType, DbType.Int32, ParameterDirection.Input); //dp.Add("@Note", model.Note, DbType.String, ParameterDirection.Input); //dp.Add("@SystemApportionedQuantity", systemApportionedQuantity, DbType.Single, ParameterDirection.Input); //dp.Add("@SystemApportionedAmount", systemApportionedAmount, DbType.Single, ParameterDirection.Input); return(connection.Execute(sql, model) > 0); } }
// 非系统单据可以修改数量金额 public bool UpdateShippingBillEntry3(ShippingBillEntryModel entryModel, float qtyDiff, float amountDiff) { //string sql = @" update SJShippingBillEntry set EntryId=@EntryId,GoodsType=@GoodsType,Quantity=@Quantity where Id=@Id; // update t set TotalQuantity=s,ApportionedAmount=Quantity/s * TotalAmount // from ( select *, sum(Quantity)over() s from SJShippingBillEntry where MainId=@MainId) as t; update SJShippingBill set TotalQuantity=TotalQuantity+diff where id=@MainId;"; string sql = @" update SJShippingBillEntry set Quantity=@Quantity,Amount=@Amount,Note=@Note where Id=@Id; "; switch (entryModel.GoodsType) { case 2: sql += " update SJShippingBill set TotalQuantity = isnull(TotalQuantity, 0) + @QtyDiff, TotalAmount = isnull(TotalAmount, 0) + @AmountDiff,HaoCaiFei= isnull(HaoCaiFei,0) + @AmountDiff where Id = @MainId "; break; //case 3: sql += " update SJShippingBill set TotalQuantity = isnull(TotalQuantity, 0) + @QtyDiff, TotalAmount = isnull(TotalAmount, 0) + @AmountDiff,YangYouFei= isnull(YangYouFei,0) + @AmountDiff where Id = @MainId "; break; case 4: sql += " update SJShippingBill set TotalQuantity = isnull(TotalQuantity, 0) + @QtyDiff, TotalAmount = isnull(TotalAmount, 0) + @AmountDiff,SheBeiFei= isnull(SheBeiFei,0) + @AmountDiff where Id = @MainId "; break; case 5: sql += " update SJShippingBill set TotalQuantity = isnull(TotalQuantity, 0) + @QtyDiff, TotalAmount = isnull(TotalAmount, 0) + @AmountDiff,HaoCaiFei= isnull(HaoCaiFei,0) + @AmountDiff where Id = @MainId "; break; case 6: sql += " update SJShippingBill set TotalQuantity = isnull(TotalQuantity, 0) + @QtyDiff, TotalAmount = isnull(TotalAmount, 0) + @AmountDiff,TuiYuanCaiLiaoFei= isnull(TuiYuanCaiLiaoFei,0) + @AmountDiff where Id = @MainId "; break; default: break; } DynamicParameters dp = new DynamicParameters(); dp.Add("@Id", entryModel.Id, DbType.Int32, ParameterDirection.Input); dp.Add("@MainId", entryModel.MainId, DbType.Int32, ParameterDirection.Input); dp.Add("@GoodsType", entryModel.GoodsType, DbType.Int32, ParameterDirection.Input); dp.Add("@Quantity", entryModel.Quantity, DbType.Single, ParameterDirection.Input); dp.Add("@Amount", entryModel.Amount, DbType.Single, ParameterDirection.Input); dp.Add("@AmountDiff", amountDiff, DbType.Single, ParameterDirection.Input); dp.Add("@QtyDiff", qtyDiff, DbType.Single, ParameterDirection.Input); dp.Add("@Note", entryModel.Note, DbType.String, ParameterDirection.Input); using (var connection = SqlDb.UpdateConnection) { return(connection.Execute(sql, dp) > 0); } }
private void AddShippingBillEntry(object obj) { if (SelectedShippingBill == null) { MessageBox.Show("请先选择主表行记录,再新增明细"); return; } ShippingBillEntryModel entry; ShippingBillEntryAddView view = new ShippingBillEntryAddView(); var copyEntry = ShippingBillEntries.LastOrDefault(); if (copyEntry == null) { entry = new ShippingBillEntryModel { MainId = SelectedShippingBill.Id, EntryId = 1, IsSystem = false, Amount = 0 } } ; else { entry = new ShippingBillEntryModel { MainId = copyEntry.MainId, EntryId = copyEntry.EntryId + 1, IsSystem = false } }; (view.DataContext as ShippingBillEntryAddViewModel).WithParam(entry, (type, shippingBillEntry) => { view.Close(); if (type == 1) { SelectedShippingBill.TotalQuantity += shippingBillEntry.Quantity; SelectedShippingBill.TotalAmount += shippingBillEntry.Amount; // 新增条目,修改后台分摊金额 if (shippingBillEntry.GoodsType == 1 || shippingBillEntry.GoodsType == 3) { SelectedShippingBill.SystemApportionedAmount += shippingBillEntry.Amount; SelectedShippingBill.SystemApportionedQuantity += shippingBillEntry.Quantity; _shippingService.AddShipingBillEntry(shippingBillEntry); //添加明细 _shippingService.UpdateShipingBillEntry(SelectedShippingBill); //分摊金额 } else { SelectedShippingBill.UnApportionedAmount += shippingBillEntry.Amount; _shippingService.AddShipingBillEntry2(shippingBillEntry); } // 更新主表 _shippingService.UpdateShipingBill2(SelectedShippingBill); // 重新加载明细 GetAllShippingBillEntriesById(shippingBillEntry.MainId); } }); view.ShowDialog(); }
public ConsignmentShippingViewModel() { _shippingService = new ShippingBillService(); _consignmentService = new ConsignmentBillService(); _commonService = new CommonService(); userDataId = _commonService.GetUserDataId(user, 7); ConsignmentBills = new ObservableCollection <ConsignmentBillModel>(); SelectedConsignmentBillLists = new ObservableCollection <ConsignmentBillModel>(); ConsignmentBillEntries = new ObservableCollection <ConsignmentBillEntryModel>(); ShippingBills = new ObservableCollection <ShippingBillModel>(); ShippingBillEntries = new ObservableCollection <ShippingBillEntryModel>(); SelectedShippingBillEntry = new ShippingBillEntryModel(); Filter = new ConsignmentBillParameterModel() { ParamRestQuatity = 0, ParamBeginDate = Convert.ToDateTime(System.DateTime.Now.AddDays(-7).ToShortDateString()), ParamEndDate = Convert.ToDateTime(System.DateTime.Now.ToShortDateString()), ParamBillType = 1 }; HostConfig = _commonService.GetHostConfig(4, _hostName, user.ID) ?? new HostConfigModel() { TypeId = 4, Host = _hostName, UserId = user.ID, TypeDesciption = "物流托运单" }; BillTypes = _commonService.GetEnumLists(5).ToList(); DataInit(); //GetShippingBills(); //InitQueryConSignmentBill(); InitCommand(); #region 命令属性 QueryCommand = new DelegateCommand(QuerySignmentBill); #region 销售出库、调拨单主表 ConsignmentBillSelectedAllCommand = new DelegateCommand(SelectedAllConsignmentBill); ConsignmentBillUnSelectedAllCommand = new DelegateCommand(UnSelectedAllConsignmentBill); ConsignmentBillSelectionChangedCommand = new DelegateCommand(ChangeSelectedConsignmentBill); ConsignmentBillRemoveCommand = new DelegateCommand(RemoveConsignmentBill); ConsignmentBillSyncCommand = new DelegateCommand(SyncConsignmentBill); ConsignmentBillSelectedListsClearCommand = new DelegateCommand(ClearSelectedConsignmentBillLists); ConsignmentBillSelectedListsAddCommand = new DelegateCommand(AddConsignmentBill); ConsignmentBillMergeCommand = new DelegateCommand(MergeConsignmentBill); #endregion #region 销售出库、调拨单子表 ConsignmentBillEntryCopyCommand = new DelegateCommand(CopyConsignmentBillEntry); ConsignmentBillEntryDeleteCommand = new DelegateCommand(DeleteConsignmentBillEntry); ConsignmentBillEntrySelectionChangedCommand = new DelegateCommand(ChangeSelectedConsignmentBillEntry); ConsignmentBillEntryCheckBoxCommand = new DelegateCommand(ClickCheckBoxConsignmentBillEntry); ConsignmentBillEntryModifyCommand = new DelegateCommand(ModifyConsignmentBillEntry); #endregion #region 托运单主表 ShippingBillSelectionChangedCommand = new DelegateCommand(ShippingBillSelectionChanged); ShippingBillModifyCommand = new DelegateCommand(ModifyShippingBill); ShippingBillDeleteCommand = new DelegateCommand(DeleteShippingBill); //ShippingBillExportCommand = new DelegateCommand(ExportShippingData); ShippingBillDetailLogShowCommand = new DelegateCommand(ShowShippingBillDetailLog); ShippingBillCreateCommand = new DelegateCommand(CreateShippingBill); #endregion #region 托运单子表 ShippingBillEntryAddCommand = new DelegateCommand(AddShippingBillEntry); ShippingBillEntryDeleteCommand = new DelegateCommand(DeleteShippingBillEntry); ShippingBillEntryUpdateCommand = new DelegateCommand(UpdateShippingBillEntry); ShippingBillEntrySelectionChangedCommand = new DelegateCommand(ShippingBillEntrySelectionChanged); #endregion #endregion }
public void WithParam(ShippingBillEntryModel entry, Action <int, ShippingBillEntryModel> callBack) { ShippingBillEntry = entry; _callBack = callBack; }