private void btn_Modify_Click(object sender, RoutedEventArgs e) { Relationship alteredRelationship = new Relationship(); //if(tb_Input.Text == (cmb_Output.SelectedItem as Procedure).Name) //{ // SystemSounds.Beep.Play(); // MessageBox.Show("前置工序与后置工序不能相同!"); // return; //} try { alteredRelationship.Input_Output_Ratio = int.Parse(txt_Ratio.Text); } catch { SystemSounds.Beep.Play(); MessageBox.Show("投入产出比必须为数字!"); return; } alteredRelationship.InputProcedure = OriginRelationship.InputProcedure; alteredRelationship.OutputProcedure = (cmb_Output.SelectedItem as Procedure).Name; alteredRelationship.Product_Id = OriginRelationship.Product_Id; Db.UpdateRelationship(alteredRelationship); PmPage.FillGridView_Relationship(); this.Close(); }
private void btn_ModifyProcedure_Click(object sender, RoutedEventArgs e) { Procedure alteredProcedure = new Procedure(); if (txt_ProcedureId.Text != OriginProcedure.Id.ToString()) { if (Db.QueryProcedureById(int.Parse(txt_ProcedureId.Text)).Count() > 0) { SystemSounds.Beep.Play(); MessageBox.Show("已存在工序编号:" + txt_ProcedureId.Text); return; } } if (txt_ProcedureName.Text != OriginProcedure.Name) { if (Db.QueryProcedureByName(txt_ProcedureName.Text).Count() > 0) { SystemSounds.Beep.Play(); MessageBox.Show("已存在工序名称:" + txt_ProcedureName.Text); return; } } alteredProcedure.Name = txt_ProcedureName.Text; try { alteredProcedure.Id = int.Parse(txt_ProcedureId.Text); } catch { SystemSounds.Beep.Play(); MessageBox.Show("工序编号必须为数字!"); return; } alteredProcedure.Product_Id = (cmb_Product.SelectedItem as Product).Id; try { Db.DeleteProcedureById(OriginProcedure.Id); } catch { SystemSounds.Beep.Play(); MessageBox.Show("更改失败!"); return; } Db.InsertProcedure(alteredProcedure); PmPage.FillGridView_Procedure(); this.Close(); }
private void btn_ModifyValue_Click(object sender, RoutedEventArgs e) { Value alteredValue = new Value(); if (txt_ValueName.Text != OriginValue.Name) { if (Db.QueryValueByName(txt_ValueName.Text).Count() > 0) { SystemSounds.Beep.Play(); MessageBox.Show("Already exists Value with name:" + txt_ValueName.Text); return; } } if (String.IsNullOrEmpty(txt_ValueName.Text.Trim()) == true || String.IsNullOrEmpty(txt_ValueUnit.Text.Trim()) == true || String.IsNullOrEmpty(txt_ValueUnitPrice.Text.Trim()) == true) { SystemSounds.Beep.Play(); MessageBox.Show("There must no be blank in any textbox."); return; } double price = 0; try { price = double.Parse(txt_ValueUnitPrice.Text); } catch (FormatException except) { SystemSounds.Beep.Play(); MessageBox.Show("You must only input numberic in Price!"); return; } alteredValue.Name = txt_ValueName.Text; alteredValue.Unit = txt_ValueUnit.Text; alteredValue.Unit_Price = price; alteredValue.Procedure_Id = (cmb_Procedure.SelectedItem as Procedure).Id; Db.DeleteValueByName(OriginValue.Name); Db.InsertValue(alteredValue); PmPage.FillGridView_Value(); this.Close(); }