/// <summary> /// 文档格式预定义好的,只填写内容 /// </summary> /// <param name="obj"></param> public static void ExportExcel(sdjl_23 obj) { ExcelAccess ex = new ExcelAccess(); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string fname = Application.StartupPath + "\\00记录模板\\送电16电力设备产权、维护范围协议书.xls"; if (obj.BigData != null) { if (obj.BigData.Length > 10) { fname = Path.GetTempPath() + "送电16电力设备产权、维护范围协议书.xls"; //MemoryStream ms = new MemoryStream(obj.BigData); FileStream fs = new FileStream(fname, FileMode.OpenOrCreate); fs.Write(obj.BigData, 0, obj.BigData.Length); fs.Flush(); fs.Close(); } } ex.Open(fname); ex.SetCellValue(obj.jf, 5, 4); ex.SetCellValue(obj.xybh, 4, 11); ex.SetCellValue(obj.cqdw + ":", 6, 4); string linename = ""; if (obj.linename.Contains("线")) { linename = obj.linename.Substring(0, obj.linename.LastIndexOf("线")); } else linename = obj.linename; string[] filtchar = { "V", "v" }; for (int i = 0; i < filtchar.Length; i++) { if (linename.Contains(filtchar[i])) { linename = linename.Substring(linename.LastIndexOf(filtchar[i]) + 1); } } ex.SetCellValue(linename,9, 9); //string fzlinename = ""; //if (obj.fzlinename.Contains("支")) //{ // fzlinename = obj.fzlinename.Substring(0, obj.fzlinename.LastIndexOf("支")); //} //else // fzlinename = obj.fzlinename; //ex.SetCellValue(fzlinename, 10, 10); ex.SetCellValue(obj.cqfw, 10, 4); ex.SetCellValue("'" + obj.gh, 9, 12); ex.SetCellValue(obj.cqdw+"。", 12, 4); ex.SetCellValue(obj.jf, 11, 4); ex.SetCellValue(obj.qxydd, 15, 8); ex.SetCellValue(obj.qdrq.Year.ToString(), 21, 11); ex.SetCellValue(obj.qdrq.Month.ToString(), 21, 13); ex.SetCellValue(obj.qdrq.Day.ToString(), 21, 16); ex.ShowExcel(); }
void gridViewOperation_AfterEdit(sdjl_23 obj) { //修改模板 //mOrg org = MainHelper.PlatformSqlMap.GetOneByKey<mOrg>(obj.ParentID); //string fname = Application.StartupPath + "\\00记录模板\\23配电线路产权维护范围协议书.xls"; //string bhname = org.OrgName.Replace("供电所", ""); //DSOFramerControl dsoFramerControl1 = new DSOFramerControl(); //dsoFramerControl1.FileOpen(fname); //Microsoft.Office.Interop.Excel.Workbook wb = dsoFramerControl1.AxFramerControl.ActiveDocument as Microsoft.Office.Interop.Excel.Workbook; //sdjl_23 obj1 = (sdjl_23)MainHelper.PlatformSqlMap.GetObject("Selectsdjl_23List", "where ParentID='" + obj.ParentID + "' and xybh like '" + SelectorHelper.GetPysm(org.OrgName.Replace("供电所", ""), true) + "-" + DateTime.Now.Year.ToString() + "-%' order by xybh ASC"); //int icount = 1; //if (obj1 != null && obj1.xybh != "") //{ // icount = Convert.ToInt32(obj.xybh.Split('-')[2]) + 1; //} //string strname = SelectorHelper.GetPysm(bhname, true); //ExcelAccess ea = new ExcelAccess(); //ea.MyWorkBook = wb; //ea.MyExcel = wb.Application; //ea.SetCellValue(strname.ToUpper(), 4, 8); //strname = DateTime.Now.Year.ToString(); //ea.SetCellValue(strname, 4, 9); //strname = string.Format("{0:D3}", icount); //ea.SetCellValue(strname, 4, 10); //ea.SetCellValue(obj.cqdw + ":", 6, 4); //ea.SetCellValue(obj.linename, 10, 7); //ea.SetCellValue(obj.fzlinename, 10, 10); //ea.SetCellValue("'" + obj.gh, 10,16); //ea.SetCellValue(obj.cqfw, 11, 4); //ea.SetCellValue(obj.cqdw, 13, 4); //ea.SetCellValue(obj.qdrq.Year.ToString(), 21, 7); //ea.SetCellValue(obj.qdrq.Month.ToString(), 21, 9); //ea.SetCellValue(obj.qdrq.Day.ToString(), 21, 11); //dsoFramerControl1.FileSave(); //obj.BigData = dsoFramerControl1.FileData; //dsoFramerControl1.FileClose(); //dsoFramerControl1.Dispose(); //dsoFramerControl1 = null; MainHelper.PlatformSqlMap.Update<sdjl_23>(obj); }
/// <summary> /// 新建对象设置Key值 /// </summary> /// <param name="newobj"></param> void gridViewOperation_CreatingObjectEvent(sdjl_23 newobj) { if (parentID == null) return; newobj.ParentID = parentID; //newobj.OrgName = parentObj.OrgName; newobj.CreateDate = DateTime.Now; newobj.qdrq = DateTime.Now; Ebada.Core.UserBase m_UserBase = MainHelper.ValidateLogin(); newobj.CreateMan = m_UserBase.RealName; string bhname = ParentObj.OrgName.Replace("供电所", ""); sdjl_23 obj = (sdjl_23)MainHelper.PlatformSqlMap.GetObject("Selectsdjl_23List", "where ParentID='" + ParentID + "' and xybh like '" + SelectorHelper.GetPysm(ParentObj.OrgName.Replace("供电所", ""), true) + "-" + DateTime.Now.Year.ToString() + "-%' order by xybh ASC"); int icount = 1; if (obj != null && obj.xybh != "") { icount = Convert.ToInt32(obj.xybh.Split('-')[2]) + 1; } newobj.xybh = SelectorHelper.GetPysm(bhname, true).ToUpper() + "-" + DateTime.Now.Year.ToString() + "-" + string.Format("{0:D3}", icount); }
public void CreatRiZhi(sdjl_23 obj) { sdjl_gzrjnr gzr = new sdjl_gzrjnr(); gzr.gzrjID = gzr.CreateID(); gzr.ParentID = obj.ID; Thread.Sleep(new TimeSpan(100000));//0.1毫秒 IList<sdjl_01gzrj> gzrj01 = MainHelper.PlatformSqlMap.GetList<sdjl_01gzrj>("Selectsdjl_01gzrjList", "where GdsCode='" + MainHelper.User.OrgCode + "' and rq between '" + obj.qdrq.ToString("yyyy-MM-dd 00:00:00") + "' and '" + obj.qdrq.ToString("yyyy-MM-dd 23:59:59") + "'"); if (gzrj01.Count > 0) { gzr.gzrjID = gzrj01[0].gzrjID; } else { sdjl_01gzrj pj = new sdjl_01gzrj(); pj.gzrjID = pj.CreateID(); pj.GdsCode = ParentObj.OrgCode; pj.GdsName = ParentObj.OrgName; pj.CreateDate = obj.qdrq; pj.CreateMan = MainHelper.User.UserName; gzr.gzrjID = pj.gzrjID; pj.rq = obj.qdrq; pj.xq = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek); pj.rsaqts = (DateTime.Today - MainHelper.UserOrg.PSafeTime.Date).Days; pj.sbaqts = (DateTime.Today - MainHelper.UserOrg.DSafeTime.Date).Days; Thread.Sleep(new TimeSpan(100000));//0.1毫秒 MainHelper.PlatformSqlMap.Create<sdjl_01gzrj>(pj); } IList<sdjl_gzrjnr> gzrlist = MainHelper.PlatformSqlMap.GetList<sdjl_gzrjnr>("Selectsdjl_gzrjnrList", "where gzrjID = '" + gzr.gzrjID + "' order by seq "); if (gzrlist.Count > 0) { gzr.seq = gzrlist[gzrlist.Count - 1].seq + 1; } else gzr.seq = 1; gzr.gznr = "配电设备产权、维护范围协议书"; gzr.fzr = obj.cqdw; //string[] strli = obj.cjry.Split(';'); //if (strli.Length < 3) // gzr.cjry = obj.cjry; //else //{ // gzr.cjry = strli[0] + strli[1] + "等" + strli.Length + "人"; //} gzr.CreateDate = obj.qdrq; gzr.CreateMan = MainHelper.User.UserName; gzr.fssj = obj.qdrq; MainHelper.PlatformSqlMap.Create<sdjl_gzrjnr>(gzr); }
void gridViewOperation_AfterAdd(sdjl_23 obj) { CreatRiZhi(obj); }