public void Load() { // 重新加载扩展日期 CustomerSchedulingDate = Service.GetContinuousDate(OrganizationSearchedItem.Id, SettleDate); // CustomerSchedulingDate = new CustomerSchedulingDateModel() { Date3 = DateTime.Now }; // 重新加载交期数据 //CustomerSchedulingDetailLists.Clear(); //Service.GetCustomerSchedulingDetailLists(OrganizationSearchedItem.Id, SettleDate, CustomerSchedulingSummarySelectedItem?.Label ?? "").ForEach(x => CustomerSchedulingDetailLists.Add(x)); // 重新加载主表格数据 CustomerSchedulingSummaryLists.Clear(); OrgLabelLists.Clear(); Service.GetCustomerSchedulingSummaryLists(OrganizationSearchedItem.Id, SettleDate).ForEach(x => { CustomerSchedulingSummaryLists.Add(x); if (SelectedIndex == -1) { OrgLabelLists.Add(new CustomerSchedulingOrgLabelModel { FItemId = x.FItemId, Label = x.Label, OrgCode = x.OrgCode, OrgId = x.OrgId, ProductionName = x.ProductionName, Value1 = null, Value2 = null, Value3 = null, Value4 = null, Value5 = null }); } }); //SelectedIndex = sd; }
private void InitCommand() { QueryCommand = new DelegateCommand((obj) => { CustomerSchedulingDetailLists.Clear(); Service.GetCustomerSchedulingDetailLists(Organization.Id, DateTime.Now.Date, Label).ForEach(x => CustomerSchedulingDetailLists.Add(x)); }); DataGridSaveCommand = new DelegateCommand((obj) => { var data = OrgLabelLists.Where(x => x.Value1 > 0 || x.Value2 > 0 || x.Value3 > 0 || x.Value4 > 0 || x.Value5 > 0); if (data.Count() > 0) { StringBuilder stringBuilder = new StringBuilder(); foreach (var item in data) { if (item.Value1 > 0) { stringBuilder.Append($",({item.OrgId},'{item.OrgCode}',{item.FItemId},'{item.Label}','{CustomerSchedulingDate.Date1}',{item.Value1},0)"); } if (item.Value2 > 0) { stringBuilder.Append($",({item.OrgId},'{item.OrgCode}',{item.FItemId},'{item.Label}','{CustomerSchedulingDate.Date2}',{item.Value2},0)"); } if (item.Value3 > 0) { stringBuilder.Append($",({item.OrgId},'{item.OrgCode}',{item.FItemId},'{item.Label}','{CustomerSchedulingDate.Date3}',{item.Value3},0)"); } if (item.Value4 > 0) { stringBuilder.Append($",({item.OrgId},'{item.OrgCode}',{item.FItemId},'{item.Label}','{CustomerSchedulingDate.Date4}',{item.Value4},0)"); } if (item.Value5 > 0) { stringBuilder.Append($",({item.OrgId},'{item.OrgCode}',{item.FItemId},'{item.Label}','{CustomerSchedulingDate.Date5}',{item.Value5},0)"); } } string sql = " insert into SJCustomerSchedulingDetail(OrgId,OrgCode,FItemId,Label,DeliveryDate,DeliveryQty,SEOutStockEntryUId)values" + stringBuilder.ToString().Substring(1); if (Service.BatchInsert(sql)) { IsChanged = true; } } else { MessageBox.Show("没有填写正确的数据"); } }); SelectionChangedCommand = new DelegateCommand((obj) => { if (OrgLabelSelectedItem != null) { CustomerSchedulingDetailSelectedItem = null; foreach (var item in CustomerSchedulingDetailLists) { if (item.Label == OrgLabelSelectedItem.Label && item.FItemId == OrgLabelSelectedItem.FItemId) { item.IsChangeBG = true; } else { item.IsChangeBG = false; } } } }); ModifyCommand = new DelegateCommand((obj) => { if (CustomerSchedulingDetailSelectedItem != null) { CustomerSchedulingDetailCreateView view = new CustomerSchedulingDetailCreateView(); var cloneData = ObjectDeepCopyHelper <CustomerSchedulingDetailModel, CustomerSchedulingDetailModel> .Trans(CustomerSchedulingDetailSelectedItem); (view.DataContext as CustomerSchedulingDetailCreateViewModel).WithParam(cloneData, (type, outputEntity) => { view.Close(); if (type == 1) { if (Service.CustomerSchedulingDetailUpdate(outputEntity)) { CustomerSchedulingDetailSelectedItem.DeliveryDate = outputEntity.DeliveryDate; CustomerSchedulingDetailSelectedItem.DeliveryQty = outputEntity.DeliveryQty; IsChanged = true; } } }); view.ShowDialog(); } else { MessageBox.Show("先选择交期数据行"); } }); DeleteCommand = new DelegateCommand((obj) => { if (CustomerSchedulingDetailSelectedItem != null) { if (MessageBox.Show($"确认删除数据 \n\r\t 客户:【 {Organization.SearchText} 】 \n\r\t 标签:【{CustomerSchedulingDetailSelectedItem.Label}】 \n\r\t 交货日期:【{CustomerSchedulingDetailSelectedItem.DeliveryDate:yyyy-MM-dd}】 \n\r\t 数量:【{CustomerSchedulingDetailSelectedItem.DeliveryQty}】", "温馨提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (Service.CustomerSchedulingDetailDelete(CustomerSchedulingDetailSelectedItem)) { CustomerSchedulingDetailLists.Remove(CustomerSchedulingDetailSelectedItem); IsChanged = true; } } } else { MessageBox.Show("先选择交期数据行"); } }); }
private void InitData(ComboBoxSearchModel org, ObservableCollection <CustomerSchedulingOrgLabelModel> orgLabelList) { Organization = org; CustomerSchedulingDate = new CustomerSchedulingDateModel { Date1 = DateTime.Now.AddDays(1).Date, Date2 = DateTime.Now.AddDays(2).Date, Date3 = DateTime.Now.AddDays(3).Date, Date4 = DateTime.Now.AddDays(4).Date, Date5 = DateTime.Now.AddDays(5).Date }; Service.GetCustomerSchedulingDetailLists(Organization.Id, DateTime.Now.Date, Label).ForEach(x => CustomerSchedulingDetailLists.Add(x)); Task.Factory.StartNew(() => { UIExecute.RunAsync(() => { if (orgLabelList.Count == 0) { Service.GetCustomerSchedulingSummaryLists(org.Id, DateTime.Now.Date).ForEach(x => OrgLabelLists.Add(new CustomerSchedulingOrgLabelModel { FItemId = x.FItemId, Label = x.Label, OrgCode = x.OrgCode, OrgId = x.OrgId, ProductionName = x.ProductionName })); } else { OrgLabelLists = orgLabelList; } }); }); }
public CustomerSchedulingManagementViewModel(ComboBoxSearchModel org, ObservableCollection <CustomerSchedulingOrgLabelModel> orgLabelList) { InitCommand(); //InitData(org,orgLabelList); Organization = org; CustomerSchedulingDate = new CustomerSchedulingDateModel { Date1 = DateTime.Now.AddDays(1).Date, Date2 = DateTime.Now.AddDays(2).Date, Date3 = DateTime.Now.AddDays(3).Date, Date4 = DateTime.Now.AddDays(4).Date, Date5 = DateTime.Now.AddDays(5).Date }; Service.GetCustomerSchedulingDetailLists(Organization.Id, DateTime.Now.Date, Label).ForEach(x => CustomerSchedulingDetailLists.Add(x)); if (orgLabelList.Count == 0) { Service.GetCustomerSchedulingSummaryLists(org.Id, DateTime.Now.Date).ForEach(x => OrgLabelLists.Add(new CustomerSchedulingOrgLabelModel { FItemId = x.FItemId, Label = x.Label, OrgCode = x.OrgCode, OrgId = x.OrgId, ProductionName = x.ProductionName })); } else { OrgLabelLists = orgLabelList; } }