public bool updateTran(VAN_OA.Model.EFrom.tb_QuotePrice model, List <tb_QuotePrice_InvDetails> invsDetails, string invDetails_IDS) { using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; tb_QuotePrice_InvsService InvSer = new tb_QuotePrice_InvsService(); tb_QuotePrice_InvDetailsService InvDetailSer = new tb_QuotePrice_InvDetailsService(); try { objCommand.Parameters.Clear(); if (model.IsYH) { model.Total = model.LastYH; } else { model.Total = invsDetails.Sum(t => t.Total) + model.LaborCost + model.EngineeringTax; } Update(model, objCommand); #region 报价内容 for (int i = 0; i < invsDetails.Count; i++) { invsDetails[i].QuoteId = model.Id; if (invsDetails[i].IfUpdate == true && invsDetails[i].Id != 0) { InvDetailSer.Update(invsDetails[i], objCommand); } else if (invsDetails[i].Id == 0) { InvDetailSer.Add(invsDetails[i], objCommand); } } if (invDetails_IDS != "") { invDetails_IDS = invDetails_IDS.Substring(0, invDetails_IDS.Length - 1); InvDetailSer.DeleteByIds(invDetails_IDS, objCommand); } #endregion tan.Commit(); } catch (Exception ex) { tan.Rollback(); return(false); } } return(true); }
public int addTran(VAN_OA.Model.EFrom.tb_QuotePrice model, List <tb_QuotePrice_InvDetails> invsDetails) { int id = 0; int MainId = 0; using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; try { objCommand.Parameters.Clear(); if (model.IsYH) { model.Total = model.LastYH; } else { model.Total = invsDetails.Sum(t => t.Total) + model.LaborCost + model.EngineeringTax; } id = Add(model, objCommand); MainId = id; tb_QuotePrice_InvDetailsService InvDetailSer = new tb_QuotePrice_InvDetailsService(); for (int i = 0; i < invsDetails.Count; i++) { invsDetails[i].QuoteId = id; InvDetailSer.Add(invsDetails[i], objCommand); } tan.Commit(); } catch (Exception) { tan.Rollback(); return(0); } return(id); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VAN_OA.Model.EFrom.tb_QuotePrice GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append("IsShuiYin,IsGaiZhang,IsRemark,LastYH,IsYH,LIlv,LaborCost,EngineeringTax,QPType,IsBrand,IsProduct, Remark,ZLBZ,YSBJ,FWBXDJ,JFQ,Total,loginName,tb_QuotePrice.Id,QuoteNo,GuestName,GuestNo,QuoteDate,ResultGuestName,ResultGuestNo,PayStyle,GuestNameToInv,ContactPerToInv,telToInv,AddressToInv,InvoHeader,InvContactPer,InvAddress,InvTel,NaShuiPer,brandNo,GuestNameTofa,ContactPerTofa,telTofa,AddressTofa,BuessName,BuessEmail,ComTel,ComChuanZhen,ComBusTel,ComName,NaShuiNo,Address,ComBrand,CreateUser,CreateTime "); strSql.Append(" from tb_QuotePrice left join tb_User on tb_User.id=tb_QuotePrice.CreateUser"); strSql.Append(" where tb_QuotePrice.Id=" + id + ""); VAN_OA.Model.EFrom.tb_QuotePrice model = null; using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn); using (SqlDataReader dataReader = objCommand.ExecuteReader()) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } } return(model); }
private void PrintPDF(int PDFId) { string modelWordUrl = System.Web.HttpContext.Current.Request.MapPath("WordModel/") + "QP.doc"; if (!File.Exists(modelWordUrl)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('模版不存在!');</script>"); return; } string wordUrl = System.Web.HttpContext.Current.Request.MapPath("PDFConverter/"); string guidUrl = wordUrl + Guid.NewGuid() + ".doc"; File.Copy(modelWordUrl, guidUrl); Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application(); object oMissing = System.Reflection.Missing.Value; //打开模板文档,并指定doc的文档类型 object objTemplate = guidUrl; //路径一定要正确 object objDocType = WdDocumentType.wdTypeDocument; object objfalse = false; object objtrue = true; object miss = System.Reflection.Missing.Value; object missingValue = Type.Missing; object doNotSaveChanges = WdSaveOptions.wdDoNotSaveChanges; Microsoft.Office.Interop.Word.Document doc = null; try { doc = (Document)appWord.Documents.Add(ref objTemplate, ref objfalse, ref objDocType, ref objtrue); //获取模板中所有的书签 Bookmarks odf = doc.Bookmarks; tb_QuotePriceService QuotePriSer = new tb_QuotePriceService(); VAN_OA.Model.EFrom.tb_QuotePrice model = QuotePriSer.GetModel(PDFId); Dictionary <string, string> bookMarks = new Dictionary <string, string>(); bookMarks.Add("GuestName", model.GuestName); bookMarks.Add("GuestNo", model.GuestNo); bookMarks.Add("PayStyle", model.PayStyle); bookMarks.Add("QuoteDate", model.QuoteDate.ToShortDateString()); bookMarks.Add("QuoteNo", model.QuoteNo); bookMarks.Add("QuoteNo1", model.QuoteNo); bookMarks.Add("ResultGuestName", model.ResultGuestName); bookMarks.Add("ResultGuestNo", model.ResultGuestNo); bookMarks.Add("Address", model.Address); bookMarks.Add("AddressTofa", model.AddressTofa); bookMarks.Add("AddressToInv", model.AddressToInv); bookMarks.Add("brandNo", model.brandNo); bookMarks.Add("BuessEmail", model.BuessEmail); bookMarks.Add("BuessName", model.BuessName); bookMarks.Add("ComBrand", model.ComBrand); bookMarks.Add("ComChuanZhen", model.ComChuanZhen); bookMarks.Add("ComName", model.ComName); bookMarks.Add("ComTel", model.ComTel); bookMarks.Add("ContactPerTofa", model.ContactPerTofa); bookMarks.Add("ContactPerToInv", model.ContactPerToInv); bookMarks.Add("GuestNameTofa", model.GuestNameTofa); bookMarks.Add("GuestNameToInv", model.GuestNameToInv); bookMarks.Add("InvAddress", model.InvAddress); bookMarks.Add("InvContactPer", model.InvContactPer); bookMarks.Add("InvoHeader", model.InvoHeader); bookMarks.Add("InvTel", model.InvTel); bookMarks.Add("NaShuiNo", model.NaShuiNo); bookMarks.Add("NaShuiPer", model.NaShuiPer); bookMarks.Add("telTofa", model.telTofa); bookMarks.Add("telToInv", model.telToInv); foreach (var key in bookMarks.Keys) { object objKey = key; doc.Bookmarks.get_Item(ref objKey).Range.Text = bookMarks[key]; } doc.SaveAs(ref objTemplate, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); doc.Close(ref doNotSaveChanges, ref missingValue, ref missingValue); appWord.Application.Quit(ref miss, ref miss, ref miss); doc = null; appWord = null; lblMess.Text = "文件生成成功"; } catch { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('文件不存在!');</script>"); doc.Close(ref doNotSaveChanges, ref missingValue, ref missingValue); appWord.Application.Quit(ref miss, ref miss, ref miss); return; } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (this.FormCheck()) { try { string QuoteNo = this.lblQuoteNo.Text; string GuestName = this.txtGuestName.Text; string GuestNo = this.lblGuestNo.Text; DateTime QuoteDate = DateTime.Now; string ResultGuestName = this.txtResultGuestName.Text; string ResultGuestNo = this.txtResultGuestNo.Text; string PayStyle = this.txtPayStyle.Text; string GuestNameToInv = this.txtGuestNameToInv.Text; string ContactPerToInv = this.txtContactPerToInv.Text; string telToInv = this.lbltelToInv.Text; string AddressToInv = this.txtAddressToInv.Text; string InvoHeader = this.txtInvoHeader.Text; string InvContactPer = this.txtInvContactPer.Text; string InvAddress = this.txtInvAddress.Text; string InvTel = this.txtInvTel.Text; string NaShuiPer = this.lblNaShuiPer.Text; string brandNo = this.lblbrandNo.Text; string AddressTofa = this.txtAddressTofa.Text; string BuessName = this.txtBuessName.Text; string BuessEmail = this.txtBuessEmail.Text; string ComTel = this.txtComTel.Text; string ComChuanZhen = this.txtComChuanZhen.Text; string ComBusTel = this.txtComBusTel.Text; string ComName = this.txtComName.Text; string NaShuiNo = this.txtNaShuiNo.Text; string ComBrand = this.txtComBrand.Text; VAN_OA.Model.EFrom.tb_QuotePrice model = new VAN_OA.Model.EFrom.tb_QuotePrice(); model.QuoteNo = QuoteNo; model.GuestName = GuestName; model.GuestNo = GuestNo; model.QuoteDate = QuoteDate; model.ResultGuestName = ResultGuestName; model.ResultGuestNo = ResultGuestNo; model.PayStyle = PayStyle; model.GuestNameToInv = GuestNameToInv; model.ContactPerToInv = ContactPerToInv; model.telToInv = telToInv; model.AddressToInv = AddressToInv; model.InvoHeader = InvoHeader; model.InvContactPer = InvContactPer; model.InvAddress = InvAddress; model.InvTel = InvTel; model.NaShuiPer = NaShuiPer; model.brandNo = brandNo; model.AddressTofa = AddressTofa; model.BuessName = BuessName; model.BuessEmail = BuessEmail; model.ComTel = ComTel; model.ComChuanZhen = ComChuanZhen; model.ComBusTel = ComBusTel; model.ComName = ComName; model.NaShuiNo = NaShuiNo; model.ComBrand = ComBrand; model.Address = lblZhanghao.Text; model.ZLBZ = txtZLBZ.Text; model.YSBJ = txtYSBJ.Text; model.FWBXDJ = txtFWBXDJ.Text; model.JFQ = txtJFQ.Text; model.Remark = txtRemark.Text; model.Id = Convert.ToInt32(base.Request["Id"]); model.IsYH = cbYH.Checked; if (cbYH.Checked) { model.LastYH = Convert.ToDecimal(txtResultYH.Text); } if (rbtnType3.Checked) { model.LaborCost = Convert.ToDecimal(txtLaborCost.Text); model.EngineeringTax = Convert.ToDecimal(txtEngineeringTax.Text); model.LIlv = Convert.ToDecimal(txtXX.Text); model.QPType = 3; } if (rbtnType2.Checked) { model.QPType = 2; } if (rbtnType1.Checked) { model.QPType = 1; } model.IsBrand = cbIsBrand.Checked; model.IsProduct = cbIsProduct.Checked; model.IsRemark = cbRemark.Checked; model.IsGaiZhang = cbIsGaiZhang.Checked; model.IsShuiYin = cbIsShuiYin.Checked; List <tb_QuotePrice_InvDetails> invDetails = Session["DataInvDetails"] as List <tb_QuotePrice_InvDetails>; string InvDetailsIds = ""; if (ViewState["InvDetailsIds"] != null) { InvDetailsIds = ViewState["InvDetailsIds"].ToString(); } VAN_OA.Dal.ReportForms.TB_GuestTrackService guestTrackSer = new VAN_OA.Dal.ReportForms.TB_GuestTrackService(); List <VAN_OA.Model.ReportForms.TB_GuestTrack> guestTrackLists = guestTrackSer.GetGuestListToQuery(string.Format(" and GuestId='{0}'", lblGuestNo.Text)); if (guestTrackLists.Count > 0) { TB_GuestTrack guest = guestTrackLists[0]; //|| txtAE.Text != model.AEName || txtINSIDE.Text != model.INSIDEName if (txtGuestName.Text != guest.GuestName) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('客户信息不存在请重新填写!');</script>"); return; } if (guest.AEName != txtBuessName.Text) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('AE必须和申请人一样!');</script>"); return; } model.GuestId = guest.Id; } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('客户信息不存在请重新填写!');</script>"); return; } if (this.QuotePriSer.updateTran(model, invDetails, InvDetailsIds)) { string url = System.Web.HttpContext.Current.Request.MapPath("PDFConverter/") + lblQuoteNo.Text + ".pdf"; url = url.Replace(@"EFrom\", @"ReportForms\"); if (System.IO.File.Exists(url)) { try { System.IO.File.Delete(url); } catch (Exception) { } } url = System.Web.HttpContext.Current.Request.MapPath("PDFConverter/") + lblQuoteNo.Text + ".doc"; url = url.Replace(@"EFrom\", @"ReportForms\"); if (System.IO.File.Exists(url)) { try { System.IO.File.Delete(url); } catch (Exception) { } } url = System.Web.HttpContext.Current.Request.MapPath("PDFConverter/") + lblQuoteNo.Text + "-word.rar"; url = url.Replace(@"EFrom\", @"ReportForms\"); if (System.IO.File.Exists(url)) { try { System.IO.File.Delete(url); } catch (Exception) { } } url = System.Web.HttpContext.Current.Request.MapPath("PDFConverter/") + lblQuoteNo.Text + "-pdf.rar"; url = url.Replace(@"EFrom\", @"ReportForms\"); if (System.IO.File.Exists(url)) { try { System.IO.File.Delete(url); } catch (Exception) { } } base.Response.Redirect(Session["POUrl"].ToString() + "?QuoteNo=" + model.QuoteNo); } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('修改失败!');</script>"); } } catch (Exception ex) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + ex.Message + "!');</script>"); } } }
protected void btnAdd_Click(object sender, EventArgs e) { if (this.FormCheck()) { try { string QuoteNo = this.lblQuoteNo.Text; string GuestName = txtGuestName.Text; string GuestNo = this.lblGuestNo.Text; DateTime QuoteDate = DateTime.Now; string ResultGuestName = this.txtResultGuestName.Text; string ResultGuestNo = this.txtResultGuestNo.Text; string PayStyle = this.txtPayStyle.Text; string GuestNameToInv = this.txtGuestNameToInv.Text; string ContactPerToInv = this.txtContactPerToInv.Text; string telToInv = this.lbltelToInv.Text; string AddressToInv = this.txtAddressToInv.Text; string InvoHeader = this.txtInvoHeader.Text; string InvContactPer = this.txtInvContactPer.Text; string InvAddress = this.txtInvAddress.Text; string InvTel = this.txtInvTel.Text; string NaShuiPer = this.lblNaShuiPer.Text; string brandNo = this.lblbrandNo.Text; string AddressTofa = this.txtAddressTofa.Text; string BuessName = this.txtBuessName.Text; string BuessEmail = this.txtBuessEmail.Text; string ComTel = this.txtComTel.Text; string ComChuanZhen = this.txtComChuanZhen.Text; string ComBusTel = this.txtComBusTel.Text; string ComName = this.txtComName.Text; string NaShuiNo = this.txtNaShuiNo.Text; string ComBrand = this.txtComBrand.Text; VAN_OA.Model.EFrom.tb_QuotePrice model = new VAN_OA.Model.EFrom.tb_QuotePrice(); model.QuoteNo = QuoteNo; model.GuestName = GuestName; model.GuestNo = GuestNo; model.QuoteDate = QuoteDate; model.ResultGuestName = ResultGuestName; model.ResultGuestNo = ResultGuestNo; model.PayStyle = PayStyle; model.GuestNameToInv = GuestNameToInv; model.ContactPerToInv = ContactPerToInv; model.telToInv = telToInv; model.AddressToInv = AddressToInv; model.InvoHeader = InvoHeader; model.InvContactPer = InvContactPer; model.InvAddress = InvAddress; model.InvTel = InvTel; model.NaShuiPer = NaShuiPer; model.brandNo = brandNo; model.AddressTofa = AddressTofa; model.BuessName = BuessName; model.BuessEmail = BuessEmail; model.ComTel = ComTel; model.ComChuanZhen = ComChuanZhen; model.ComBusTel = ComBusTel; model.ComName = ComName; model.NaShuiNo = NaShuiNo; model.ComBrand = ComBrand; model.CreateTime = DateTime.Now; model.CreateUser = Convert.ToInt32(Session["currentUserId"]); model.ComBrand = ComBrand; model.Address = lblZhanghao.Text; model.ZLBZ = txtZLBZ.Text; model.YSBJ = txtYSBJ.Text; model.FWBXDJ = txtFWBXDJ.Text; model.JFQ = txtJFQ.Text; model.Remark = txtRemark.Text; model.IsYH = cbYH.Checked; if (cbYH.Checked) { model.LastYH = Convert.ToDecimal(txtResultYH.Text); } List <tb_QuotePrice_InvDetails> invDetails = Session["DataInvDetails"] as List <tb_QuotePrice_InvDetails>; if (rbtnType3.Checked) { model.LaborCost = Convert.ToDecimal(txtLaborCost.Text); model.EngineeringTax = Convert.ToDecimal(txtEngineeringTax.Text); model.LIlv = Convert.ToDecimal(txtXX.Text); model.QPType = 3; //YY=设备材料价格+人工费 txtRenGJS.Text = (invDetails.Sum(t => t.Total) + Convert.ToDecimal(txtLaborCost.Text)).ToString(); } if (rbtnType2.Checked) { model.QPType = 2; } if (rbtnType1.Checked) { model.QPType = 1; } model.IsBrand = cbIsBrand.Checked; model.IsProduct = cbIsProduct.Checked; model.IsRemark = cbRemark.Checked; model.IsGaiZhang = cbIsGaiZhang.Checked; model.IsShuiYin = cbIsShuiYin.Checked; VAN_OA.Dal.ReportForms.TB_GuestTrackService guestTrackSer = new VAN_OA.Dal.ReportForms.TB_GuestTrackService(); List <VAN_OA.Model.ReportForms.TB_GuestTrack> guestTrackLists = guestTrackSer.GetGuestListToQuery(string.Format(" and GuestId='{0}'", lblGuestNo.Text)); if (guestTrackLists.Count > 0) { TB_GuestTrack guest = guestTrackLists[0]; //|| txtAE.Text != model.AEName || txtINSIDE.Text != model.INSIDEName if (txtGuestName.Text != guest.GuestName) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('客户信息不存在请重新填写!');</script>"); return; } if (guest.AEName != txtBuessName.Text) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('AE必须和申请人一样!');</script>"); return; } model.GuestId = guest.Id; } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('客户信息不存在请重新填写!');</script>"); return; } if (this.QuotePriSer.addTran(model, invDetails) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加成功!');</script>"); base.Response.Redirect(Session["POUrl"].ToString() + "?QuoteNo=" + model.QuoteNo); } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加失败!');</script>"); } } catch (Exception ex) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + ex.Message + "!');</script>"); } } }
private void ShowInfo(int Id) { VAN_OA.Model.EFrom.tb_QuotePrice model = QuotePriSer.GetModel(Id); lblNo.Text = model.QuoteNo; this.lblQuoteNo.Text = model.QuoteNo; this.txtGuestName.Text = model.GuestName; this.lblGuestNo.Text = model.GuestNo; this.lblQuoteDate.Text = model.QuoteDate.ToString("yyyy-MM-dd HH:mm:ss"); this.txtResultGuestName.Text = model.ResultGuestName; this.txtResultGuestNo.Text = model.ResultGuestNo; this.txtPayStyle.Text = model.PayStyle; this.txtGuestNameToInv.Text = model.GuestNameToInv; this.txtContactPerToInv.Text = model.ContactPerToInv; this.lbltelToInv.Text = model.telToInv; this.txtAddressToInv.Text = model.AddressToInv; this.txtInvoHeader.Text = model.InvoHeader; this.txtInvContactPer.Text = model.InvContactPer; this.txtInvAddress.Text = model.InvAddress; this.txtInvTel.Text = model.InvTel; this.lblNaShuiPer.Text = model.NaShuiPer; this.lblbrandNo.Text = model.brandNo; this.txtAddressTofa.Text = model.AddressTofa; this.txtBuessName.Text = model.BuessName; this.txtBuessEmail.Text = model.BuessEmail; this.txtComTel.Text = model.ComTel; this.txtComChuanZhen.Text = model.ComChuanZhen; this.txtComBusTel.Text = model.ComBusTel; this.txtComName.Text = model.ComName; this.txtNaShuiNo.Text = model.NaShuiNo; this.txtComBrand.Text = model.ComBrand; lblZhanghao.Text = model.Address; txtGuestName.Text = model.GuestName; txtZLBZ.Text = model.ZLBZ; txtYSBJ.Text = model.YSBJ; txtFWBXDJ.Text = model.FWBXDJ; txtJFQ.Text = model.JFQ; txtRemark.Text = model.Remark; if (model.QPType == 1) { rbtnType1.Checked = true; } if (model.QPType == 2) { rbtnType2.Checked = true; } if (model.QPType == 3) { rbtnType3.Checked = true; txtLaborCost.Text = model.LaborCost.ToString(); txtEngineeringTax.Text = model.EngineeringTax.ToString(); txtXX.Text = model.LIlv.ToString(); } cbIsBrand.Checked = model.IsBrand; cbIsProduct.Checked = model.IsProduct; cbRemark.Checked = model.IsRemark; cbIsGaiZhang.Checked = model.IsGaiZhang; cbIsShuiYin.Checked = model.IsShuiYin; cbYH.Checked = model.IsYH; if (cbYH.Checked) { txtResultYH.Text = model.LastYH.ToString(); } GetALLTotal(); Session["Company"] = model.ComName; }
public string PrintPDF(int PDFId, out string QPNo, out string GuidNO, string modelWordUrl, string wordUrl) { //ServiceAppSetting.LoggerHander("开始转换", ""); QPNo = ""; GuidNO = ""; //string modelWordUrl = System.Web.HttpContext.Current.Request.MapPath("WordModel/") + "QP.doc"; //if (!File.Exists(modelWordUrl)) //{ // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('模版不存在!');</script>"); // return ""; //} tb_QuotePriceService QuotePriSer = new tb_QuotePriceService(); VAN_OA.Model.EFrom.tb_QuotePrice model = QuotePriSer.GetModel(PDFId); //ServiceAppSetting.LoggerHander("获取实体", ""); if (model.QPType == 2)//不含税 英文模版 { modelWordUrl = modelWordUrl.Replace("QP", "EnQP"); } GuidNO = model.QuoteNo; string guidUrl = wordUrl + GuidNO + ".doc"; if (!File.Exists(guidUrl)) { File.Copy(modelWordUrl, guidUrl); } else { return(guidUrl); } //ServiceAppSetting.LoggerHander("复制文件", ""); Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application(); object oMissing = System.Reflection.Missing.Value; //打开模板文档,并指定doc的文档类型 object objTemplate = guidUrl; //路径一定要正确 object objDocType = WdDocumentType.wdTypeDocument; object objfalse = false; object objtrue = true; object miss = System.Reflection.Missing.Value; object missingValue = Type.Missing; object doNotSaveChanges = WdSaveOptions.wdDoNotSaveChanges; Microsoft.Office.Interop.Word.Document doc = null; try { try { //ServiceAppSetting.LoggerHander("开始创建模版", ""); doc = (Document)appWord.Documents.Add(ref objTemplate, ref objfalse, ref objDocType, ref objtrue); //ServiceAppSetting.LoggerHander("结束创建模版", ""); } catch (Exception ex) { ServiceAppSetting.LoggerHander("创建模版-》" + ex.ToString(), ""); } //获取模板中所有的书签 Bookmarks odf = doc.Bookmarks; QPNo = model.QuoteNo; Dictionary <string, string> bookMarks = new Dictionary <string, string>(); bookMarks.Add("QuoteNo", model.QuoteNo); bookMarks.Add("QuoteNo1", model.QuoteNo); bookMarks.Add("GuestNo", model.GuestNo); bookMarks.Add("QuoteDate", model.QuoteDate.ToString("yyyy-MM-dd")); bookMarks.Add("ResultGuestName", model.ResultGuestName); bookMarks.Add("GuestName2", model.GuestName); bookMarks.Add("ResultGuestNo", model.ResultGuestNo); bookMarks.Add("PayStyle", model.PayStyle); bookMarks.Add("ContactPerToInv", model.ContactPerToInv); bookMarks.Add("NaShuiPer", model.NaShuiPer); //telToInv bookMarks.Add("telToInv", model.telToInv); //InvoHeader bookMarks.Add("InvoHeader", model.InvoHeader); //brandNo bookMarks.Add("brandNo", model.brandNo); //GuestNameToInv bookMarks.Add("GuestNameToInv", model.GuestNameToInv); //InvAddress bookMarks.Add("InvAddress", model.InvAddress); //AddressTofa bookMarks.Add("AddressTofa", model.AddressTofa); //AddressToInv bookMarks.Add("AddressToInv", model.AddressToInv); //InvTel bookMarks.Add("InvTel", model.InvTel); //InvContactPer bookMarks.Add("InvContactPer", model.InvContactPer); //BuessName bookMarks.Add("BuessName", model.BuessName); //ComBusTel bookMarks.Add("ComBusTel", model.ComBusTel); //ComTel bookMarks.Add("ComTel", model.ComTel); //BuessEmail bookMarks.Add("BuessEmail", model.BuessEmail); //ComChuanZhen bookMarks.Add("ComChuanZhen", model.ComChuanZhen); //ZLBZ bookMarks.Add("ZLBZ", model.ZLBZ); //YSBJ bookMarks.Add("YSBJ", model.YSBJ); //FWBXDJ bookMarks.Add("FWBXDJ", model.FWBXDJ); //JFQ bookMarks.Add("JFQ", model.JFQ); //ComName bookMarks.Add("ComName", model.ComName); //ComBrand bookMarks.Add("ComBrand", model.ComBrand); //ComBrand bookMarks.Add("Zhanghao", model.Address); //NaShuiNo bookMarks.Add("NaShuiNo", model.NaShuiNo); if (model.IsYH) { //NaShuiNo bookMarks.Add("YHPrice", model.LastYH.ToString()); } foreach (var key in bookMarks.Keys) { try { object objKey = key; doc.Bookmarks.get_Item(ref objKey).Range.Text = bookMarks[key]; } catch (Exception) { } } //ServiceAppSetting.LoggerHander("书签 赋值", ""); ////修改图片 //object YHPrice = "YHPrice"; //var xShape =doc.Bookmarks.get_Item(ref YHPrice).Range.InlineShapes.AddPicture(@"C:\Users\fj3174\Desktop\1.bmp", false, true ) ; //doc.Bookmarks.get_Item(ref YHPrice).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight; //报价内容 Microsoft.Office.Interop.Word.Table nowTable = doc.Tables[2]; Object Nothing = System.Reflection.Missing.Value; tb_QuotePrice_InvDetailsService invDetailSer = new tb_QuotePrice_InvDetailsService(); List <tb_QuotePrice_InvDetails> invDetails = invDetailSer.GetListArray(" QuoteId=" + PDFId); //invDetails.Add(new tb_QuotePrice_InvDetails { }); decimal total = 0; for (int i = 0; i < invDetails.Count; i++) { invDetails[i].No = i + 1; total += invDetails[i].Total; nowTable.Rows.Add(ref Nothing); } int rowsCount = nowTable.Rows.Count; int columnCount = nowTable.Columns.Count; ServiceAppSetting.LoggerHander("明细总数" + rowsCount, ""); decimal fax = Convert.ToDecimal(1.17); decimal noHanShui = 0; if (invDetails.Count > 0) { for (int rowPos = 2; rowPos <= rowsCount; rowPos++) { try { if (model.QPType == 2) { nowTable.Cell(rowPos, 1).Range.Text = invDetails[rowPos - 2].No.ToString(); nowTable.Cell(rowPos, 2).Range.Text = invDetails[rowPos - 2].InvName.ToString(); nowTable.Cell(rowPos, 3).Range.Text = invDetails[rowPos - 2].InvModel.ToString(); nowTable.Cell(rowPos, 4).Range.Text = invDetails[rowPos - 2].InvUnit.ToString(); nowTable.Cell(rowPos, 5).Range.Text = string.Format("{0:n0}", invDetails[rowPos - 2].InvNum); nowTable.Cell(rowPos, 6).Range.Text = string.Format("{0:n2}", (invDetails[rowPos - 2].InvPrice / fax)); noHanShui += (invDetails[rowPos - 2].InvPrice / fax) * invDetails[rowPos - 2].InvNum; nowTable.Cell(rowPos, 7).Range.Text = string.Format("{0:n2}", invDetails[rowPos - 2].InvPrice); nowTable.Cell(rowPos, 8).Range.Text = string.Format("{0:n2}", invDetails[rowPos - 2].Total); if (model.IsBrand) { nowTable.Cell(rowPos, 9).Range.Text = invDetails[rowPos - 2].GoodBrand.ToString();//品牌 } else { nowTable.Cell(rowPos, 9).Range.Text = "";//品牌 } if (model.IsProduct) { nowTable.Cell(rowPos, 10).Range.Text = invDetails[rowPos - 2].Product.ToString();//产地 } else { nowTable.Cell(rowPos, 10).Range.Text = "";//产地 } if (model.IsRemark) { nowTable.Cell(rowPos, 11).Range.Text = invDetails[rowPos - 2].InvRemark.ToString();//备注 } else { nowTable.Cell(rowPos, 11).Range.Text = "";//备注 } } else { nowTable.Cell(rowPos, 1).Range.Text = invDetails[rowPos - 2].No.ToString(); nowTable.Cell(rowPos, 2).Range.Text = invDetails[rowPos - 2].InvName.ToString(); nowTable.Cell(rowPos, 3).Range.Text = invDetails[rowPos - 2].InvModel.ToString(); nowTable.Cell(rowPos, 4).Range.Text = invDetails[rowPos - 2].InvUnit.ToString(); nowTable.Cell(rowPos, 5).Range.Text = string.Format("{0:n0}", invDetails[rowPos - 2].InvNum); nowTable.Cell(rowPos, 6).Range.Text = string.Format("{0:n2}", invDetails[rowPos - 2].InvPrice); nowTable.Cell(rowPos, 7).Range.Text = string.Format("{0:n2}", invDetails[rowPos - 2].Total); if (model.IsBrand) { nowTable.Cell(rowPos, 8).Range.Text = invDetails[rowPos - 2].GoodBrand.ToString(); } else { nowTable.Cell(rowPos, 8).Range.Text = "";//品牌 } if (model.IsProduct) { nowTable.Cell(rowPos, 9).Range.Text = invDetails[rowPos - 2].Product.ToString(); } else { nowTable.Cell(rowPos, 9).Range.Text = "";//产地 } if (model.IsRemark) { nowTable.Cell(rowPos, 10).Range.Text = invDetails[rowPos - 2].InvRemark.ToString(); } else { nowTable.Cell(rowPos, 10).Range.Text = "";//备注 } } } catch (Exception) { } } } ServiceAppSetting.LoggerHander("明细赋值", ""); //合计 if (model.QPType == 3)//工程 加三行 { //材料小计 nowTable.Rows.Add(ref Nothing); nowTable.Cell(rowsCount, 6).Range.Text = "材料小计"; nowTable.Cell(rowsCount, 7).Range.Text = total.ToString(); //人工费用 nowTable.Rows.Add(ref Nothing); rowsCount++; nowTable.Cell(rowsCount, 6).Range.Text = "人工费用"; nowTable.Cell(rowsCount, 7).Range.Text = model.LaborCost.ToString(); nowTable.Cell(rowsCount, 7).Range.Shading.ForegroundPatternColor = WdColor.wdColorYellow;//背景颜色 total += model.LaborCost; //工程计税 nowTable.Rows.Add(ref Nothing); rowsCount++; nowTable.Cell(rowsCount, 6).Range.Text = "工程计税"; nowTable.Cell(rowsCount, 7).Range.Text = model.EngineeringTax.ToString(); nowTable.Cell(rowsCount, 7).Range.Shading.ForegroundPatternColor = WdColor.wdColorYellow;//背景颜色 total += model.EngineeringTax; } if (model.QPType == 2) //不含税 英文格式 加1行 { Microsoft.Office.Interop.Word.Cell cell1 = nowTable.Cell(rowsCount + 1, 2); //2行1列合并2行2列为一起 cell1.Merge(nowTable.Cell(rowsCount + 1, 7)); nowTable.Cell(rowsCount + 1, 2).Range.Text = "总计人民币(不含税): " + string.Format("CNY {0:n2}", noHanShui) + System.Environment.NewLine + "总计人民币增值税: " + string.Format("CNY {0:n2}", (total - noHanShui)); nowTable.Cell(rowsCount + 1, 2).LeftPadding = 2; nowTable.Cell(rowsCount + 1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft; rowsCount++; nowTable.Rows.Add(ref Nothing); } if (model.QPType != 2) { Microsoft.Office.Interop.Word.Cell cell = nowTable.Cell(rowsCount + 1, 2);//2行1列合并2行2列为一起 cell.Merge(nowTable.Cell(rowsCount + 1, 6)); nowTable.Cell(rowsCount + 1, 2).Range.Text = "总计人民币(含税):"; nowTable.Cell(rowsCount + 1, 2).LeftPadding = 2; float size = 10.5f; //app.Selection.Font.Size nowTable.Cell(rowsCount + 1, 2).Range.Font.Size = size; nowTable.Cell(rowsCount + 1, 3).Range.Font.Size = size; nowTable.Cell(rowsCount + 1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft; nowTable.Cell(rowsCount + 1, 3).Range.Text = string.Format("CNY {0:n2}", total); nowTable.Cell(rowsCount + 1, 2).Range.Bold = 2; //设置单元格中字体为粗体 nowTable.Cell(rowsCount + 1, 3).Range.Bold = 2; //设置单元格中字体为粗体 } else { nowTable.Cell(rowsCount + 1, 2).Range.Text = "总计人民币(含税): " + string.Format("CNY {0:n2}", total); nowTable.Cell(rowsCount + 1, 2).LeftPadding = 2; float size = 10.5f; //app.Selection.Font.Size nowTable.Cell(rowsCount + 1, 2).Range.Font.Size = size; //nowTable.Cell(rowsCount + 1, 3).Range.Font.Size = size; nowTable.Cell(rowsCount + 1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft; //nowTable.Cell(rowsCount + 1, 3).Range.Text = string.Format("CNY {0:n2}", total); nowTable.Cell(rowsCount + 1, 2).Range.Bold = 2;//设置单元格中字体为粗体 //nowTable.Cell(rowsCount + 1, 3).Range.Bold = 2;//设置单元格中字体为粗体 } if (model.IsYH)//增加最后优惠信息 { //人工费用 nowTable.Rows.Add(ref Nothing); rowsCount++; Microsoft.Office.Interop.Word.Cell cell = nowTable.Cell(rowsCount + 1, 2);//2行1列合并2行2列为一起 //cell.Merge(nowTable.Cell(rowsCount + 1, 6)); if (model.QPType == 2) { nowTable.Cell(rowsCount + 1, 2).Range.Text = "最终优惠价(含税): " + string.Format("CNY {0:n2}", model.LastYH); } else { nowTable.Cell(rowsCount + 1, 2).Range.Text = "最终优惠价(含税):"; } nowTable.Cell(rowsCount + 1, 2).LeftPadding = 2; float size = 10.5f; //app.Selection.Font.Size nowTable.Cell(rowsCount + 1, 2).Range.Font.Size = size; nowTable.Cell(rowsCount + 1, 3).Range.Font.Size = size; nowTable.Cell(rowsCount + 1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft; if (model.QPType != 2) { nowTable.Cell(rowsCount + 1, 3).Range.Text = string.Format("CNY {0:n2}", model.LastYH); } nowTable.Cell(rowsCount + 1, 2).Range.Bold = 2; //设置单元格中字体为粗体 nowTable.Cell(rowsCount + 1, 3).Range.Bold = 2; //设置单元格中字体为粗体 } ServiceAppSetting.LoggerHander("合计赋值", ""); //object objKey_Total = "Total"; //doc.Bookmarks.get_Item(ref objKey_Total).Range.Text = string.Format("{0:n2}", total); doc.SaveAs(ref objTemplate, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); doc.Close(ref doNotSaveChanges, ref missingValue, ref missingValue); appWord.Application.Quit(ref miss, ref miss, ref miss); doc = null; appWord = null; } catch (Exception ex) { // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('文件不存在!');</script>"); doc.Close(ref doNotSaveChanges, ref missingValue, ref missingValue); appWord.Application.Quit(ref miss, ref miss, ref miss); if (System.IO.File.Exists(objTemplate.ToString())) { try { System.IO.File.Delete(objTemplate.ToString()); } catch (Exception) { } } return(""); } return(objTemplate.ToString()); }
/// <summary> /// 对象实体绑定数据 /// </summary> public VAN_OA.Model.EFrom.tb_QuotePrice ReaderBind(IDataReader dataReader) { VAN_OA.Model.EFrom.tb_QuotePrice model = new VAN_OA.Model.EFrom.tb_QuotePrice(); object ojb; ojb = dataReader["Id"]; if (ojb != null && ojb != DBNull.Value) { model.Id = (int)ojb; } model.QuoteNo = dataReader["QuoteNo"].ToString(); model.GuestName = dataReader["GuestName"].ToString(); model.GuestNo = dataReader["GuestNo"].ToString(); ojb = dataReader["QuoteDate"]; if (ojb != null && ojb != DBNull.Value) { model.QuoteDate = (DateTime)ojb; } model.ResultGuestName = dataReader["ResultGuestName"].ToString(); model.ResultGuestNo = dataReader["ResultGuestNo"].ToString(); model.PayStyle = dataReader["PayStyle"].ToString(); model.GuestNameToInv = dataReader["GuestNameToInv"].ToString(); model.ContactPerToInv = dataReader["ContactPerToInv"].ToString(); model.telToInv = dataReader["telToInv"].ToString(); model.AddressToInv = dataReader["AddressToInv"].ToString(); model.InvoHeader = dataReader["InvoHeader"].ToString(); model.InvContactPer = dataReader["InvContactPer"].ToString(); model.InvAddress = dataReader["InvAddress"].ToString(); model.InvTel = dataReader["InvTel"].ToString(); model.NaShuiPer = dataReader["NaShuiPer"].ToString(); model.brandNo = dataReader["brandNo"].ToString(); model.GuestNameTofa = dataReader["GuestNameTofa"].ToString(); model.ContactPerTofa = dataReader["ContactPerTofa"].ToString(); model.telTofa = dataReader["telTofa"].ToString(); model.AddressTofa = dataReader["AddressTofa"].ToString(); model.BuessName = dataReader["BuessName"].ToString(); model.BuessEmail = dataReader["BuessEmail"].ToString(); model.ComTel = dataReader["ComTel"].ToString(); model.ComChuanZhen = dataReader["ComChuanZhen"].ToString(); model.ComBusTel = dataReader["ComBusTel"].ToString(); model.ComName = dataReader["ComName"].ToString(); model.NaShuiNo = dataReader["NaShuiNo"].ToString(); model.Address = dataReader["Address"].ToString(); model.ComBrand = dataReader["ComBrand"].ToString(); ojb = dataReader["CreateUser"]; if (ojb != null && ojb != DBNull.Value) { model.CreateUser = (int)ojb; } ojb = dataReader["CreateTime"]; if (ojb != null && ojb != DBNull.Value) { model.CreateTime = (DateTime)ojb; } ojb = dataReader["loginName"]; if (ojb != null && ojb != DBNull.Value) { model.CreateUserName = ojb.ToString(); } model.Total = Convert.ToDecimal(dataReader["Total"]); model.ZLBZ = dataReader["ZLBZ"].ToString(); model.YSBJ = dataReader["YSBJ"].ToString(); model.FWBXDJ = dataReader["FWBXDJ"].ToString(); model.JFQ = dataReader["JFQ"].ToString(); model.Remark = dataReader["Remark"].ToString(); model.LaborCost = Convert.ToDecimal(dataReader["LaborCost"]); model.EngineeringTax = Convert.ToDecimal(dataReader["EngineeringTax"]); model.QPType = Convert.ToInt32(dataReader["QPType"]); model.IsBrand = Convert.ToBoolean(dataReader["IsBrand"]); model.IsProduct = Convert.ToBoolean(dataReader["IsProduct"]); model.LIlv = Convert.ToDecimal(dataReader["LIlv"]); model.LastYH = Convert.ToDecimal(dataReader["LastYH"]); model.IsYH = Convert.ToBoolean(dataReader["IsYH"]); model.IsRemark = Convert.ToBoolean(dataReader["IsRemark"]); model.IsShuiYin = Convert.ToBoolean(dataReader["IsShuiYin"]); model.IsGaiZhang = Convert.ToBoolean(dataReader["IsGaiZhang"]); return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(VAN_OA.Model.EFrom.tb_QuotePrice model, SqlCommand objCommand) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_QuotePrice set "); //if (model.QuoteNo != null) //{ // strSql.Append("QuoteNo='" + model.QuoteNo + "',"); //} if (model.GuestName != null) { strSql.Append("GuestName='" + model.GuestName + "',"); } if (model.GuestId != null) { strSql.Append("GuestId=" + model.GuestId + ","); } if (model.GuestNo != null) { strSql.Append("GuestNo='" + model.GuestNo + "',"); } if (model.QuoteDate != null) { strSql.Append("QuoteDate='" + model.QuoteDate + "',"); } if (model.ResultGuestName != null) { strSql.Append("ResultGuestName='" + model.ResultGuestName + "',"); } if (model.ResultGuestNo != null) { strSql.Append("ResultGuestNo='" + model.ResultGuestNo + "',"); } if (model.PayStyle != null) { strSql.Append("PayStyle='" + model.PayStyle + "',"); } if (model.GuestNameToInv != null) { strSql.Append("GuestNameToInv='" + model.GuestNameToInv + "',"); } else { strSql.Append("GuestNameToInv= null ,"); } if (model.ContactPerToInv != null) { strSql.Append("ContactPerToInv='" + model.ContactPerToInv + "',"); } else { strSql.Append("ContactPerToInv= null ,"); } if (model.telToInv != null) { strSql.Append("telToInv='" + model.telToInv + "',"); } else { strSql.Append("telToInv= null ,"); } if (model.AddressToInv != null) { strSql.Append("AddressToInv='" + model.AddressToInv + "',"); } else { strSql.Append("AddressToInv= null ,"); } if (model.InvoHeader != null) { strSql.Append("InvoHeader='" + model.InvoHeader + "',"); } else { strSql.Append("InvoHeader= null ,"); } if (model.InvContactPer != null) { strSql.Append("InvContactPer='" + model.InvContactPer + "',"); } else { strSql.Append("InvContactPer= null ,"); } if (model.InvAddress != null) { strSql.Append("InvAddress='" + model.InvAddress + "',"); } else { strSql.Append("InvAddress= null ,"); } if (model.InvTel != null) { strSql.Append("InvTel='" + model.InvTel + "',"); } else { strSql.Append("InvTel= null ,"); } if (model.NaShuiPer != null) { strSql.Append("NaShuiPer='" + model.NaShuiPer + "',"); } else { strSql.Append("NaShuiPer= null ,"); } if (model.brandNo != null) { strSql.Append("brandNo='" + model.brandNo + "',"); } else { strSql.Append("brandNo= null ,"); } if (model.GuestNameTofa != null) { strSql.Append("GuestNameTofa='" + model.GuestNameTofa + "',"); } else { strSql.Append("GuestNameTofa= null ,"); } if (model.ContactPerTofa != null) { strSql.Append("ContactPerTofa='" + model.ContactPerTofa + "',"); } else { strSql.Append("ContactPerTofa= null ,"); } if (model.telTofa != null) { strSql.Append("telTofa='" + model.telTofa + "',"); } else { strSql.Append("telTofa= null ,"); } if (model.AddressTofa != null) { strSql.Append("AddressTofa='" + model.AddressTofa + "',"); } else { strSql.Append("AddressTofa= null ,"); } if (model.BuessName != null) { strSql.Append("BuessName='" + model.BuessName + "',"); } else { strSql.Append("BuessName= null ,"); } if (model.BuessEmail != null) { strSql.Append("BuessEmail='" + model.BuessEmail + "',"); } else { strSql.Append("BuessEmail= null ,"); } if (model.ComTel != null) { strSql.Append("ComTel='" + model.ComTel + "',"); } else { strSql.Append("ComTel= null ,"); } if (model.ComChuanZhen != null) { strSql.Append("ComChuanZhen='" + model.ComChuanZhen + "',"); } else { strSql.Append("ComChuanZhen= null ,"); } if (model.ComBusTel != null) { strSql.Append("ComBusTel='" + model.ComBusTel + "',"); } else { strSql.Append("ComBusTel= null ,"); } if (model.ComName != null) { strSql.Append("ComName='" + model.ComName + "',"); } else { strSql.Append("ComName= null ,"); } if (model.NaShuiNo != null) { strSql.Append("NaShuiNo='" + model.NaShuiNo + "',"); } else { strSql.Append("NaShuiNo= null ,"); } if (model.Address != null) { strSql.Append("Address='" + model.Address + "',"); } else { strSql.Append("Address= null ,"); } if (model.ComBrand != null) { strSql.Append("ComBrand='" + model.ComBrand + "',"); } else { strSql.Append("ComBrand= null ,"); } if (model.Total != null) { strSql.Append("Total=" + model.Total + ","); } if (model.LIlv != null) { strSql.Append("LIlv=" + model.LIlv + ","); } if (model.ZLBZ != null) { strSql.Append("ZLBZ='" + model.ZLBZ + "',"); } if (model.YSBJ != null) { strSql.Append("YSBJ='" + model.YSBJ + "',"); } if (model.FWBXDJ != null) { strSql.Append("FWBXDJ='" + model.FWBXDJ + "',"); } if (model.JFQ != null) { strSql.Append("JFQ='" + model.JFQ + "',"); } if (model.Remark != null) { strSql.Append("Remark='" + model.Remark + "',"); } if (model.LaborCost != null) { strSql.Append("LaborCost=" + model.LaborCost + ","); } if (model.EngineeringTax != null) { strSql.Append("EngineeringTax=" + model.EngineeringTax + ","); } if (model.QPType != null) { strSql.Append("QPType=" + model.QPType + ","); } if (model.IsBrand != null) { strSql.Append("IsBrand=" + (model.IsBrand?1:0) + ","); } if (model.IsProduct != null) { strSql.Append("IsProduct=" + (model.IsProduct ? 1 : 0) + ","); } if (model.IsYH != null) { strSql.Append("IsYH=" + (model.IsYH ? 1 : 0) + ","); } if (model.IsRemark != null) { strSql.Append("IsRemark=" + (model.IsRemark ? 1 : 0) + ","); } if (model.LastYH != null) { strSql.Append("LastYH=" + model.LastYH + ","); } if (model.IsGaiZhang != null) { strSql.Append("IsGaiZhang=" + (model.IsGaiZhang ? 1 : 0) + ","); } if (model.IsShuiYin != null) { strSql.Append("IsShuiYin=" + (model.IsShuiYin ? 1 : 0) + ","); } // strSql.Append(" CreateTime=getdate(),"); int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where Id=" + model.Id + ""); objCommand.CommandText = strSql.ToString(); objCommand.ExecuteNonQuery(); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(VAN_OA.Model.EFrom.tb_QuotePrice model, SqlCommand objCommand) { //报价单号:YYYYMMDDTTT-N 表示,YYYYMMDD是生成界面的当年月日,TTT是客户表中的快速代码,N 是当天这个客户的第几份报价单 string resultNo = ""; string Qian = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00") + model.GuestNo + "-"; string getNo = string.Format(@"select right('0000000000000'+CONVERT(varchar, MAX(CONVERT(int, RIGHT(QuoteNo,2)))+1),2) from tb_QuotePrice where QuoteNo like '{0}%'", Qian); objCommand.CommandText = getNo; object objNo = objCommand.ExecuteScalar(); if (objNo == null || objNo.ToString() == "") { resultNo = Qian + "01"; } else { resultNo = Qian + objNo.ToString(); } model.QuoteNo = resultNo; StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.QuoteNo != null) { strSql1.Append("QuoteNo,"); strSql2.Append("'" + resultNo + "',"); } if (model.GuestName != null) { strSql1.Append("GuestName,"); strSql2.Append("'" + model.GuestName + "',"); } if (model.GuestNo != null) { strSql1.Append("GuestNo,"); strSql2.Append("'" + model.GuestNo + "',"); } if (model.GuestId != null) { strSql1.Append("GuestId,"); strSql2.Append("" + model.GuestId + ","); } if (model.QuoteDate != null) { strSql1.Append("QuoteDate,"); strSql2.Append("'" + model.QuoteDate + "',"); } if (model.ResultGuestName != null) { strSql1.Append("ResultGuestName,"); strSql2.Append("'" + model.ResultGuestName + "',"); } if (model.ResultGuestNo != null) { strSql1.Append("ResultGuestNo,"); strSql2.Append("'" + model.ResultGuestNo + "',"); } if (model.PayStyle != null) { strSql1.Append("PayStyle,"); strSql2.Append("'" + model.PayStyle + "',"); } if (model.GuestNameToInv != null) { strSql1.Append("GuestNameToInv,"); strSql2.Append("'" + model.GuestNameToInv + "',"); } if (model.ContactPerToInv != null) { strSql1.Append("ContactPerToInv,"); strSql2.Append("'" + model.ContactPerToInv + "',"); } if (model.telToInv != null) { strSql1.Append("telToInv,"); strSql2.Append("'" + model.telToInv + "',"); } if (model.AddressToInv != null) { strSql1.Append("AddressToInv,"); strSql2.Append("'" + model.AddressToInv + "',"); } if (model.InvoHeader != null) { strSql1.Append("InvoHeader,"); strSql2.Append("'" + model.InvoHeader + "',"); } if (model.InvContactPer != null) { strSql1.Append("InvContactPer,"); strSql2.Append("'" + model.InvContactPer + "',"); } if (model.InvAddress != null) { strSql1.Append("InvAddress,"); strSql2.Append("'" + model.InvAddress + "',"); } if (model.InvTel != null) { strSql1.Append("InvTel,"); strSql2.Append("'" + model.InvTel + "',"); } if (model.NaShuiPer != null) { strSql1.Append("NaShuiPer,"); strSql2.Append("'" + model.NaShuiPer + "',"); } if (model.brandNo != null) { strSql1.Append("brandNo,"); strSql2.Append("'" + model.brandNo + "',"); } if (model.GuestNameTofa != null) { strSql1.Append("GuestNameTofa,"); strSql2.Append("'" + model.GuestNameTofa + "',"); } if (model.ContactPerTofa != null) { strSql1.Append("ContactPerTofa,"); strSql2.Append("'" + model.ContactPerTofa + "',"); } if (model.telTofa != null) { strSql1.Append("telTofa,"); strSql2.Append("'" + model.telTofa + "',"); } if (model.AddressTofa != null) { strSql1.Append("AddressTofa,"); strSql2.Append("'" + model.AddressTofa + "',"); } if (model.BuessName != null) { strSql1.Append("BuessName,"); strSql2.Append("'" + model.BuessName + "',"); } if (model.BuessEmail != null) { strSql1.Append("BuessEmail,"); strSql2.Append("'" + model.BuessEmail + "',"); } if (model.ComTel != null) { strSql1.Append("ComTel,"); strSql2.Append("'" + model.ComTel + "',"); } if (model.ComChuanZhen != null) { strSql1.Append("ComChuanZhen,"); strSql2.Append("'" + model.ComChuanZhen + "',"); } if (model.ComBusTel != null) { strSql1.Append("ComBusTel,"); strSql2.Append("'" + model.ComBusTel + "',"); } if (model.ComName != null) { strSql1.Append("ComName,"); strSql2.Append("'" + model.ComName + "',"); } if (model.NaShuiNo != null) { strSql1.Append("NaShuiNo,"); strSql2.Append("'" + model.NaShuiNo + "',"); } if (model.Address != null) { strSql1.Append("Address,"); strSql2.Append("'" + model.Address + "',"); } if (model.ComBrand != null) { strSql1.Append("ComBrand,"); strSql2.Append("'" + model.ComBrand + "',"); } if (model.CreateUser != null) { strSql1.Append("CreateUser,"); strSql2.Append("" + model.CreateUser + ","); } if (model.CreateTime != null) { strSql1.Append("CreateTime,"); strSql2.Append("'" + model.CreateTime + "',"); } if (model.Total != null) { strSql1.Append("Total,"); strSql2.Append("" + model.Total + ","); } if (model.LIlv != null) { strSql1.Append("LIlv,"); strSql2.Append("" + model.LIlv + ","); } if (model.ZLBZ != null) { strSql1.Append("ZLBZ,"); strSql2.Append("'" + model.ZLBZ + "',"); } if (model.YSBJ != null) { strSql1.Append("YSBJ,"); strSql2.Append("'" + model.YSBJ + "',"); } if (model.FWBXDJ != null) { strSql1.Append("FWBXDJ,"); strSql2.Append("'" + model.FWBXDJ + "',"); } if (model.JFQ != null) { strSql1.Append("JFQ,"); strSql2.Append("'" + model.JFQ + "',"); } if (model.Remark != null) { strSql1.Append("Remark,"); strSql2.Append("'" + model.Remark + "',"); } if (model.LaborCost != null) { strSql1.Append("LaborCost,"); strSql2.Append("" + model.LaborCost + ","); } if (model.EngineeringTax != null) { strSql1.Append("EngineeringTax,"); strSql2.Append("" + model.EngineeringTax + ","); } if (model.QPType != null) { strSql1.Append("QPType,"); strSql2.Append("" + model.QPType + ","); } if (model.IsBrand != null) { strSql1.Append("IsBrand,"); strSql2.Append("" + (model.IsBrand?1:0) + ","); } if (model.IsProduct != null) { strSql1.Append("IsProduct,"); strSql2.Append("" + (model.IsProduct ? 1 : 0) + ","); } if (model.IsYH != null) { strSql1.Append("IsYH,"); strSql2.Append("" + (model.IsYH ? 1 : 0) + ","); } if (model.IsRemark != null) { strSql1.Append("IsRemark,"); strSql2.Append("" + (model.IsRemark ? 1 : 0) + ","); } if (model.LastYH != null) { strSql1.Append("LastYH,"); strSql2.Append("" + model.LastYH + ","); } if (model.IsShuiYin != null) { strSql1.Append("IsShuiYin,"); strSql2.Append("" + (model.IsShuiYin ? 1 : 0) + ","); } if (model.IsGaiZhang != null) { strSql1.Append("IsGaiZhang,"); strSql2.Append("" + (model.IsGaiZhang ? 1 : 0) + ","); } strSql.Append("insert into tb_QuotePrice("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); int result; objCommand.CommandText = strSql.ToString(); object obj = objCommand.ExecuteScalar(); if (!int.TryParse(obj.ToString(), out result)) { return(0); } return(result); }
//private string storefolder = @"D:\PDFConverter\"; protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { try { converter = new RemoteConverter(); if (Request["type"] != "word") { try { //try to get the remoting-object if (!converter.WordIsAvailable()) { lblMess.Text = "Word 2007 not available on server!"; return; } } catch { //Remoteserver not available lblMess.Text = "PDFConverter is not running!"; return; } } if (Session["PDFId"] != null) { #region 获取URL名称 tb_QuotePriceService QuotePriSer = new tb_QuotePriceService(); VAN_OA.Model.EFrom.tb_QuotePrice model = QuotePriSer.GetModel(Convert.ToInt32(Session["PDFId"])); //文件名由 “苏州万邦电脑系统有限公司”(报价AE所属单位全称)+“-”+“20161018“(第一次生成的日期)+“天华网络”(客户简称)+“-”+“报价单” VAN_OA.Dal.ReportForms.TB_GuestTrackService guestTrackSer = new VAN_OA.Dal.ReportForms.TB_GuestTrackService(); var simpGuestName = guestTrackSer.GetGuestSimpName(string.Format(" and GuestName='{0}'", model.GuestName)); #endregion string wordUrl = System.Web.HttpContext.Current.Request.MapPath("PDFConverter/"); string otherName = model.ComName + "-" + model.CreateTime.ToString("yyyyMMdd") + "-" + simpGuestName + "" + "-报价单" + model.QuoteNo.Substring(12); string urlName = wordUrl + otherName; try { if (File.Exists(urlName + ".pdf")) { File.Delete(urlName + ".pdf"); } } catch (Exception) { } try { if (File.Exists(urlName + ".doc")) { File.Delete(urlName + ".doc"); } } catch (Exception) { } var modelPath = System.Web.HttpContext.Current.Request.MapPath("WordModel/"); if (model.ComName != "苏州万邦电脑系统有限公司") { modelPath += model.ComName + @"/"; } string modelWordUrl = modelPath + "QP.doc"; if (Request["type"] != "word") { if (model.IsShuiYin && model.IsGaiZhang)//QP2 { modelWordUrl = modelPath + "QP1.doc"; } if (model.IsGaiZhang == false && model.IsShuiYin)//QP1 { modelWordUrl = modelPath + "QP2.doc"; } if (model.IsGaiZhang && model.IsShuiYin == false)//QP1 { modelWordUrl = modelPath + "QP3.doc"; } } string QPNO = ""; string GuidNO = ""; //string url = @"D:\Project\万邦OA\FLY\ReportForms\PDFConverter\201702080285-01-word\201702080285-01.doc"; // string url = converter.PrintPDF(Convert.ToInt32(Session["PDFId"]), out QPNO, out GuidNO, modelWordUrl, wordUrl); if (url != "" && Request["type"] != "word") { //convertPDF(url, QPNO, GuidNO); string sourcefile = url; string outputfile = url.Replace(".doc", ".pdf"); //call the converter method converter.convert(sourcefile, outputfile); urlName += ".pdf"; if (File.Exists(outputfile)) { File.Copy(outputfile, urlName); } List <string> listFJ = new List <string>(); //保存附件路径 List <string> listFJName = new List <string>(); //保存附件名字 listFJ.Add(outputfile); listFJ.Add(urlName); listFJName.Add(GuidNO + ".pdf"); listFJName.Add(otherName + ".pdf"); string time = GuidNO + "-pdf"; var path = Server.MapPath("PDFConverter/" + time + ".rar"); ZipFileMain(listFJ.ToArray(), listFJName.ToArray(), path, 9);//压缩文件 //DownloadFile(Server.UrlEncode(time + ".rar"), path);//下载文件 try { File.Delete(url); } catch (Exception) { } // foreach (var fj in listFJ) { try { File.Delete(fj);//删除已下载文件 } catch (Exception) { } } convertWord(path, listFJ); } else { //创建另一个文件 string guidUrl = wordUrl + GuidNO + ".doc"; urlName += ".doc"; if (File.Exists(guidUrl)) { File.Copy(guidUrl, urlName, true); } List <string> listFJ = new List <string>(); //保存附件路径 List <string> listFJName = new List <string>(); //保存附件名字 listFJ.Add(url); listFJ.Add(urlName); listFJName.Add(GuidNO + ".doc"); listFJName.Add(otherName + ".doc"); string time = GuidNO + "-word"; var path = Server.MapPath("PDFConverter/" + time + ".rar"); ZipFileMain(listFJ.ToArray(), listFJName.ToArray(), path, 9);//压缩文件 //DownloadFile(Server.UrlEncode(time + ".zip"), path);//下载文件 foreach (var fj in listFJ) { try { File.Delete(fj);//删除已下载文件 } catch (Exception) { } } convertWord(path, listFJ); } } } catch (Exception ex) { if (converter == null) { lblMess.Text += "conver -null"; } if (Session["PDFId"] == null) { lblMess.Text += "pdfid-null"; } lblMess.Text += "A:" + ex.ToString() + "111"; ServiceAppSetting.LoggerHander.Invoke(ex.ToString(), "Error"); } } }