void Button1Click(object sender, System.EventArgs e) { if (TestuiSave()) { bool isSave = false; if (tu.Id != 0) { isSave = SqlDBUtil.update(tu); } else { tu.Id = SqlDBUtil.insertReturnID(tu); isSave = true; } if (isSave) { //创建文档 if (unitDOCpath == null) { unitDOCpath = this.defaultpath; } this.richTextBox1.SaveFile(temppath + @"\" + tu.Unitno + ".doc"); CreateTestUnit(defaultpath + @"\temp\TestUnit.doc", temppath + @"\" + tu.Unitno + ".doc", unitDOCpath + @"\" + tu.Unitno + ".doc"); // //创建HTML // if(unitHTMLpath!=null) // { // var fullHtmlPath =unitHTMLpath+@"\"+tu.Unitno+".html"; // WordDocumentMerger.WordToHtmlFile(unitDOCpath+@"\"+tu.Unitno+".doc",fullHtmlPath); // } //勾选自动发送 if (this.checkBox1.Checked) { SendMessageToManager("", true); } MessageBox.Show("保存成功!"); } else { MessageBox.Show("保存失败!"); } } }
//保存按钮 void Button4Click(object sender, System.EventArgs e) { if (UICheckInfoSave()) { string msgstr = "保存成功!"; //更新 if (uiinfo.Id != null && uiinfo.Id != 0) { uiinfo.Checkerid = Int32.Parse(GlobalParams.UserId); uiinfo.Checkername = GlobalParams.Username; SqlDBUtil.update(uiinfo); msgstr = "更新成功!"; } //插入 else { uiinfo.Id = SqlDBUtil.insertReturnID(uiinfo); SendMessageToManager(); } if (_isedit) //是否编辑图片 { //判断是否有当前未保存的编辑操作,如果有,则给操作数组赋值。 if (this.pictureBox1.OperateManager != null) { OperateList[this.curImageno - 1] = this.pictureBox1.OperateManager; } //将当前的文字说明保存给对象。因为有可能编辑过。 Checkviewlist[this.curImageno - 1].Checkmark = this.textBox1.Text; } //循环保存图片信息 for (int i = 0; i < Checkviewlist.Count; i++) { //设置图片编号为循环顺序 Checkviewlist[i].Imageno = i.ToString(); UICheckView uc = Checkviewlist[i]; //保存图片到对象中 MemoryStream ms = null; if (uc.Checkedimage != null) { ms = new MemoryStream(Checkviewlist[i].Checkedimage); } else { ms = new MemoryStream(Checkviewlist[i].Srcimage); } //先将基础图片赋值到控件 this.pictureBox1.Image = Image.FromStream(ms); //判断有无编辑操作 if (OperateList != null && OperateList[i] != null) { this.pictureBox1.OperateManager = OperateList[i]; } else { this.pictureBox1.OperateManager = null; } //从控件中抓取编辑过的图片,保存到对象中 MemoryStream ms1 = new MemoryStream(); this.pictureBox1.GetImg().Save(ms1, ImageFormat.Jpeg); Byte[] bytBLOBData = new Byte[ms1.Length]; ms1.Position = 0; ms1.Read(bytBLOBData, 0, Convert.ToInt32(ms1.Length)); uc.Checkedimage = bytBLOBData; uc.Checkmark = Checkviewlist[i].Checkmark; if (uc.Id != null && uc.Id != 0) { SqlDBUtil.update(uc); } else { Checkviewlist[i].Id = SqlDBUtil.insertReturnID(uc); } } //还原到当前的图片上 MemoryStream ms2 = null; if (Checkviewlist[this.curImageno - 1].Checkedimage != null) { ms2 = new MemoryStream(Checkviewlist[this.curImageno - 1].Checkedimage); } else { ms2 = new MemoryStream(Checkviewlist[this.curImageno - 1].Srcimage); } this.pictureBox1.Image = Image.FromStream(ms2); if (OperateList != null && OperateList[this.curImageno - 1] != null) { this.pictureBox1.OperateManager = OperateList[this.curImageno - 1]; } else { this.pictureBox1.OperateManager = null; } MessageBox.Show(msgstr, "提示"); } }