private void Button_Commit_Click(object sender, RoutedEventArgs e) { if (CheckAndGetData()) { if (!isNew) { if (!new ViewModel.Customer.CustomerConsole().Update(d)) { MessageBox.Show("编号或名称重复", "错误"); return; } StatusBarMessageEvent.OnUpdateMessage("修改用户:" + d.Name); } else { if (!new ViewModel.Customer.CustomerConsole().Add(d)) { MessageBox.Show("编号或名称重复", "错误"); return; } StatusBarMessageEvent.OnUpdateMessage("添加用户:" + d.Name); } Button_Cancel_Click(null, null); } else { MessageBox.Show("请检查输入是否有误。", "错误"); } }
private void Button_Commit_Click(object sender, RoutedEventArgs e) { if (CheckAndGetData()) { if (isNew) { if (!new ViewModel.MeansOfProduction.RawMaterialsConsole().Add(d)) { MessageBox.Show("编号或名称重复", "错误"); return; } StatusBarMessageEvent.OnUpdateMessage("添加原材料:" + d.Name); } else { if (!new ViewModel.MeansOfProduction.RawMaterialsConsole().Update(d)) { MessageBox.Show("编号或名称重复", "错误"); return; } StatusBarMessageEvent.OnUpdateMessage("修改原材料:" + d.Name); } Button_Cancel_Click(null, null); } else { MessageBox.Show("请检查输入是否有误。", "错误"); } }
private void Button_Commit_Click(object sender, RoutedEventArgs e) { string typeMsg = RadioButton_添加.IsChecked == true ? "添加" : "卖出"; if (CheckAndGetData()) { sc.Add(m); RefreshData_Scrap(); StatusBarMessageEvent.OnUpdateMessage(typeMsg + "余料名称:" + m.Name); } }
private void Button_Commit_Click(object sender, RoutedEventArgs e) { if (CheckAndGetData()) { if (isNew) { new ViewModel.Orders.ProductOrderConsole().Add(d); StatusBarMessageEvent.OnUpdateMessage("新增订单:" + d.OrderNumber); } else { new ViewModel.Orders.ProductOrderConsole().Update(d); StatusBarMessageEvent.OnUpdateMessage("修改订单:" + d.OrderNumber); } ProductOrderEvent.OnUpdateDataGrid(); Button_Cancel_Click(null, null); } else { } }
private bool CheckAndGetData() { DateTime dt = new DateTime(); DateTime.TryParse(DatePicker_Date.Text, out dt); TimeSpan ts = DateTime.Now - dt; int day = ts.Days; if (day > 1000) { StatusBarMessageEvent.OnUpdateMessage("日期不能为空!"); DatePicker_Date.Text = DateTime.Now.ToShortDateString(); return(false); } if (ComboBox_Name.SelectedIndex == 0) { StatusBarMessageEvent.OnUpdateMessage("请选择余料类型!"); ComboBox_Name.Focus(); return(false); } if (RadioButton_添加.IsChecked == false) { decimal dTmp = 0; decimal.TryParse(TextBox_Number.Text, out dTmp); if (dTmp > sc.GetAmountByName(ComboBox_Name.Text)) { StatusBarMessageEvent.OnUpdateMessage("卖出数量/重量大于库存值!"); return(false); } } m.Guid = Guid.NewGuid(); m.Name = ComboBox_Name.Text; m.Number = RadioButton_添加.IsChecked == true ? TextBox_Number.Text : "-" + TextBox_Number.Text; m.Remark = TextBox_Remark.Text; m.Date = DateTime.Parse(DatePicker_Date.Text).ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("T"); m.Operator = TextBox_Operator.Text; return(true); }