private void RemoveEmployee_Click(object sender, RoutedEventArgs e) { if (gridEmployee.SelectedItems.Count == 0) { SystemSounds.Beep.Play(); MessageBox.Show("请选择想要取消分配的员工!"); return; } foreach (Employee employee in gridEmployee.SelectedItems) { Value v = gridTask.SelectedItem as Value; Relationship r = gridProcedure.SelectedItem as Relationship; Procedure p = Db.QueryProcedureByName(r.InputProcedure).Single(); ValuePrice vp = gridPrice.SelectedItem as ValuePrice; foreach (Employee eTmp in gridEmployee.SelectedItems) { try { Db.DeleteAssignByValueIdAndProcedureIdAndEmployeeId(v.Id, p.Id, eTmp.Id); } catch { SystemSounds.Beep.Play(); MessageBox.Show("取消分配失败!"); FillEmployee(); return; } } } FillEmployee(); }
private void FillListBox_Months() { List <Value> valueList = new List <Value>(); List <Assign> assginList = Db.QueryAssignByEmployeeId(LoginedEmployee.Id).ToList(); foreach (Assign a in assginList) { ValuePrice price = Db.QueryValuePriceById(a.Price_Id).Single(); valueList.Add(Db.QueryValueById(price.Value_Id).Single()); } if (valueList.Count == 0) { return; } DateTime beginTime = valueList.ElementAt(0).TaskDate; DateTime endTime = valueList.ElementAt(0).TaskDate; foreach (Value v in valueList) { if (v.TaskDate < beginTime) { beginTime = v.TaskDate; } endTime = v.TaskDate; } int months = (endTime.Year - beginTime.Year) * 12 + (endTime.Month - beginTime.Month); for (int i = 0; i < months + 1; i++) { lst_Months.Items.Add(beginTime.AddMonths(i).ToString("yyyy/MM")); } }
public IEnumerable <Assign> QueryAssignByValuePrice(ValuePrice v) { using (IDbConnection conn = OpenConnection()) { return(conn.Query <Assign>("select * from tbl_Assign where Price_Id=@Price_Id", new { Price_Id = v.Id })); } }
public ModifyPriceWindow(ProductionScheduling_Page psPage, ValuePrice selectedPrice) { InitializeComponent(); PsPage = psPage; OriginPrice = selectedPrice; Db = new DataAccessLayer(); RestoreOriginPrice(); }
public AssignEmployeeWindow(ProductionScheduling_Page psPage, ValuePrice selectedPrice) { PsPage = psPage; SelectedPrice = selectedPrice; Db = new DataAccessLayer(); InitializeComponent(); BindingComboBoxSource(); }
public int UpdatePrice(ValuePrice price) { using (IDbConnection conn = OpenConnection()) { return(conn.Execute("update tbl_Value_Price set Unit=@Unit, Unit_Price=@Unit_Price where Id=@Id", new { Unit = price.Unit, Unit_Price = price.Unit_Price, Id = price.Id })); } }
public int InsertValuePrice(ValuePrice p) { //Id INT AUTO_INCREMENT PRIMARY KEY, //Unit CHAR(20), //Unit_Price FLOAT, //Value_Id INT, //CONSTRAINT fk_Value_Id FOREIGN KEY (Value_Id) // REFERENCES tbl_Value (Id) //Procedure_Id INT, //CONSTRAINT fk_ProcedureId FOREIGN KEY (Procedure_Id) // REFERENCES tbl_Procedure (Id) using (IDbConnection conn = OpenConnection()) { return(conn.Execute("Insert into tbl_Value_Price values " + "(@Id, @Unit, @Unit_Price, @Value_Id, @Procedure_Id)", new { Id = p.Id, Unit = p.Unit, Unit_Price = p.Unit_Price, Value_Id = p.Value_Id, Procedure_Id = p.Procedure_Id })); } }
private void FillListView() { string dateString = lst_Months.SelectedItem as string; dateString += "/01"; DateTime pickedDate = new DateTime(); try { pickedDate = DateTime.Parse(dateString); } catch { MessageBox.Show("Wrong date :" + dateString); return; } List <Value> valueList = new List <Value>(); List <Assign> assginList = Db.QueryAssignByEmployeeId(LoginedEmployee.Id).ToList(); List <wage> wageList = new List <wage>(); foreach (Assign a in assginList) { ValuePrice p = Db.QueryValuePriceById(a.Price_Id).Single(); Value v = Db.QueryValueById(p.Value_Id).Single(); if (v.TaskDate > pickedDate && v.TaskDate < pickedDate.AddMonths(1)) { wage w = new wage(); w.Count = Db.QueryReckonByAssignId(a.Id).Single().Count; w.Date = v.TaskDate; w.Price = p.Unit_Price; w.Procedure = Db.QueryProcedureById(p.Procedure_Id).Single().Name; w.Product = Db.QueryProductById(v.Product_Id).Single().Name; w.Unit = p.Unit; w.Value = v.Name; w.Wage = w.Price * w.Count; wageList.Add(w); } } lv_Task.ItemsSource = wageList; CalculateMonthWage(wageList); }
private void btn_Modify_Click(object sender, RoutedEventArgs e) { ValuePrice modifiedPrice = new ValuePrice(); try { modifiedPrice.Unit_Price = double.Parse(txt_Price.Text); } catch { SystemSounds.Beep.Play(); MessageBox.Show("工序单价必须为数字!"); return; } modifiedPrice.Id = OriginPrice.Id; modifiedPrice.Procedure_Id = OriginPrice.Procedure_Id; modifiedPrice.Value_Id = OriginPrice.Value_Id; modifiedPrice.Unit = txt_Unit.Text; Db.UpdatePrice(modifiedPrice); PsPage.FillPrice(); this.Close(); }
private void btn_AddTask_Click(object sender, RoutedEventArgs e) { Value v = new Value(); if (cmb_Product.SelectedIndex == -1) { SystemSounds.Beep.Play(); MessageBox.Show("产品编号不能为空!"); return; } else { v.Product_Id = (cmb_Product.SelectedItem as Product).Id; v.Product_Name = (cmb_Product.SelectedItem as Product).Name; } try { if (string.IsNullOrWhiteSpace(txt_TaskNum.Text) == true) { SystemSounds.Beep.Play(); MessageBox.Show("任务编号不能为空!"); return; } else { v.TaskNum = int.Parse(txt_TaskNum.Text); } } catch (FormatException fe) { txt_TaskNum.Text = string.Empty; SystemSounds.Beep.Play(); MessageBox.Show("任务编号必须为数字!"); return; } //if (Db.QueryValueByName(txt_Value.Text).Count() == 0) // QueryValueByNameNotInProduct if (Db.QueryValueByNameAndProductId(txt_Value.Text, v.Product_Id).Count() == 0) { v.Name = txt_Value.Text; } else { SystemSounds.Beep.Play(); MessageBox.Show("该产品已存在感值:" + txt_Value.Text); txt_Value.Text = string.Empty; return; } v.TaskDate = DateTime.Now; Db.InsertValue(v); IEnumerable <Relationship> relateList = Db.QueryRelationshipByProduct_Id(v.Product_Id); foreach (Relationship item in relateList) { ValuePrice price = new ValuePrice(); price.Procedure_Id = Db.QueryProcedureByName(item.InputProcedure).Single().Id; price.Value_Id = Db.QueryValueByTaskNum(v.TaskNum).Single().Id; Db.InsertValuePrice(price); } PsPage.FillGridTask(); this.Close(); }