private void DeleteConsignmentBillEntry(object obj) { if (SelectedConsignmentBill == null) { return; } if (SelectedConsignmentBillEntry == null || SelectedConsignmentBillEntry.IsSystem) { MessageBox.Show("只能删除手动添加的数据"); return; } string ownerName = _consignmentService.GetConsignmentBillLockOwner(SelectedConsignmentBill.BillNo, SelectedConsignmentBill.UserId); if (string.IsNullOrEmpty(ownerName)) { // 修改主表界面和后台 SelectedConsignmentBill.CurrencyQuantity -= SelectedConsignmentBillEntry.ECurrencyQuantity; SelectedConsignmentBill.UndoQuantity -= SelectedConsignmentBillEntry.ECurrencyQuantity; SelectedConsignmentBill.TotalQuantity -= SelectedConsignmentBillEntry.ECurrencyQuantity; _consignmentService.UpdateConsignmentBill(SelectedConsignmentBill); // 删除字表数据 int id = SelectedConsignmentBillEntry.Id; ConsignmentBillEntries.Remove(SelectedConsignmentBillEntry); _consignmentService.DeleteConsignmentBillEntry(id); } else { MessageBox.Show($"该记录正在被【{ownerName}】使用,请选择其他数据"); } }
private void ChangeSelectedConsignmentBill(object obj) { if (obj != null) { SelectedConsignmentBill = (ConsignmentBillModel)obj; ConsignmentBillEntries.Clear(); _consignmentService.GetAllConsignmentBillEntryById(SelectedConsignmentBill.InterId).ToList().ForEach(x => ConsignmentBillEntries.Add(x)); } }
private void ClearSelectedConsignmentBillLists(object obj) { if (SelectedConsignmentBillLists.Count() > 0) { string ids = "'" + string.Join("','", SelectedConsignmentBillLists.Select(x => x.BillNo)) + "'"; SelectedConsignmentBillLists.Clear(); SelectedConsignmentSum = 0; ConsignmentBillEntries.Clear(); _consignmentService.ClearSelectedConsignmentBills(ids); QuerySignmentBill(null); } }
private void CopyConsignmentBillEntry(object obj) { if (SelectedConsignmentBill == null) { return; } string ownerName = _consignmentService.GetConsignmentBillLockOwner(SelectedConsignmentBill.BillNo, SelectedConsignmentBill.UserId); if (string.IsNullOrEmpty(ownerName)) { if (SelectedConsignmentBillEntry == null) { return; } ConsignmentBillEntryCopyView add = new ConsignmentBillEntryCopyView(); var cloneData = TransExpV2 <ConsignmentBillEntryModel, ConsignmentBillEntryModel> .Trans(SelectedConsignmentBillEntry); cloneData.IsChecked = true; cloneData.EntryId = ConsignmentBillEntries.Max(m => m.EntryId) + 1; cloneData.IsSystem = false; cloneData.ECurrencyQuantity = 0; (add.DataContext as ConsignmentBillEntryCopyViewModel).WithParam(cloneData, (type, entry) => { add.Close(); if (type == 1) { // 修改字表界面和后台 int id = _consignmentService.AddConsignmentBillEntry(entry, user.ID); entry.ETotalQuantity = entry.ECurrencyQuantity; entry.EUndoQuantity = entry.ECurrencyQuantity; entry.Id = id; ConsignmentBillEntries.Add(entry); // 修改主表界面和后台 SelectedConsignmentBill.CurrencyQuantity += entry.ECurrencyQuantity; SelectedConsignmentBill.UndoQuantity += entry.ECurrencyQuantity; SelectedConsignmentBill.TotalQuantity += entry.ECurrencyQuantity; _consignmentService.UpdateConsignmentBill(SelectedConsignmentBill); } }); add.ShowDialog(); } else { MessageBox.Show($"该记录正在被【{ownerName}】使用,请选择其他数据"); } }
private void QuerySignmentBill(object obj) { ConsignmentBills.Clear(); //var para = Filter;//(ConsignmentBillParameterModel)obj; List <string> filters = new List <string>(); if (Filter.ParamBillBeginSeq > 0 && Filter.ParamBillEndSeq > 0) { filters.Add($" and BillSeq between {Filter.ParamBillBeginSeq} and {Filter.ParamBillEndSeq} "); } else if (Filter.ParamBillBeginSeq > 0) { filters.Add($" and a.BillNo like '%{Filter.ParamBillBeginSeq}%' "); } //if (!string.IsNullOrEmpty(para.ParamBillNo)) //{ // filters.Add($" and a.BillNo like '%{para.ParamBillNo}%' "); //} if (!string.IsNullOrEmpty(Filter.ParamDeptName)) { string deptName = Filter.ParamDeptName.Replace(",", ","); if (deptName.Contains(",")) { string orfield = string.Empty; foreach (var item in deptName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { orfield += $"or DeptName like '%{item}%' "; } orfield = orfield.Length > 2 ? orfield.Substring(2) : " 1 = 1 "; filters.Add($" and ( {orfield} )"); } else { filters.Add($" and DeptName like '%{deptName}%' "); } } if (!string.IsNullOrEmpty(Filter.ParamCustName)) { string custName = Filter.ParamCustName.Replace(",", ","); if (custName.Contains(",")) { string orfield = string.Empty; foreach (var item in custName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { orfield += $"or CustName like '%{item}%' "; } orfield = orfield.Length > 2 ? orfield.Substring(2) : " 1 = 1 "; filters.Add($" and ( {orfield} )"); } else { filters.Add($" and CustName like '%{custName}%' "); } } if (Filter.IsSelected) { filters.Add($" and SelectedStatus > 0 "); } string filter = $" and BillDate >= '{Filter.ParamBeginDate}' and BillDate <= '{Filter.ParamEndDate}' and BillType={Filter.ParamBillType} and UndoQuantity>{Filter.ParamRestQuatity} " + string.Join(" ", filters); _consignmentService.GetAllConsignmentBills(user.ID, filter).ToList().ForEach(x => { ConsignmentBills.Add(x); }); ConsignmentBillsCount = ConsignmentBills.Count(); ConsignmentBillsSumQuantity = ConsignmentBills.Sum(m => m.CurrencyQuantity); SelectedConsignmentBillEntry = null; SelectedConsignmentBill = null; ConsignmentBillEntries.Clear(); }