private void GouzaoRecord_Load(object sender, EventArgs e) { dynamic tag = this.Tag; if (tag.type == "Edit") { string path = ((dynamic)Program.MainForm.Tag).path; Gouzao gouzao = new Gouzao(); XmlSerializer xs = new XmlSerializer(gouzao.GetType()); TextReader tw = new StreamReader($@"{path}\project\{tag.id}.tf"); gouzao = (Gouzao)xs.Deserialize(tw); tw.Close(); //1 _tab1List = gouzao.T1Value; _waistList = gouzao.T3Values.waists; _Bims = gouzao.T2Value; //3 b_start.Text = gouzao.T3Values.StartB.ToString(); b_end.Text = gouzao.T3Values.EndB.ToString(); hw_start.Text = gouzao.T3Values.StartHW.ToString(); hw_end.Text = gouzao.T3Values.EndHW.ToString(); //4 combo_ran.Text = gouzao.T4Values.Angle; box_linenum.Text = gouzao.T4Values.Num.ToString(); comboBox8.Text = gouzao.T4Values.Type; comboBox9.Text = gouzao.T4Values.Diam; LoadTab1View(); LoadTab2View(); PushEditWaist(); return; } CreateTab1View(); }
private void button1_Click(object sender, EventArgs e) { //确认按钮 //GRecord record = new GRecord(); //record.name = box_Name.Text; //JsonParam JPram = new JsonParam(); T4Values t4 = new T4Values(); T3Values t3 = new T3Values(); //保存表格信息 Gouzao gouzao = new Gouzao(); dynamic tag = Program.MainForm.Tag; dynamic edit = this.Tag; if (edit.type != "Edit") { gouzao.TName = Guid.NewGuid().ToString(); } else { gouzao.TName = edit.id; } gouzao.T1Value = _tab1List; gouzao.T2Value = _Bims; if (b_start.Text != "") { t3.StartB = int.Parse(b_start.Text); } if (b_end.Text != "") { t3.EndB = int.Parse(b_end.Text); } if (hw_start.Text != "") { t3.StartHW = int.Parse(hw_start.Text); } if (hw_end.Text != "") { t3.EndHW = int.Parse(hw_end.Text); } t3.waists = _waistList; t4.Angle = combo_ran.Text; t4.Num = int.Parse(box_linenum.Text); t4.Type = comboBox8.Text; t4.Diam = comboBox9.Text; gouzao.T4Values = t4; gouzao.T3Values = t3; XmlSerializer xs = new XmlSerializer(gouzao.GetType()); TextWriter tw = new StreamWriter($@"{tag.path}\project\{gouzao.TName}.tf"); xs.Serialize(tw, gouzao); tw.Close(); transf(new { id = gouzao.TName, name = box_Name.Text }); this.Close(); //catch { MessageBox.Show("保存失败!"); } }