Пример #1
0
        void ctrl_Leave(object sender, EventArgs e) {
            LP_Temple lp = (LP_Temple)(sender as Control).Tag;
            string str = (sender as Control).Text;
            if (dsoFramerWordControl1 == null || dsoFramerWordControl1.MyExcel == null) {
                return;
            }
            try {
                //Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
                ExcelAccess ea = new ExcelAccess();
                ea.MyWorkBook = wb;
                ea.MyExcel = wb.Application;
                //Excel.Worksheet xx;
                if (lp.KindTable != "" && activeSheetName != lp.KindTable) {
                    if (lp.KindTable != "") {
                        activeSheetName = lp.KindTable;

                        xx = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet;

                        activeSheetIndex = xx.Index;
                    } else {
                        xx = wb.Application.Sheets[1] as Excel.Worksheet;
                        activeSheetIndex = xx.Index;
                        activeSheetName = xx.Name;
                    }
                    if (lp.KindTable != "") {
                        ea.ActiveSheet(lp.KindTable);
                    } else {
                        ea.ActiveSheet(1);
                    }
                }
                if (lp.CellPos == "") {
                    if (lp.CellName.IndexOf("绘图") > -1) {
                        //unLockExcel(wb, xx);
                        PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + str + "'");
                        if (tb != null) {
                            if (tb.picName != "表箱") {
                                string tempPath = Path.GetTempPath();
                                string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1;
                                FileStream fs;
                                fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                BinaryWriter bw = new BinaryWriter(fs);
                                bw.Write(tb.picImage);
                                bw.Flush();
                                bw.Close();
                                fs.Close();
                                //IDataObject data = new DataObject(DataFormats.FileDrop, new string[] { tempfile });
                                //MemoryStream memo = new MemoryStream(4);
                                //byte[] bytes = new byte[] { (byte)(5), 0, 0, 0 };
                                //memo.Write(bytes, 0, bytes.Length);
                                //data.SetData("ttt", memo);
                                //Clipboard.SetDataObject(data);
                                Image im = Bitmap.FromFile(tempfile);
                                Bitmap bt = new Bitmap(im);
                                DataObject dataObject = new DataObject();
                                dataObject.SetData(DataFormats.Bitmap, bt);
                                Clipboard.SetDataObject(dataObject, true);
                            } else {
                                Microsoft.Office.Interop.Excel.Shape activShape = null;
                                activShape = xx.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal,
                                    (float)153.75, (float)162.75, (float)22.5, (float)10.5);
                                activShape.TextFrame.Characters(1, 1).Font.Size = 8;
                                activShape.TextFrame.Characters(1, 1).Text = "1";
                                activShape.TextFrame.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                                activShape.Cut();
                            }
                        }
                    } else {
                        if (valuehs.ContainsKey(lp.LPID)) {
                            WF_TableFieldValue tfv = valuehs[lp.LPID] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;

                        } else {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;
                            tfv.ExcelSheetName = xx.Name;

                            valuehs.Add(lp.LPID, tfv);
                        }
                    }
                    return;
                }

                unLockExcel(wb, xx);

                string[] arrCellpos = lp.CellPos.Split(pchar);
                string[] arrtemp = lp.WordCount.Split(pchar);
                arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar);
                if (lp.CtrlType.Contains("uc_gridcontrol")) {
                    FillTable(ea, lp, (sender as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar))));
                    LockExcel(wb, xx);
                    return;
                } else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit")) {
                    FillTime(ea, lp, (sender as DateEdit).DateTime);
                    LockExcel(wb, xx);
                    return;
                } else if (lp.CtrlType.Contains("DevExpress.XtraEditors.SpinEdit")) {

                    IList<string> strList = new List<string>();
                    if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1])) {
                        if (string.IsNullOrEmpty(str))
                            ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                        else
                            ea.SetCellValue("'" + str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0])) {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;

                        } else {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                        }
                    } else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1]))) {
                        int i = 0;
                        if (string.IsNullOrEmpty(str))
                            ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                        else
                            ea.SetCellValue("'" + str, GetCellPos(arrCellpos[i])[0], GetCellPos(arrCellpos[i])[1]);
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[i])) {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[i]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[i])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[i])[1];
                            tfv.ExcelSheetName = xx.Name;

                        } else {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[i])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[i])[1];
                            tfv.ExcelSheetName = xx.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[i], tfv);
                        }
                    }
                    LockExcel(wb, xx);

                    return;
                }

                string[] extraWord = lp.ExtraWord.Split(pchar);
                List<int> arrCellCount = String2Int(arrtemp);
                if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1])) {
                    if (string.IsNullOrEmpty(str))
                        ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                    else
                        ea.SetCellValue("'" + str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + lp.CellPos)) {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + lp.CellPos] as WF_TableFieldValue;
                        tfv.ControlValue = str;
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                        tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                        tfv.ExcelSheetName = xx.Name;

                    } else {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = str;
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                        tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                        tfv.ExcelSheetName = xx.Name;
                        valuehs.Add(lp.LPID + "$" + lp.CellPos, tfv);
                    }

                } else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1]))) {
                    StringHelper help = new StringHelper();
                    if (lp.CellName == "编号") {
                        for (int j = 0; j < arrCellpos.Length; j++) {
                            if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[j]) && str != "") {
                                string strNew = str.Substring(0, str.Length - 1) + (j + 1).ToString();
                                ea.SetCellValue("'" + strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]);
                                if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[j])) {
                                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[j]] as WF_TableFieldValue;
                                    tfv.ControlValue = strNew;
                                    tfv.FieldId = lp.LPID;
                                    tfv.FieldName = lp.CellName;
                                    tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                    tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                    tfv.ExcelSheetName = xx.Name;

                                } else {
                                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                                    tfv.ControlValue = strNew;
                                    tfv.FieldId = lp.LPID;
                                    tfv.FieldName = lp.CellName;
                                    tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                    tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                    tfv.ExcelSheetName = xx.Name;
                                    valuehs.Add(lp.LPID + "$" + arrCellpos[j], tfv);
                                }
                            }
                        }
                        LockExcel(wb, xx);
                        return;
                    }
                    int i = 0;
                    if (arrCellCount[0] != arrCellCount[1]) {
                        if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[0])) {
                            if (string.IsNullOrEmpty(str))
                                ea.SetCellValue("", GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                            else
                                ea.SetCellValue("'" + str, GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0])) {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = xx.Name;

                            } else {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = xx.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                            }

                            LockExcel(wb, xx);
                            return;
                        }
                        ea.SetCellValue("'" + str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                            str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])),
                            GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0])) {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                            str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;

                        } else {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                            str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                        }
                        str = str.Substring(help.GetFristLen(str, arrCellCount[0]) >= str.IndexOf("\r\n") &&
                            str.IndexOf("\r\n") != -1 ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                        i++;
                    }
                    str = help.GetPlitString(str, arrCellCount[1]);
                    FillMutilRows(ea, i, lp, str, arrCellCount, arrCellpos);

                }
                if (lp.CellName == "单位") {
                    IList list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select OrgCode  from mOrg where OrgName='" + str + "'");
                    if (list.Count > 0) {
                        switch (kind) {

                            case "电力线路第一种工作票":
                            case "yzgzp":
                                strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                                break;
                            case "电力线路第二种工作票":
                            case "ezgzp":
                                strNumber = "08" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                                break;
                            case "电力线路倒闸操作票":
                            case "dzczp":
                                strNumber = "BJ" + System.DateTime.Now.Year.ToString();
                                break;
                            case "电力线路事故应急抢修单":
                            case "xlqxp":
                                strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString();
                                break;
                            default:
                                strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                                break;
                        }
                        IList<LP_Record> listLPRecord = ClientHelper.PlatformSqlMap.GetList<LP_Record>("SelectLP_RecordList", " where kind = '" + kind + "' and number like '" + strNumber + "%'");
                        if (kind == "yzgzp") {
                            strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0') + "-1";
                        } else {
                            strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0');
                        }
                        if (ctrlNumber != null) {
                            ctrlNumber.Text = strNumber;

                        }
                        if (currRecord != null) currRecord.OrgName = str;
                        //ContentChanged(ctrlNumber);
                    }

                }

                LockExcel(wb, xx);
            } catch { }
        }
Пример #2
0
        private void GetFileList(DSOFramerControl ds1, string strCurDir)
        {

            DirectoryInfo dir;
            ///针对当前目录建立目录引用对象
            DirectoryInfo dirInfo = new DirectoryInfo(strCurDir);
            foreach (FileSystemInfo fsi in dirInfo.GetFileSystemInfos())
            {
                if (fsi is FileInfo)
                {

                    if (fsi.Extension.IndexOf(".xls") < 0) continue;
                    string filename = fsi.FullName;
                    ds1.FileOpen(filename);
                    IList<LP_Temple> templeList = new List<LP_Temple>();
                    LP_Temple parentTemple = MainHelper.PlatformSqlMap.GetOne<LP_Temple>("where ParentID not in (select LPID from LP_Temple where 1=1 and  CtrlSize!='目录') and  CellName like '%安规电子档案%'");
                    if (parentTemple != null) templeList = MainHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList",
                        "where ParentID ='" + parentTemple.LPID + "' order by SortID");
                    Excel.Worksheet xx = null;
                    Excel.Workbook wb = ds1.AxFramerControl.ActiveDocument as Excel.Workbook;
                    Excel.Worksheet sheet = wb.Application.Sheets[1] as Excel.Worksheet;
                    PJ_ryda currRecord = new PJ_ryda();
                    currRecord.CreateDate = DateTime.Now;
                    currRecord.BigData = ds1.FileDataGzip;
                    Excel.Range range;
                    WF_TableFieldValue wfv;
                    int i = 0;

                    foreach (LP_Temple lp in templeList)
                    {
                        string[] arrCellPos = lp.CellPos.Split('|');
                        arrCellPos = StringHelper.ReplaceEmpty(arrCellPos).Split('|');
                        if (lp.CtrlType.Contains("uc_gridcontrol"))
                        {
                            if (lp.CellName.IndexOf("培训情况") > -1)
                            {
                                for (i = 0; i < 6; i++)
                                {
                                    range = sheet.get_Range(sheet.Cells[11 + i, 1], sheet.Cells[11 + i, 1]);//坐标
                                    if (range.Value2 != null && range.Value2.ToString() != "")
                                    {
                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "培训时间1";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        if (wfv.ControlValue != "" && wfv.FieldName.IndexOf("时间") > 0)
                                        {
                                            wfv.ControlValue = range.Value2.ToString().Replace(".", "-");
                                            DateTime dt = Convert.ToDateTime(wfv.ControlValue);
                                            wfv.ControlValue = dt.ToString("yyyy年MM月dd日");
                                        }
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);

                                        Thread.Sleep(new TimeSpan(100000));//0.1毫秒

                                        range = sheet.get_Range(sheet.Cells[11 + i, 2], sheet.Cells[11 + i, 2]);//坐标
                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[1])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[1])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "培训类别1";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                                    }

                                    Thread.Sleep(new TimeSpan(100000));//0.1毫秒

                                    range = sheet.get_Range(sheet.Cells[11 + i, 3], sheet.Cells[11 + i, 3]);//坐标
                                    if (range.Value2 != null && range.Value2.ToString() != "")
                                    {
                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[2])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[2])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "培训时间2";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        if (wfv.ControlValue != "" && wfv.FieldName.IndexOf("时间") > 0)
                                        {
                                            wfv.ControlValue = range.Value2.ToString().Replace(".", "-");
                                            DateTime dt = Convert.ToDateTime(wfv.ControlValue);
                                            wfv.ControlValue = dt.ToString("yyyy年MM月dd日");
                                        }

                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                                        Thread.Sleep(new TimeSpan(100000));//0.1毫秒

                                        range = sheet.get_Range(sheet.Cells[11 + i, 4], sheet.Cells[11 + i, 4]);//坐标
                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[3])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[3])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "培训类别2";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                                    }
                                }
                            }
                            else if (lp.CellName.IndexOf("考试情况") > -1)
                            {
                                for (i = 0; i < 12; i++)
                                {
                                    range = sheet.get_Range(sheet.Cells[19 + i, 1], sheet.Cells[19 + i, 1]);//坐标
                                    if (range.Value2 != null && range.Value2.ToString() != "")
                                    {

                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "考试时间";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        if (wfv.ControlValue != "" && wfv.FieldName.IndexOf("时间") > 0)
                                        {
                                            wfv.ControlValue = range.Value2.ToString().Replace(".", "-");
                                            DateTime dt = Convert.ToDateTime(wfv.ControlValue);
                                            wfv.ControlValue = dt.ToString("yyyy年MM月dd日");
                                        }
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                                        Thread.Sleep(new TimeSpan(100000));//0.1毫秒

                                        range = sheet.get_Range(sheet.Cells[19 + i, 2], sheet.Cells[19 + i, 2]);//坐标
                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[1])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[1])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "考试类别";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);


                                        Thread.Sleep(new TimeSpan(100000));//0.1毫秒

                                        range = sheet.get_Range(sheet.Cells[19 + i, 3], sheet.Cells[19 + i, 3]);//坐标

                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[2])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[2])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "考试成绩";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);

                                        Thread.Sleep(new TimeSpan(100000));//0.1毫秒

                                        range = sheet.get_Range(sheet.Cells[19 + i, 4], sheet.Cells[19 + i, 4]);//坐标
                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[3])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[3])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "考试评价";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);

                                        Thread.Sleep(new TimeSpan(100000));//0.1毫秒

                                        range = sheet.get_Range(sheet.Cells[19 + i, 5], sheet.Cells[19 + i, 5]);//坐标
                                        wfv = new WF_TableFieldValue();
                                        wfv.ID = wfv.CreateID();
                                        wfv.RecordId = currRecord.ID;
                                        wfv.WorkFlowId = currRecord.ID;
                                        wfv.WorkFlowInsId = currRecord.wdmc;
                                        wfv.WorkTaskId = "安规电子档案";
                                        wfv.WorkTaskInsId = "安规电子档案";
                                        wfv.UserControlId = parentTemple.LPID;
                                        wfv.XExcelPos = GetCellPos(arrCellPos[4])[0];
                                        wfv.YExcelPos = GetCellPos(arrCellPos[4])[1];
                                        wfv.FieldId = lp.LPID;
                                        wfv.FieldName = lp.CellName + "-" + "年检情况";
                                        wfv.ExcelSheetName = lp.KindTable;
                                        if (range.Value2 != null)
                                            wfv.ControlValue = range.Value2.ToString();
                                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                                    }

                                }
                            }
                        }
                        else
                        {
                            range = sheet.get_Range(sheet.Cells[GetCellPos(arrCellPos[0])[0], GetCellPos(arrCellPos[0])[1]], sheet.Cells[GetCellPos(arrCellPos[0])[0], GetCellPos(arrCellPos[0])[1]]);//坐标
                            wfv = new WF_TableFieldValue();
                            wfv.ID = wfv.CreateID();
                            wfv.RecordId = currRecord.ID;
                            wfv.WorkFlowId = currRecord.ID;
                            wfv.WorkFlowInsId = currRecord.wdmc;
                            wfv.WorkTaskId = "安规电子档案";
                            wfv.WorkTaskInsId = "安规电子档案";
                            wfv.UserControlId = parentTemple.LPID;
                            wfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                            wfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                            wfv.FieldId = lp.LPID;
                            wfv.FieldName = lp.CellName;
                            wfv.ExcelSheetName = lp.KindTable;
                            if (range.Value2 != null)
                                wfv.ControlValue = range.Value2.ToString();
                            if (wfv.ControlValue != "" && lp.CellName == "出生年月日")
                            {
                                wfv.ControlValue = range.Value2.ToString().Replace(".", "-");
                                DateTime dt = Convert.ToDateTime(wfv.ControlValue);
                                wfv.ControlValue = dt.ToString("yyyy年MM月dd日");
                            }
                            if (wfv.ControlValue != "" && lp.CellName == "参加工作时间")
                            {
                                try
                                {
                                    wfv.ControlValue = range.Value2.ToString().Replace(".", "-");
                                    DateTime dt = Convert.ToDateTime(wfv.ControlValue);

                                    wfv.ControlValue = dt.ToString("yyyy年MM月dd日");
                                }
                                catch
                                {
                                    DateTime dt = new DateTime(Convert.ToInt32(wfv.ControlValue));

                                    wfv.ControlValue = dt.ToString("yyyy年MM月dd日");
                                }
                            }
                            if (lp.CellName == "姓名")
                            {
                                currRecord.wdmc = wfv.ControlValue;
                            }
                            else if (lp.CellName == "职务")
                            {
                                currRecord.wdlx = wfv.ControlValue;
                            }
                            else if (lp.CellName == "所在单位")
                            {
                                currRecord.OrgName = wfv.ControlValue.Replace(MainHelper.UserCompany, "");
                                mOrg org = MainHelper.PlatformSqlMap.GetOne<mOrg>("where OrgName='" + currRecord.OrgName + "'");
                                if (org != null)
                                {
                                    currRecord.OrgCode = org.OrgCode;
                                }
                            }
                            wfv.WorkFlowInsId = currRecord.wdmc;
                            MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                            Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                        }
                    }
                    currRecord.CreateMan = MainHelper.User.UserName;
                    MainHelper.PlatformSqlMap.Create<PJ_ryda>(currRecord);
                    ds1.FileSave();
                    ds1.FileClose();
                }
                else
                {
                    dir = (DirectoryInfo)fsi;






                    //获取文件夹路径
                    GetFileList(ds1, strCurDir + "\\" + dir.Name);


                }
            }
        }
Пример #3
0
        void ContentChanged(Control ctrl) {
            LP_Temple lp = (LP_Temple)ctrl.Tag;
            string str = ctrl.Text;
            if (dsoFramerWordControl1.MyExcel == null) {
                return;
            }
            //Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            //Excel.Worksheet sheet;
            ExcelAccess ea = new ExcelAccess();
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            if (lp.KindTable != "" && activeSheetName != lp.KindTable) {
                if (lp.KindTable != "") {
                    activeSheetName = lp.KindTable;
                    sheet = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet;
                    activeSheetIndex = sheet.Index;
                } else {

                    sheet = wb.Application.Sheets[1] as Excel.Worksheet;
                    activeSheetIndex = sheet.Index;
                    activeSheetName = sheet.Name;
                }
            }
            ea.ActiveSheet(activeSheetIndex);
            unLockExcel(wb, sheet);
            if (lp.CtrlType.Contains("uc_gridcontrol")) { FillTable(ea, lp, (ctrl as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar)))); return; } else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit")) {
                FillTime(ea, lp, (ctrl as DateEdit).DateTime);
                return;
            }
            string[] arrCellpos = lp.CellPos.Split(pchar);
            string[] arrtemp = lp.WordCount.Split(pchar);
            arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar);
            arrtemp = StringHelper.ReplaceEmpty(arrtemp).Split(pchar);
            List<int> arrCellCount = String2Int(arrtemp);
            if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1])) {
                ea.SetCellValue("'" + str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                if (valuehs.ContainsKey(lp.LPID + "$" + lp.CellPos)) {
                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + lp.CellPos] as WF_TableFieldValue;
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];

                } else {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    valuehs.Add(lp.LPID + "$" + lp.CellPos, tfv);
                }
            } else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1]))) {

                StringHelper help = new StringHelper();
                if (lp.CellName == "编号") {
                    for (int j = 0; j < arrCellpos.Length; j++) {
                        if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[j])) {
                            string strNew = str.Substring(0, (str.Length > 0 ? str.Length : 1) - 1) + (j + 1).ToString();
                            ea.SetCellValue("'" + strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]);
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[j])) {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[j]] as WF_TableFieldValue;
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = sheet.Name;
                            } else {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = sheet.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[j], tfv);
                            }
                        }
                    }
                    return;
                }
                int i = 0;
                if (arrCellCount[0] != arrCellCount[1]) {
                    if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[0])) {
                        ea.SetCellValue("'" + str, GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0])) {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = sheet.Name;

                        } else {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = sheet.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                        }
                        return;
                    }
                    ea.SetCellValue("'" + str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])),
                        GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0])) {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                        tfv.ControlValue = str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = sheet.Name;

                    } else {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = sheet.Name;
                        valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                    }

                    str = str.Substring(help.GetFristLen(str, arrCellCount[0]) >= str.IndexOf("\r\n") &&
                        str.IndexOf("\r\n") != -1 ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                    i++;
                }
                str = help.GetPlitString(str, arrCellCount[1]);
                FillMutilRows(ea, i, lp, str, arrCellCount, arrCellpos);

            }
            LockExcel(wb, sheet);
        }
Пример #4
0
        private void LPFrm_Load(object sender, EventArgs e) {
            if (tempCtrlList == null) {
                tempCtrlList = new List<Control>();
            }
            //InitializeComponent();
            if (valuehs == null)
                valuehs = new Hashtable();
            //InitIndex();            
            //InitContorl();
            Excel.Workbook wb;
            Excel.Worksheet sheet;
            ExcelAccess ea = new ExcelAccess();
            //Regex r1 = new Regex(@"(?<=" + CurrRecord.Status + ":)([^,]+)((?=,)?)");
            //if (r1.Match(parentTemple.KindTable).Value != "")
            //{
            //    activeSheetName = r1.Match(parentTemple.KindTable).Value;
            //}
            //int istart = parentTemple.KindTable.IndexOf(CurrRecord.Status + ":") + CurrRecord.Status.Length + 1;
            //int iend = parentTemple.KindTable.IndexOf(",", istart);
            //if (iend > -1)
            //    activeSheetName = parentTemple.KindTable.Substring(istart, iend);
            //else
            //    activeSheetName = parentTemple.KindTable.Substring(istart);

            WF_TableFieldValue wfv = null;
            if (parentTemple != null) {
                LP_Temple lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where  ParentID='" + parentTemple.LPID + "' and SortID=1");
                if (lp != null) {

                    wfv = new WF_TableFieldValue();
                    wfv.ID = wfv.CreateID();
                    wfv.RecordId = currRecord.ID;
                    wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                    wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                    wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                    wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                    wfv.UserControlId = parentTemple.LPID;
                    wfv.ControlValue = "";
                    wfv.FieldId = lp.LPID;
                    wfv.FieldName = lp.CellName;
                    //wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    //wfv.YExcelPos = GetCellPos(lp.CellPos)[1];


                    wfv = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                     + " and   WorkflowId='" + wfv.WorkFlowId + "'"
                                     + " and   RecordId='" + wfv.RecordId + "'"
                                     + " and   UserControlId='" + wfv.UserControlId + "'"
                                     + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
                                     + " and   fieldname='" + lp.CellName + "'"
                                     + " and   FieldId='" + lp.LPID + "' and Bigdata is not null"
                                    );

                }
            }
            if (wfv != null && wfv.Bigdata != null && wfv.Bigdata.Length > 0) {
                this.dsoFramerWordControl1.FileDataGzip = wfv.Bigdata;
            } else {
                if (currRecord.DocContent == null) {
                    currRecord.DocContent = new byte[0];
                }
                //InitContorl();
                if (currRecord.ID.IndexOf("N") == -1) {
                    if (GetWorkFlowNmae(kind).IndexOf("电力线路") > -1 && currRecord.DocContent != null && currRecord.DocContent.Length > 0) this.dsoFramerWordControl1.FileDataGzip = currRecord.DocContent;
                    else
                        this.dsoFramerWordControl1.FileDataGzip = currRecord.DocContent;
                } else {
                    if (currRecord.DocContent.Length > 0) this.dsoFramerWordControl1.FileDataGzip = currRecord.DocContent;
                    else if (parentTemple != null) this.dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent;
                }
            }

            //if (GetWorkFlowNmae(kind).IndexOf("电力线路") > -1)
            //{

            //    this.dsoFramerWordControl1.FileDataGzip = currRecord.DocContent;

            //}


            //LoadContent();

            //if ((parentTemple != null && parentTemple.DocContent != null) || (currRecord!=null&&currRecord.DocContent != null && currRecord.DocContent.Length > 0))
            //{
            //    wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;

            //    //sheet = wb.Application.Sheets[activeSheetName] as Excel.Worksheet;



            //    //activeSheetIndex = sheet.Index;
            //        for (int i = 1; i <= wb.Application.Sheets.Count; i++)
            //        {
            //            sheet = wb.Application.Sheets[i] as Excel.Worksheet;
            //             //保护工作表
            //             LockExcel(wb, sheet);
            //            //if (i != activeSheetIndex)
            //            //{
            //            //    Excel.Worksheet tmpSheet = (Excel.Worksheet)wb.Application.Sheets.get_Item(i);
            //            //    try
            //            //    {
            //            //        if (tmpSheet != null) tmpSheet.Visible = Excel.XlSheetVisibility.xlSheetHidden;

            //            //    }
            //            //    catch { }

            //       }

            //   }
            //保护工作表
            //    LockExcel(wb,sheet);
            //}
        }
Пример #5
0
        void ctrl_Leave(object sender, EventArgs e)
        {
             
            
            LP_Temple lp = (LP_Temple)(sender as Control).Tag;
            string str = (sender as Control).Text;
            if (dsoFramerWordControl1.MyExcel==null)
            {
                return;
            }
            Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            ExcelAccess ea = new ExcelAccess();
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            Excel.Worksheet xx;
            if (lp.KindTable != "")
            {
                activeSheetName = lp.KindTable;
                xx = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet;
                activeSheetIndex = xx.Index;
            }
            else
            {
                xx = wb.Application.Sheets[1] as Excel.Worksheet;
                activeSheetIndex = xx.Index;
                activeSheetName = xx.Name;
            }
            if (lp.KindTable != "")
            {
                ea.ActiveSheet(lp.KindTable);
            }
            else
            {
                ea.ActiveSheet(1);
            }

            if (lp.CellPos == "")
            {
                lp.CellPos = lp.CellPos;
                if (valuehs.ContainsKey(lp.LPID))
                {
                    WF_TableFieldValue tfv = valuehs[lp.LPID] as WF_TableFieldValue;
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = -1;
                    tfv.YExcelPos = -1;

                }
                else
                {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = -1;
                    tfv.YExcelPos = -1;
                    tfv.ExcelSheetName = xx.Name;

                    valuehs.Add(lp.LPID, tfv);
                }
                return;
            }
            unLockExcel(wb,xx);
            if (lp.CtrlType.Contains("uc_gridcontrol"))
            { 
                FillTable(ea, lp, (sender as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar))));
                LockExcel(wb, xx);
                return; 
            }
            else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit"))
            { 
                FillTime(ea, lp, (sender as DateEdit).DateTime);
                LockExcel(wb, xx);
                return;
            }            
            string[] arrCellpos = lp.CellPos.Split(pchar);
            string[] arrtemp = lp.WordCount.Split(pchar);
            arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar);
            string[] extraWord = lp.ExtraWord.Split(pchar);  
            List<int> arrCellCount = String2Int(arrtemp);
            if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1]))
            {
                ea.SetCellValue(str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                if (valuehs.ContainsKey(lp.LPID + "$" + lp.CellPos))
                {
                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + lp.CellPos] as WF_TableFieldValue;
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    tfv.ExcelSheetName = xx.Name;

                }
                else
                {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    tfv.ExcelSheetName = xx.Name;
                    valuehs.Add(lp.LPID + "$" + lp.CellPos, tfv);
                }

            }
            else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1])))
            {
                StringHelper help = new StringHelper();
                if (lp.CellName == "编号")
                {
                    for (int j = 0; j < arrCellpos.Length; j++)
                    {
                        if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[j]) && str != "")
                        {
                            string strNew = str.Substring(0, str.Length - 1) + (j + 1).ToString();
                            ea.SetCellValue(strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]);
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[j]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[j]] as WF_TableFieldValue;
                                tfv.ControlValue = strNew;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = xx.Name;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = strNew;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = xx.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[j], tfv);
                            }
                        }
                    }
                    LockExcel(wb, xx);
                    return;
                }
                int i = 0;
                if (arrCellCount[0] != arrCellCount[1])
                {
                    if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[0]))
                    {
                        ea.SetCellValue(str, GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;

                        }
                        else
                        {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                        }

                        LockExcel(wb, xx);
                        return;
                    }
                    ea.SetCellValue(str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])),
                        GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                    {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                        tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = xx.Name;

                    }
                    else
                    {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = xx.Name;
                        valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                    }
                    str = str.Substring(help.GetFristLen(str, arrCellCount[0]) >= str.IndexOf("\r\n") &&
                        str.IndexOf("\r\n") != -1 ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                    i++;
                }
                str = help.GetPlitString(str, arrCellCount[1]);
                FillMutilRows(ea, i, lp, str, arrCellCount, arrCellpos);

            }
            if (lp.CellName == "单位")
            {
                IList list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select OrgCode  from mOrg where OrgName='" + str + "'");
                if (list.Count > 0)
                {
                    switch (kind)
                    {

                        case "电力线路第一种工作票":
                        case "yzgzp":
                            strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                            break;
                        case "电力线路第二种工作票":
                        case "ezgzp":
                            strNumber = "08" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                            break;
                        case "电力线路倒闸操作票":
                        case "dzczp":
                            strNumber = "BJ" + System.DateTime.Now.Year.ToString();
                            break;
                        case "电力线路事故应急抢修单":
                        case "xlqxp":
                            strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString();
                            break;
                        default:
                            strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                            break;
                    }
                    IList<LP_Record> listLPRecord = ClientHelper.PlatformSqlMap.GetList<LP_Record>("SelectLP_RecordList", " where kind = '" + kind + "' and number like '" + strNumber + "%'");
                    if (kind == "yzgzp")
                    {
                        strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0') + "-1";
                    }
                    else
                    {
                        strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0');
                    }
                    if (ctrlNumber != null)
                    {
                        ctrlNumber.Text = strNumber;
                        currRecord.Number = ctrlNumber.Text;
                    }
                    if (currRecord!=null) currRecord.OrgName = str;
                    //ContentChanged(ctrlNumber);
                }

            }

            LockExcel(wb, xx);
        }
Пример #6
0
        private void LPFrm_Load(object sender, EventArgs e) {
            if (tempCtrlList == null) {
                tempCtrlList = new List<Control>();
            }
            this.Text = "20低压线路完好率及台区网络图";
            //InitializeComponent();
            if (valuehs == null)
                valuehs = new Hashtable();

            ExcelAccess ea = new ExcelAccess();
            WF_TableFieldValue wfv = null;
            parentTemple = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where ( ParentID not in (select LPID from LP_Temple where 1=1 and  CtrlSize!='目录') and  CtrlSize!='目录' ) and  CellName like '%低压线路完好率及台区网络图%'");
            LP_Temple lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where  ParentID='" + parentTemple.LPID + "' and SortID=1");
            currRecord = rowData;
            if (lp != null) {
                if (wfv == null) {
                    wfv = new WF_TableFieldValue();
                    wfv.ID = wfv.CreateID();
                    wfv.RecordId = currRecord.ID;
                    wfv.WorkFlowId = currRecord.tqCode;
                    wfv.WorkFlowInsId = currRecord.tqName;
                    wfv.WorkTaskId = "20低压设备完好率及台区网络图";
                    wfv.WorkTaskInsId = "20低压设备完好率及台区网络图";
                    wfv.UserControlId = parentTemple.LPID;
                    wfv.ControlValue = "";
                    wfv.FieldId = lp.LPID;
                    wfv.FieldName = lp.CellName;
                    wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                }

                wfv = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                 + " and   WorkflowId='" + wfv.WorkFlowId + "'"
                                 + " and   RecordId='" + wfv.RecordId + "'"
                                 + " and   UserControlId='" + wfv.UserControlId + "'"
                                 + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
                                 + " and   fieldname='" + lp.CellName + "'"
                                 + " and   FieldId='" + lp.LPID + "' and Bigdata is not null"
                                );

            }
            if (parentTemple == null) {
                MsgBox.ShowWarningMessageBox("没有找到表单20低压线路完好率及台区网络图!");
                return;
            }
            //if (currRecord.BigData == null || currRecord.BigData.Length == 0)
            {
                if (status != "edit" || wfv == null || wfv.Bigdata == null || wfv.Bigdata.Length == 0) {
                    this.dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent;
                } else {
                    this.dsoFramerWordControl1.FileDataGzip = wfv.Bigdata;
                }
            }
            //else
            //{

            //    this.dsoFramerWordControl1.FileDataGzip = currRecord.BigData;
            //}
            wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            xx = wb.ActiveSheet as Excel.Worksheet;
            sheet = xx;
            activeSheetName = xx.Name;

            InitIndex();
            InitContorl();
            InitData();

            if (status == "edit") {
                IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList",
                 " where RecordId='" + currRecord.ID + "' and UserControlId='" + parentTemple.LPID + "' and   WorkflowId='" + currRecord.tqCode + "' and WorkFlowInsId='" + currRecord.tqName + "' ");

                //wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
                //ea.MyWorkBook = wb;
                //ea.MyExcel = wb.Application;

                //xx = wb.Application.Sheets[1] as Excel.Worksheet;
                int i = 0;

                for (i = 0; i < tfvli.Count; i++) {
                    Control ctl = FindCtrl(tfvli[i].FieldId);
                    if (ctl != null) {
                        //ctl.Text = tfvli[i].ControlValue;
                        //ctl.Focus();
                        lp = ctl.Tag as LP_Temple;
                        if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit") == false) {
                            if (lp.CellName != "编号" && lp.CellName.IndexOf("低压线路") == -1
                                 && lp.CellName.IndexOf("最大供电半径") == -1
                                 && lp.CellName.IndexOf("低压杆基数") == -1
                                 && lp.CellName.IndexOf("表箱数") == -1
                                 && lp.CellName.IndexOf("四线的一类") == -1
                                 && lp.CellName.IndexOf("四线的二类") == -1
                                 && lp.CellName.IndexOf("四线的三类") == -1
                                 && lp.CellName.IndexOf("二线的一类") == -1
                                 && lp.CellName.IndexOf("二线的二类") == -1
                                 && lp.CellName.IndexOf("二线的三类") == -1
                                ) {
                                if (ctl.Text.IndexOf(tfvli[i].ControlValue) == -1)
                                    ctl.Text += tfvli[i].ControlValue;
                            } else {
                                ctl.Text = tfvli[i].ControlValue;
                            }
                            ctl.Focus();
                        } else {
                            IList<WF_TableFieldValue> tfvlitemp = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList",
                        " where RecordId='" + currRecord.ID + "' and UserControlId='" + parentTemple.LPID + "'   and FieldId='" + tfvli[i].FieldId.ToString() + "' and FieldName='" + tfvli[i].FieldName + "完整时间' order by id desc, YExcelPos,XExcelPos");
                            if (tfvlitemp.Count > 0) {
                                ((DevExpress.XtraEditors.DateEdit)ctl).DateTime = Convert.ToDateTime(tfvlitemp[0].ControlValue);
                            }
                            //((DevExpress.XtraEditors.DateEdit)ctl).DateTime = Convert.ToDateTime(tfvli[i].ControlValue);
                        }
                    }
                }
                dsoFramerWordControl1.FileSave();
            }
        }
Пример #7
0
        void btn_Submit_Click(object sender, EventArgs e) {
            //Excel.Workbook wb;
            //Excel.Worksheet sheet;
            dsoFramerWordControl1.FileSave();
            //currRecord.BigData = this.dsoFramerWordControl1.FileDataGzip;
            //wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            //if (activeSheetName != "")
            //{
            //    sheet = wb.Application.Sheets[activeSheetName] as Excel.Worksheet;
            //}
            //else
            //{
            //    sheet = wb.Application.Sheets[1] as Excel.Worksheet;
            //}
            //activeSheetIndex = sheet.Index;

            //for (int i = 1; i <= wb.Application.Sheets.Count; i++)
            //{
            //    if (i != activeSheetIndex)
            //    {
            //        Excel.Worksheet tmpSheet = (Excel.Worksheet)wb.Application.Sheets.get_Item(i);
            //        try
            //        {
            //            if (tmpSheet != null) tmpSheet.Visible = Excel.XlSheetVisibility.xlSheetVisible ;
            //        }
            //        catch { }

            //    }
            //}
            //unLockExcel(wb,sheet);
            //for (int i = 1; sheet.Protection.AllowEditRanges.Count > 0; )
            //{
            //    Excel.AllowEditRange editRange = sheet.Protection.AllowEditRanges.get_Item(i);
            //    editRange.Delete();
            //}
            //LockExcel(wb, sheet);
            byte[] bt = new byte[0];
            string strmes = "";
            WF_WorkTaskCommands wt;
            WF_TableFieldValue wfv = null;
            LP_Temple lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>("where ParentID='" + parentTemple.LPID + "' and  CellName like '%说明%'");
            Control ctl = FindCtrl(lp.LPID);
            if (ctl != null) {
                currRecord.Remark = ctl.Text;
            }
            //rowData = null;
            ArrayList akeys = new ArrayList(valuehs.Keys);
            List<object> list = new List<object>();
            for (int i = 0; i < akeys.Count; i++) {
                wfv = valuehs[akeys[i]] as WF_TableFieldValue;
                wfv.ID = wfv.CreateID();
                wfv.RecordId = currRecord.ID;
                wfv.WorkFlowId = currRecord.tqCode;
                wfv.WorkFlowInsId = currRecord.tqName;
                wfv.WorkTaskId = "20低压设备完好率及台区网络图";
                wfv.WorkTaskInsId = "20低压设备完好率及台区网络图";
                wfv.UserControlId = parentTemple.LPID;
                Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                list.Add(wfv);
                for (int j = 0; j < templeList.Count; j++) {
                    if (templeList[j].LPID == wfv.FieldId) {
                        templeList.RemoveAt(j);
                        break;
                    }
                }
            }
            Control ct = null;
            for (int i = 0; i < templeList.Count; i++) {
                wfv = new WF_TableFieldValue();
                wfv.ExcelSheetName = templeList[i].KindTable;
                if (templeList[i].CellPos != "") {
                    wfv.XExcelPos = GetCellPos(templeList[i].CellPos)[0];
                    wfv.YExcelPos = GetCellPos(templeList[i].CellPos)[1];
                } else {

                    wfv.XExcelPos = -1;
                    wfv.YExcelPos = -1;
                }
                wfv.FieldId = templeList[i].LPID;
                wfv.FieldName = templeList[i].CellName;
                ct = FindCtrl(templeList[i].LPID);
                if (ct != null)
                    wfv.ControlValue = ct.Text;

                wfv.ID = wfv.CreateID();
                wfv.RecordId = currRecord.ID;
                wfv.WorkFlowId = currRecord.tqCode;
                wfv.WorkFlowInsId = currRecord.tqName;
                wfv.WorkTaskId = "20低压设备完好率及台区网络图";
                wfv.WorkTaskInsId = "20低压设备完好率及台区网络图";
                wfv.UserControlId = parentTemple.LPID;
                Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                list.Add(wfv);
            }
            MainHelper.PlatformSqlMap.DeleteByWhere<WF_TableFieldValue>(" where RecordId ='" + currRecord.ID + "' and WorkTaskInsId='20低压设备完好率及台区网络图' ");
            lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where  ParentID='" + parentTemple.LPID + "' and SortID=1");
            //if (lp != null)
            //{
            //    if (wfv == null)
            //    {
            //        wfv = new WF_TableFieldValue();
            //        wfv.ID = wfv.CreateID();
            //        wfv.RecordId = currRecord.ID;
            //        wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
            //        wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
            //        wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
            //        wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
            //        wfv.UserControlId = parentTemple.LPID;
            //        wfv.ControlValue = "";
            //        wfv.FieldId = lp.LPID;
            //        wfv.FieldName = lp.CellName;
            //        wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
            //        wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
            //        wfv.ExcelSheetName = activeSheetName;
            //    }

            //    wfv = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
            //                     + " and   WorkflowId='" + wfv.WorkFlowId + "'"
            //                     + " and   RecordId='" + wfv.RecordId + "'"
            //                     + " and   UserControlId='" + wfv.UserControlId + "'"
            //                     + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
            //                     + " and   fieldname='" + lp.CellName + "'"
            //                     + " and   FieldId='" + lp.LPID + "' and Bigdata is not null"
            //                    );


            //    if (wfv == null)
            //    {
            //        wfv = new WF_TableFieldValue();
            //        wfv.ID = wfv.CreateID();
            //        wfv.RecordId = currRecord.ID;
            //        wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
            //        wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
            //        wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
            //        wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
            //        wfv.UserControlId = parentTemple.LPID;
            //        wfv.ControlValue = "";
            //        wfv.FieldId = lp.LPID;
            //        wfv.FieldName = lp.CellName;
            //        wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
            //        wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
            //        wfv.ExcelSheetName = activeSheetName;
            //        wfv.Bigdata = currRecord.BigData;
            //        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
            //    }
            //    else
            //    {
            //        wfv.Bigdata = currRecord.BigData;
            //        MainHelper.PlatformSqlMap.Update<WF_TableFieldValue>(wfv);

            //    }
            //}
            dsoFramerWordControl1.FileSave();
            currRecord.BigData = dsoFramerWordControl1.FileDataGzip;
            if (currRecord.ParentID == "") {
                currRecord.ParentID = currRecord.tqCode.Substring(0, 3);
            }
            if (currRecord.OrgName == "") {
                mOrg org = MainHelper.PlatformSqlMap.GetOne<mOrg>("where orgcode='" + currRecord.ParentID + "'");
                if (org != null) {
                    currRecord.OrgName = org.OrgName;
                    currRecord.OrgCode = org.OrgCode;
                }
            }
            switch (status) {
                case "add":

                    if (list.Count > 0) {
                        foreach (WF_TableFieldValue wfv2 in list) {

                            if (wfv2.FieldId == lp.LPID) {
                                wfv2.Bigdata = currRecord.BigData;
                                break;
                            }

                        }
                        Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(list, null, null);
                    }
                    if (currRecord.BigData == null) {
                        currRecord.BigData = new byte[0];
                    }
                    Client.ClientHelper.PlatformSqlMap.Create<PJ_20>(currRecord);
                    break;

                case "edit":

                    if (list.Count > 0) {
                        foreach (WF_TableFieldValue wfv2 in list) {
                            WF_TableFieldValue wtfvtemp = Client.ClientHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                 + " and   WorkflowId='" + wfv2.WorkFlowId + "'"
                                 + " and   RecordId='" + wfv2.RecordId + "'"
                                 + " and   UserControlId='" + wfv2.UserControlId + "'"
                                 + " and   WorkFlowInsId='" + wfv2.WorkFlowInsId + "'"
                                 + " and   FieldId='" + wfv2.FieldId + "'"
                                 + " and   XExcelPos='" + wfv2.XExcelPos + "'"
                                 + " and   YExcelPos='" + wfv2.YExcelPos + "'"
                                 + " and WorkTaskInsId='20低压设备完好率及台区网络图'");
                            if (wfv2.FieldId == lp.LPID) {
                                wfv2.Bigdata = currRecord.BigData;
                            }
                            if (wtfvtemp != null)
                                wfv2.ID = wtfvtemp.ID;
                            else {
                                MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv2);
                            }
                        }
                        Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(null, list, null);
                    }
                    if (currRecord.BigData == null) {
                        currRecord.BigData = new byte[0];
                    }
                    Client.ClientHelper.PlatformSqlMap.Update<PJ_20>(currRecord);
                    break;
            }
            PS_tq tq = Client.ClientHelper.PlatformSqlMap.GetOne<PS_tq>(" where tqName='" + currRecord.tqName + "'");
            int idw = 1;
            string valEX = @"[0-9]+(\.)?[0-9]+";//只允许整数或小数的正则表达式

            templeList = MainHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList",
                           "where ParentID ='" + parentTemple.LPID + "' order by SortID");
            foreach (LP_Temple lp2 in templeList) {
                if ((lp2.CellName.IndexOf("补偿电容") > -1 || lp2.CellName.IndexOf("电动机") > -1 || lp2.CellName.Trim().IndexOf("机井") > -1
                    || lp2.CellName.IndexOf("农副业") > -1 || lp2.CellName.IndexOf("照明户数") > -1
                    || lp2.CellName.IndexOf("单相表数") > -1 || lp2.CellName.IndexOf("三相表数") > -1) == false) {
                    continue;
                }

                IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList",
                                " where   UserControlId='" + parentTemple.LPID + "'  and WorkTaskInsId='20低压设备完好率及台区网络图'"
                                + " and  FieldId='" + lp2.LPID + "' and ( WorkflowId='" + tq.tqCode + "') "
                                + " order by YExcelPos");
                object obj = null;
                double sum = 0;
                string value = "";
                foreach (WF_TableFieldValue tfv in tfvli) {
                    WF_TableFieldValue tfvtemp = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(
                                  " where   UserControlId='" + parentTemple.LPID + "'"
                                  + " and   WorkflowId='" + tfv.WorkFlowId + "'"
                                  + " and   RecordId='" + tfv.RecordId + "'"
                                  + " and   FieldName='类型'"
                                  + " and WorkTaskInsId='20低压设备完好率及台区网络图'"
                                  + " order by YExcelPos");
                    if (tfvtemp != null && tfvtemp.ControlValue == "新增")
                        idw = 1;
                    else
                        if (tfvtemp != null && tfvtemp.ControlValue == "减少")
                            idw = -1;
                        else
                            idw = 1;
                    if (tfv.FieldName.IndexOf("时间") == -1 && lp.IsVisible == 0) {
                        valEX = "^[0-9]+(\\.)?([0-9]+)?$";
                        if (tfv.ControlValue == "" || Regex.Match(tfv.ControlValue, valEX).Value != "") {
                            if (tfv.ControlValue == "")
                                sum += 0;
                            else
                                sum += idw * Convert.ToDouble(tfv.ControlValue);
                            value = sum.ToString();
                        } else {
                            valEX = "^[0-9]+(\\.)?([0-9]+)?/[0-9]+(\\.)?([0-9]+)?";
                            if (Regex.Match(tfv.ControlValue, valEX).Value != "") {
                                string[] str1 = tfv.ControlValue.Split('/');
                                if (value == "") {

                                    value = (idw * Convert.ToDouble(str1[0])).ToString() + "/" + (idw * Convert.ToDouble(str1[1])).ToString();
                                } else {
                                    string[] str2 = value.Split('/');
                                    sum = idw * Convert.ToDouble(str1[0]) + Convert.ToDouble(str2[0]);
                                    value = sum.ToString();

                                    if (str2.Length > 1)
                                        sum = idw * Convert.ToDouble(str1[1]) + Convert.ToDouble(str2[1]);
                                    else
                                        sum = idw * Convert.ToDouble(str1[1]);
                                    value = value + "/" + sum.ToString();
                                }
                            } else {
                                value = tfv.ControlValue;
                            }


                        }
                    } else {
                        value = tfv.ControlValue;

                    }
                }

                if (lp2.CellName.IndexOf("补偿电容") > -1) {
                    tq.bcdr = value.ToString();
                }
                if (lp2.CellName.IndexOf("电动机") > -1) {

                    tq.ddj = value.ToString();
                }
                if (lp2.CellName.Trim().IndexOf("机井") > -1) {
                    tq.jj = value.ToString();
                }
                if (lp2.CellName.IndexOf("农副业") > -1) {
                    tq.nfy = value.ToString();
                }
                if (lp2.CellName.IndexOf("照明户数") > -1) {
                    tq.zmfs = value.ToString();
                }
                if (lp2.CellName.IndexOf("单相表数") > -1) {
                    tq.dxbs = value.ToString();
                }
                if (lp2.CellName.IndexOf("三相表数") > -1) {
                    tq.sxbs = value.ToString();
                }
            }
            Client.ClientHelper.PlatformSqlMap.Update<PS_tq>(tq);
            dsoFramerWordControl1.FileClose();

            this.DialogResult = DialogResult.OK;
        }
Пример #8
0
        void ctrl_Leave(object sender, EventArgs e)
        {


            LP_Temple lp = (LP_Temple)(sender as Control).Tag;
            string str = (sender as Control).Text;
            if (dsoFramerWordControl1.MyExcel == null)
            {
                return;
            }
            Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            ExcelAccess ea = new ExcelAccess();
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            try
            {
                if (lp.KindTable != activeSheetName)
                {
                    if (lp.KindTable != "")
                    {
                        activeSheetName = lp.KindTable;
                        try
                        {
                            sheet = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet;
                        }
                        catch { sheet = wb.Application.Sheets[1] as Excel.Worksheet; }

                        activeSheetIndex = sheet.Index;
                    }
                    else
                    {
                        sheet = wb.Application.Sheets[1] as Excel.Worksheet;
                        activeSheetIndex = sheet.Index;
                        activeSheetName = sheet.Name;
                    }
                }
                if (lp.KindTable != "")
                {
                    //try {
                    //    ea.ActiveSheet(lp.KindTable);
                    //} catch { }
                }
                else
                {
                    try
                    {
                        ea.ActiveSheet(1);
                    }
                    catch { }
                }

                if (lp.CellPos == "")
                {

                    if (lp.CellName.IndexOf("简图") > -1)
                    {
                        unLockExcel(wb, sheet);
                        PJ_tbsj tb = MainHelper.PlatformSqlMap.GetOne<PJ_tbsj>("where picName = '" + str + "'");
                        if (tb != null)
                        {
                            if (tb.picName != "表箱")
                            {
                                string tempPath = Path.GetTempPath();
                                string tempfile = tempPath + "~" + Guid.NewGuid().ToString() + tb.S1;
                                FileStream fs;
                                fs = new FileStream(tempfile, FileMode.Create, FileAccess.Write);
                                BinaryWriter bw = new BinaryWriter(fs);
                                bw.Write(tb.picImage);
                                bw.Flush();
                                bw.Close();
                                fs.Close();
                                //IDataObject data = new DataObject(DataFormats.FileDrop, new string[] { tempfile });
                                //MemoryStream memo = new MemoryStream(4);
                                //byte[] bytes = new byte[] { (byte)(5), 0, 0, 0 };
                                //memo.Write(bytes, 0, bytes.Length);
                                //data.SetData("ttt", memo);
                                //Clipboard.SetDataObject(data);
                                Image im = Bitmap.FromFile(tempfile);
                                Bitmap bt = new Bitmap(im);
                                DataObject dataObject = new DataObject();
                                dataObject.SetData(DataFormats.Bitmap, bt);
                                Clipboard.SetDataObject(dataObject, true);
                            }
                            else
                            {
                                Microsoft.Office.Interop.Excel.Shape activShape = null;
                                activShape = sheet.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal,
                                    (float)153.75, (float)162.75, (float)22.5, (float)10.5);
                                activShape.TextFrame.Characters(1, 1).Font.Size = 8;
                                activShape.TextFrame.Characters(1, 1).Text = "1";
                                activShape.TextFrame.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
                                activShape.Cut();
                            }
                        }
                    }
                    else
                    {
                        if (valuehs.ContainsKey(lp.LPID))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;

                        }
                        else
                        {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;
                            tfv.ExcelSheetName = sheet.Name;

                            valuehs.Add(lp.LPID, tfv);
                        }

                    }
                    return;
                }

                unLockExcel(wb, sheet);
                string[] arrCellpos = lp.CellPos.Split(pchar);
                string[] arrtemp = lp.WordCount.Split(pchar);
                arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar);
                if (lp.CtrlType.Contains("uc_gridcontrol") == false)
                {
                    for (int i = 0; i < arrCellpos.Length; i++)
                    {
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[i]))
                        {
                            valuehs.Remove(lp.LPID + "$" + arrCellpos[i]);
                        }
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[i] + "完整时间"))
                        {
                            valuehs.Remove(lp.LPID + "$" + arrCellpos[i] + "完整时间");
                        }
                        try
                        {
                            if (lp.isExplorer != 1)
                            {
                                //ea.SetCellValue("", GetCellPos(arrCellpos[i])[0], GetCellPos(arrCellpos[i])[1]);
                            }
                        }
                        catch { }
                    }



                }
                if (lp.CtrlType.Contains("uc_gridcontrol"))
                {
                    FillTable(ea, lp, (sender as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar))));
                    LockExcel(wb, sheet);
                    return;
                }
                else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit"))
                {
                    FillTime(ea, lp, (sender as DateEdit).DateTime);
                    LockExcel(wb, sheet);
                    return;
                }
                else if (lp.CtrlType.Contains("DevExpress.XtraEditors.SpinEdit"))
                {

                    IList<string> strList = new List<string>();
                    if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1]))
                    {
                        try
                        {
                            if (lp.isExplorer != 1) ea.SetCellValue(str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                        }
                        catch { }
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = sheet.Name;

                        }
                        else
                        {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = sheet.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                        }
                    }
                    else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1])))
                    {
                        int i = 0;
                        try
                        {
                            if (lp.isExplorer != 1) ea.SetCellValue(str, GetCellPos(arrCellpos[i])[0], GetCellPos(arrCellpos[i])[1]);
                        }
                        catch { }
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[i]))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[i]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[i])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[i])[1];
                            tfv.ExcelSheetName = sheet.Name;

                        }
                        else
                        {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[i])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[i])[1];
                            tfv.ExcelSheetName = sheet.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[i], tfv);
                        }
                    }
                    LockExcel(wb, sheet);

                    return;
                }

                string[] extraWord = lp.ExtraWord.Split(pchar);
                List<int> arrCellCount = String2Int(arrtemp);
                string value = lp.ExtraWord;
                if (lp.ExtraWord == "合同编号")
                {
                    for (int j = 0; j < arrCellpos.Length; j++)
                    {
                        if (str.Length > j)
                        {
                            string strNew = str.Substring(j, 1);
                            try
                            {
                                if (lp.isExplorer != 1) ea.SetCellValue(strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]);

                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                                tfv.ControlValue = strNew;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = strNew;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                            }

                        }
                        else
                            break;

                    }
                    LockExcel(wb, sheet);
                    return;
                }
                else
                    if (lp.ExtraWord != "")
                    {
                        str = value.Replace("{0}", str);

                    }
                if (lp.CellName == "工作班人员" || lp.CellName == "抢修班人员" || lp.CellName == "工作班成员")
                {
                    LP_Temple lpt = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where CellName='人数' and ParentID='" + parentTemple.LPID + "'");
                    Control relateCtrl = FindCtrl(lp.LPID);
                    Control resCtrl = FindCtrl(lpt.LPID);
                    if (relateCtrl != null)
                    {
                        string[] strcount = SelectorHelper.ToDBC(relateCtrl.Text).Split('、');
                        int irencount = 0;
                        for (int iren = 0; iren < strcount.Length; iren++)
                        {
                            if (strcount[iren] != "") irencount++;
                        }
                        if (irencount != 0)
                        {
                            resCtrl.Text = irencount.ToString();
                        }
                    }
                }
                if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1]))
                {
                    try
                    {
                        if (lp.isExplorer != 1)
                        {
                            int[] cc = GetCellPos(arrCellpos[0]);
                            ea.SetCellValue("'" + str, cc[0], cc[1]);
                        }
                    }
                    catch { }
                    if (valuehs.ContainsKey(lp.LPID + "$" + lp.CellPos))
                    {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + lp.CellPos] as WF_TableFieldValue;
                        tfv.ControlValue = str;
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                        tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                        tfv.ExcelSheetName = sheet.Name;

                    }
                    else
                    {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = str;
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                        tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                        tfv.ExcelSheetName = sheet.Name;
                        valuehs.Add(lp.LPID + "$" + lp.CellPos, tfv);
                    }

                }
                else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1])))
                {
                    StringHelper help = new StringHelper();
                    if (lp.CellName == "编号")
                    {
                        for (int j = 0; j < arrCellpos.Length; j++)
                        {
                            if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[j]) && str != "")
                            {
                                //string strNew = str.Substring(0, str.Length - 1) + (j + 1).ToString();
                                string strNew = str;
                                try
                                {
                                    if (lp.isExplorer != 1) ea.SetCellValue("'" + strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]);
                                }
                                catch { }

                                if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[j]))
                                {
                                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[j]] as WF_TableFieldValue;
                                    tfv.ControlValue = strNew;
                                    tfv.FieldId = lp.LPID;
                                    tfv.FieldName = lp.CellName;
                                    tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                    tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                    tfv.ExcelSheetName = sheet.Name;

                                }
                                else
                                {
                                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                                    tfv.ControlValue = strNew;
                                    tfv.FieldId = lp.LPID;
                                    tfv.FieldName = lp.CellName;
                                    tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                    tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                    tfv.ExcelSheetName = sheet.Name;
                                    valuehs.Add(lp.LPID + "$" + arrCellpos[j], tfv);
                                }
                            }
                        }
                        LockExcel(wb, sheet);
                        return;
                    }
                    int i = 0;
                    //if (arrCellCount.Count>1&&arrCellCount[0] != arrCellCount[1])
                    if (arrCellCount.Count > 1)
                    {
                        if ((lp.CtrlType.IndexOf("uc_gridcontrol") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[i])) || (lp.CtrlType.IndexOf("uc_gridcontrol") > -1 && str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[i])))
                        {
                            try
                            {
                                if (lp.isExplorer != 1) ea.SetCellValue(str, GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                            }

                            LockExcel(wb, sheet);
                            return;
                        }

                        if (lp.CtrlType.IndexOf("uc_gridcontrol") > -1)
                        {
                            try
                            {
                                if (lp.isExplorer != 1) ea.SetCellValue(str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                                    str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])),
                                    GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                                tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                                str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                                str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                            }
                            str = str.Substring(help.GetFristLen(str, arrCellCount[0]) >= str.IndexOf("\r\n") &&
                                str.IndexOf("\r\n") != -1 ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                            i++;

                            str = help.GetPlitString(str, arrCellCount[1]);
                        }
                        else
                        {
                            int i1 = str.IndexOf("\r\n");
                            if (i1 > help.GetFristLen(str, arrCellCount[0]))
                                i1 = help.GetFristLen(str, arrCellCount[0]);
                            if (i1 == -1)
                                i1 = help.GetFristLen(str, arrCellCount[0]);
                            if (str.Length > i1 + 1 && (str.Substring(i1, 1) == "," || str.Substring(i1, 1) == "。" || str.Substring(i1 + 1, 1) == "、" || str.Substring(i1 + 1, 1) == ":" || str.Substring(i1 + 1, 1) == "!"))
                            {
                                i1 = i1 + 1;
                            }
                            try
                            {
                                if (lp.isExplorer != 1) ea.SetCellValue(str.Substring(0, i1), GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                                tfv.ControlValue = str.Substring(0, i1);
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = str.Substring(0, i1);
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                                tfv.ExcelSheetName = sheet.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                            }
                            str = str.Substring(i1);
                            i++;
                            //str = help.GetPlitString(str, arrCellCount[1]);
                        }
                        FillMutilRows(ea, i, lp, str, arrCellCount, arrCellpos);
                    }

                }
                if (lp.CellName == "单位")
                {
                    IList list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select OrgCode  from mOrg where OrgName='" + str + "'");
                    if (list.Count > 0)
                    {

                        switch (parentTemple.CellName)
                        {

                            case "电力线路第一种工作票":
                            case "yzgzp":
                                //strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                                if (bhht[str] != null)
                                {
                                    strNumber = "07" + bhht[str].ToString();

                                }
                                else
                                    strNumber = "07";
                                break;
                            case "电力线路第二种工作票":
                            case "ezgzp":
                                //strNumber = "08" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                                strNumber = "08" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                                break;
                            case "电力线路倒闸操作票":
                            case "dzczp":
                                //strNumber = "BJ" + System.DateTime.Now.Year.ToString();
                                strNumber = "06" + list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString();
                                break;
                            case "电力线路事故应急抢修单":
                            case "xlqxp":
                                //strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString();
                                strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString();
                                break;

                            case "低压线路第一种工作票":
                                if (bhht[str] != null)
                                {
                                    strNumber = "11" + bhht[str].ToString();
                                }
                                else
                                    strNumber = "11";
                                break;
                            case "低压线路第二种工作票":
                                strNumber = "12" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                                break;

                            default:
                                strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString();
                                break;
                        }

                        //IList<LP_Record> listLPRecord = ClientHelper.PlatformSqlMap.GetList<LP_Record>("SelectLP_RecordList", " where kind = '" + kind + "' and number like '" + strNumber + "%'");
                        IList listLPRecord = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", string.Format("select ControlValue from WF_TableFieldValue where  FieldName='编号' and UserControlId='{0}' and WorkFlowInsId!='" + WorkFlowData.Rows[0]["WorkFlowInsId"].ToString() + "' and ControlValue like '" + strNumber + "%' and id like '" + DateTime.Now.Year + "%' order by id desc", parentTemple.LPID));
                        if (kind == "yzgzp" || parentTemple.CellName == "电力线路第一种工作票")
                        {
                            //strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0') + "-1";
                            if (listLPRecord.Count == 0)
                                strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0');
                            else
                            {
                                decimal udw = Convert.ToDecimal(listLPRecord[0]);
                                strNumber = "0" + (udw + 1).ToString().PadLeft(3, '0');
                            }
                        }
                        else
                        {
                            int step = 1;
                            if (ctrlNumber2 != null) step = 2;
                            if (listLPRecord.Count == 0)
                                strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0');
                            else
                            {
                                decimal udw = Convert.ToDecimal(listLPRecord[0].ToString().Substring(listLPRecord[0].ToString().Length - 3));
                                strNumber = listLPRecord[0].ToString().Substring(0, listLPRecord[0].ToString().Length - 3) + (udw + step).ToString().PadLeft(3, '0');
                            }
                            if (ctrlNumber2 != null)
                            {
                                ctrlNumber2.Text = strNumber.Substring(0, strNumber.Length - 3) + (int.Parse(strNumber.Substring(strNumber.Length - 3)) + 1).ToString("000");
                            }
                            //strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0');
                        }
                        if (ctrlNumber != null)
                        {
                            ctrlNumber.Text = strNumber;
                            currRecord.Number = ctrlNumber.Text;
                        }
                        if (currRecord != null) currRecord.OrgName = str;
                        //ContentChanged(ctrlNumber);
                    }

                }
                LockExcel(wb, sheet);
            }
            catch { }
        }
Пример #9
0
        public void FillMutilRows(ExcelAccess ea, int i, LP_Temple lp, string str, List<int> arrCellCount, string[] arrCellPos)
        {
            StringHelper help = new StringHelper();

            string[] extraWord = lp.ExtraWord.Split(pchar);
            if (lp.CtrlType.IndexOf("uc_gridcontrol") > -1)
            {
                str = help.GetPlitString(str, arrCellCount[1]);
                string[] arrRst = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                int j = 0;
                for (; i < arrCellPos.Length; i++)
                {
                    if (j >= arrRst.Length)
                        break;
                    try
                    {
                        if (lp.isExplorer != 1) ea.SetCellValue(arrRst[j], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                    }
                    catch { }
                    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                    {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                        tfv.ControlValue = arrRst[j];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                        tfv.ExcelSheetName = activeSheetName;

                    }
                    else
                    {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = arrRst[j];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                        tfv.ExcelSheetName = activeSheetName;
                        valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                    }
                    j++;
                }
            }
            else
            {
                string strarrRst = str;
                int i1 = strarrRst.IndexOf("\r\n");

                for (; i < arrCellPos.Length; i++)
                {
                    i1 = strarrRst.IndexOf("\r\n");
                    if (i1 > help.GetFristLen(strarrRst, arrCellCount[i]))
                        i1 = help.GetFristLen(strarrRst, arrCellCount[i]);
                    if (i1 == 0)
                    {
                        strarrRst = strarrRst.Substring(2);
                        i1 = strarrRst.IndexOf("\r\n");
                        if (i1 > help.GetFristLen(strarrRst, arrCellCount[i]))
                            i1 = help.GetFristLen(strarrRst, arrCellCount[i]);
                    }
                    if (i1 == -1)
                        i1 = help.GetFristLen(str, arrCellCount[i]);
                    if (strarrRst.Length > i1 + 1 && (strarrRst.Substring(i1, 1) == "," || strarrRst.Substring(i1, 1) == "。" || strarrRst.Substring(i1 + 1, 1) == "、" || strarrRst.Substring(i1 + 1, 1) == ":" || strarrRst.Substring(i1 + 1, 1) == "!"))
                    {
                        i1 = i1 + 1;
                    }
                    //if (strarrRst.Length <= help.GetFristLen(str, arrCellCount[i]))
                    //{
                    //    try
                    //    {
                    //        if (lp.isExplorer != 1) ea.SetCellValue(strarrRst, GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                    //    }
                    //    catch { }
                    //    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                    //    {
                    //        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                    //        tfv.ControlValue = strarrRst;
                    //        tfv.FieldId = lp.LPID;
                    //        tfv.FieldName = lp.CellName;
                    //        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                    //        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                    //        tfv.ExcelSheetName = activeSheetName;

                    //    }
                    //    else
                    //    {
                    //        WF_TableFieldValue tfv = new WF_TableFieldValue();
                    //        tfv.ControlValue = strarrRst;
                    //        tfv.FieldId = lp.LPID;
                    //        tfv.FieldName = lp.CellName;
                    //        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                    //        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                    //        tfv.ExcelSheetName = activeSheetName;
                    //        valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                    //    }
                    //    break;
                    //}
                    //else
                    {
                        if (strarrRst.Length >= i1)
                        {
                            try
                            {
                                if (lp.isExplorer != 1) if (lp.isExplorer != 1) ea.SetCellValue(strarrRst.Substring(0, i1), GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                                tfv.ControlValue = strarrRst.Substring(0, i1);
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                                tfv.ExcelSheetName = activeSheetName;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = strarrRst.Substring(0, i1);
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                                tfv.ExcelSheetName = activeSheetName;
                                valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                            }
                            strarrRst = strarrRst.Substring(i1);
                        }
                        else
                        {
                            try
                            {
                                if (lp.isExplorer != 1) if (lp.isExplorer != 1) ea.SetCellValue(strarrRst, GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                                tfv.ControlValue = strarrRst;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                                tfv.ExcelSheetName = activeSheetName;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = strarrRst;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                                tfv.ExcelSheetName = activeSheetName;
                                valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                            }
                            strarrRst = "";
                        }
                        //i++;
                        //strarrRst = help.GetPlitString(strarrRst, arrCellCount[i]);
                    }


                }
            }
        }
Пример #10
0
        void btn_Submit_Click(object sender, EventArgs e)
        {
            Excel.Workbook wb;
            Excel.Worksheet sheet;
            dsoFramerWordControl1.FileSave();
            currRecord.BigData = this.dsoFramerWordControl1.FileDataGzip;
            wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            if (activeSheetName != "")
            {
                sheet = wb.Application.Sheets[activeSheetName] as Excel.Worksheet;
            }
            else
            {
                sheet = wb.Application.Sheets[1] as Excel.Worksheet;
            }
            activeSheetIndex = sheet.Index;
            
            for (int i = 1; i <= wb.Application.Sheets.Count; i++)
            {
                if (i != activeSheetIndex)
                {
                    Excel.Worksheet tmpSheet = (Excel.Worksheet)wb.Application.Sheets.get_Item(i);
                    try
                    {
                        if (tmpSheet != null) tmpSheet.Visible = Excel.XlSheetVisibility.xlSheetVisible ;
                    }
                    catch { }

                }
            }
            unLockExcel(wb,sheet);
            for (int i = 1; sheet.Protection.AllowEditRanges.Count > 0; )
            {
                Excel.AllowEditRange editRange = sheet.Protection.AllowEditRanges.get_Item(i);
                editRange.Delete();
            }
            LockExcel(wb, sheet);
            byte[] bt = new byte[0];
            string strmes = "";
            WF_WorkTaskCommands wt;
            LP_Temple lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>("where ParentID='" + parentTemple.LPID + "' and  CellName like '%姓名%'");
            Control ctl = FindCtrl(lp.LPID);
            if (ctl != null)
            {
                currRecord.wdmc = ctl.Text;
            }
            lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>("where ParentID='" + parentTemple.LPID + "' and  CellName like '%职务%'");
             ctl = FindCtrl(lp.LPID);
            if (ctl != null)
            {
                currRecord.wdlx = ctl.Text;
            }
            //rowData = null;
            ArrayList akeys = new ArrayList(valuehs.Keys);
            List<object> list = new List<object>();
            for (int i = 0; i < akeys.Count; i++)
            {
                WF_TableFieldValue wfv = valuehs[akeys[i]] as WF_TableFieldValue;
                wfv.ID = wfv.CreateID();
                wfv.RecordId = currRecord.ID;
                wfv.WorkFlowId = currRecord.ID ;
                wfv.WorkFlowInsId = currRecord.wdmc ;
                wfv.WorkTaskId = "安规电子档案";
                wfv.WorkTaskInsId = "安规电子档案";
                wfv.UserControlId = parentTemple.LPID;
                Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                list.Add(wfv);
                if (wfv.FieldName == "所在单位")
                {

                    rowData.OrgName = wfv.ControlValue.Replace(MainHelper.UserCompany, "");
                    mOrg org = MainHelper.PlatformSqlMap.GetOne<mOrg>("where OrgName='" + rowData.OrgName + "'");
                    if (org != null)
                    {
                        rowData.OrgCode = org.OrgCode;
                    }
                }
                for (int j = 0; j < templeList.Count; j++)
                {
                    if (templeList[j].LPID == wfv.FieldId)
                    {
                        templeList.RemoveAt(j);
                        break;
                    }
                }
            }
            Control ct=null;
            for (int i = 0; i < templeList.Count; i++)
            {
                WF_TableFieldValue wfv = new  WF_TableFieldValue();
                wfv.ExcelSheetName = templeList[i].KindTable;
                if (templeList[i].CellPos != "")
                {
                    wfv.XExcelPos = GetCellPos(templeList[i].CellPos)[0];
                    wfv.YExcelPos = GetCellPos(templeList[i].CellPos)[1];
                }
                else
                {

                    wfv.XExcelPos = -1;
                    wfv.YExcelPos = -1;
                }
                wfv.FieldId = templeList[i].LPID;
                wfv.FieldName = templeList[i].CellName;
                ct = FindCtrl( templeList[i].LPID);
                if(ct!=null)
                wfv.ControlValue=ct.Text;

                wfv.ID = wfv.CreateID();
                wfv.RecordId = currRecord.ID;
                wfv.WorkFlowId = currRecord.ID;
                wfv.WorkFlowInsId = currRecord.wdmc;
                wfv.WorkTaskId = "安规电子档案";
                wfv.WorkTaskInsId = "安规电子档案";
                wfv.UserControlId = parentTemple.LPID;
                wfv.UserControlId = parentTemple.LPID;
                Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                list.Add(wfv);
               
            }
            
            switch (status)
            {
                case "add":

                    if (list.Count > 0)
                    {
                        Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(list, null, null);
                    }
                    if (currRecord.BigData == null)
                    {
                        currRecord.BigData = new byte[0];
                    }
                     Client.ClientHelper.PlatformSqlMap.Create<PJ_ryda >(currRecord);
                    break;

                case "edit":

                    if (list.Count > 0)
                    {
                        foreach (WF_TableFieldValue wfv in list)
                        {
                           WF_TableFieldValue wtfvtemp= Client.ClientHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                + " and   WorkflowId='" + wfv.WorkFlowId + "'"
                                + " and   RecordId='" + wfv.RecordId + "'"
                                + " and   UserControlId='" + wfv.UserControlId + "'"
                                + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
                                + " and   fieldname='" + wfv.FieldName  + "'"
                                + " and   FieldId='" + wfv.FieldId + "'"
                                + " and   XExcelPos='" + wfv.XExcelPos + "'"
                                + " and   YExcelPos='" + wfv.YExcelPos + "'"
                                + " and WorkTaskInsId='安规电子档案'");
                           if (wtfvtemp != null)
                               wfv.ID = wtfvtemp.ID;
                           else
                           {
                               Client.ClientHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                           }
                        }
                        Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(null, list, null);
                    }
                    if (currRecord.BigData == null)
                    {
                        currRecord.BigData = new byte[0];
                    }
                    Client.ClientHelper.PlatformSqlMap.Update<PJ_ryda>(currRecord);
                    break;
            }

            dsoFramerWordControl1.FileSave();
            //dsoFramerWordControl1.FileClose();
            rowData = currRecord;
            this.DialogResult = DialogResult.OK;
        }
Пример #11
0
        void btn_Submit_Click(object sender, EventArgs e)
        {
            Excel.Workbook wb;
            //Excel.Worksheet sheet;
            wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            if (activeSheetName != "")
            {
                sheet = wb.Application.Sheets[activeSheetName] as Excel.Worksheet;
            }
            else
            {
                sheet = wb.Application.Sheets[1] as Excel.Worksheet;
            }
            //activeSheetIndex = sheet.Index;
            if (filecontrol != null)
            {
                if (filecontrol.Isupfile)
                {
                    MsgBox.ShowTipMessageBox("请稍后,正在上传文件");
                    return;
                }
                if (filecontrol.Isdownfile)
                {
                    if (MsgBox.ShowAskMessageBox("正在下载文件,确认提交?") != DialogResult.OK)
                    {
                        return;
                    }

                }
            }
            for (int i = 1; i <= wb.Application.Sheets.Count; i++)
            {
                if (i != activeSheetIndex)
                {
                    Excel.Worksheet tmpSheet = (Excel.Worksheet)wb.Application.Sheets.get_Item(i);
                    try
                    {
                        if (tmpSheet != null) tmpSheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
                    }
                    catch { }

                }
            }
            unLockExcel(wb, sheet);
            for (int i = 1; sheet.Protection.AllowEditRanges.Count > 0; )
            {
                Excel.AllowEditRange editRange = sheet.Protection.AllowEditRanges.get_Item(i);
                editRange.Delete();
            }
            LockExcel(wb, sheet);
            byte[] bt = new byte[0];
            string strmes = "";
            WF_WorkTaskCommands wt;
            if (strNumber != "") currRecord.Number = strNumber;
            ArrayList akeys = new ArrayList(valuehs.Keys);
            List<object> list = new List<object>();

            DateTime dt = DateTime.Now;
            Random rd = new Random();
            int irpos = 5001;
            WF_TableFieldValue wfv = null;
            decimal dtemp = Convert.ToDecimal(dt.ToString("yyyyMMddHHmmssffffff"));
            for (int i = 0; i < akeys.Count; i++)
            {
                wfv = valuehs[akeys[i]] as WF_TableFieldValue;
                if (wfv.XExcelPos != -1 && wfv.YExcelPos != -1)
                    wfv.ID = Convert.ToString((dtemp + wfv.YExcelPos + wfv.XExcelPos * 10000));
                else
                {

                    wfv.ID = Convert.ToString((dtemp + irpos + irpos * 10000));
                    irpos++;
                }
                wfv.RecordId = currRecord.ID;
                wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                wfv.UserControlId = parentTemple.LPID;
                //MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                //Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                wfv.ID = wfv.CreateID() + new Random().Next(10, 99);
                list.Add(wfv);
                MainHelper.PlatformSqlMap.DeleteByWhere<WF_TableFieldValue>(" where FieldId ='" + wfv.FieldId + "' and WorkFlowInsId='" + WorkFlowData.Rows[0]["WorkFlowInsId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'");
            }
            //foreach (WF_TableFieldValue wfv in list)
            //{
            //    Console.Write(wfv.ID+"\r\n");
            //}

            if (RecordWorkTask.CheckOnRiZhi(WorkFlowData))
            {

                RecordWorkTask.CreatRiZhi(WorkFlowData, dsoFramerWordControl1, currRecord.ID, new object[] { currRecord });

            }
            //RecordWorkTask.CreateJL(WorkFlowData, dsoFramerWordControl1, currRecord.ID, new object[] { currRecord });
            if (strxiestatus == "add")
            {
                if (list.Count > 0)
                {

                    Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(list, null, null);

                }
            }
            else
            {
                if (list.Count > 0)
                {
                    foreach (WF_TableFieldValue wfv2 in list)
                    {
                        WF_TableFieldValue wtfvtemp = Client.ClientHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                             + " and   WorkflowId='" + wfv2.WorkFlowId + "'"
                             + " and   RecordId='" + wfv2.RecordId + "'"
                             + " and   UserControlId='" + wfv2.UserControlId + "'"
                             + " and   WorkFlowInsId='" + wfv2.WorkFlowInsId + "'"
                             + " and   fieldname='" + wfv2.FieldName + "'"
                             + " and   FieldId='" + wfv2.FieldId + "'"
                             + " and   XExcelPos='" + wfv2.XExcelPos + "'"
                             + " and   YExcelPos='" + wfv2.YExcelPos + "'"
                             + " and   WorkTaskId='" + wfv2.WorkTaskId + "'"
                             );
                        if (wtfvtemp != null)
                            wfv2.ID = wtfvtemp.ID;
                        else
                        {
                            wfv2.ID = wfv2.CreateID();
                            Client.ClientHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv2);
                        }
                    }
                    Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(null, list, null);
                }
            }
            LP_Temple lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where  ParentID='" + parentTemple.LPID + "' and SortID=1");
            if (lp != null)
            {
                if (wfv == null)
                {
                    wfv = new WF_TableFieldValue();
                    wfv.ID = wfv.CreateID();
                    wfv.RecordId = currRecord.ID;
                    wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                    wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                    wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                    wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                    wfv.UserControlId = parentTemple.LPID;
                    wfv.ControlValue = "";
                    wfv.FieldId = lp.LPID;
                    wfv.FieldName = lp.CellName;
                    wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    wfv.ExcelSheetName = activeSheetName;
                }

                wfv = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                 + " and   WorkflowId='" + wfv.WorkFlowId + "'"
                                 + " and   RecordId='" + wfv.RecordId + "'"
                                 + " and   UserControlId='" + wfv.UserControlId + "'"
                                 + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
                                 + " and   fieldname='" + lp.CellName + "'"
                                 + " and   FieldId='" + lp.LPID + "' and Bigdata is not null"
                                );

                dsoFramerWordControl1.FileSave();
                currRecord.DocContent = dsoFramerWordControl1.FileDataGzip;
                if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
                if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
                if (wfv == null)
                {
                    wfv = new WF_TableFieldValue();
                    wfv.ID = wfv.CreateID();
                    wfv.RecordId = currRecord.ID;
                    wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                    wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                    wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                    wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                    wfv.UserControlId = parentTemple.LPID;
                    wfv.ControlValue = "";
                    wfv.FieldId = lp.LPID;
                    wfv.FieldName = lp.CellName;
                    wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    wfv.ExcelSheetName = activeSheetName;
                    wfv.Bigdata = currRecord.DocContent;
                    MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                }
                else
                {
                    wfv.Bigdata = currRecord.DocContent;
                    MainHelper.PlatformSqlMap.Update<WF_TableFieldValue>(wfv);

                }
            }
            RunTaskUpdate();
            RunTaskRecordUpdate();
            switch (status)
            {
                case "add":

                    //LP_Record newRecord = new LP_Record();
                    currRecord.Kind = kind;
                    currRecord.Content = GetContent();
                    dsoFramerWordControl1.FileSave();
                    //dsoFramerWordControl1.FileClose();
                    if (ctrlNumber != null)
                        currRecord.Number = ctrlNumber.Text;
                    //currRecord.ImageAttachment = bt;
                    //currRecord.SignImg = bt;
                    currRecord.LastChangeTime = DateTime.Now.ToString();

                    //string[] strtemp = RecordWorkTask.RunNewGZPRecord(currRecord.ID, kind, MainHelper.User.UserID);
                    wt = (WF_WorkTaskCommands)MainHelper.PlatformSqlMap.GetObject("SelectWF_WorkTaskCommandsList", " where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'");
                    if (wt != null)
                    {
                        strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), wt.CommandName);
                    }
                    else
                    {
                        strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), "提交");
                    }
                    //strmes = strtemp[0];
                    //currRecord.Status = strtemp[1];
                    if (strmes.IndexOf("未提交至任何人") > -1)
                    {
                        MsgBox.ShowTipMessageBox("未提交至任何人,创建失败,请检查流程模板和组织机构配置是否正确!");
                        return;
                    }
                    else
                        MsgBox.ShowTipMessageBox(strmes);
                    strmes = RecordWorkTask.GetWorkFlowTaskCaption(WorkFlowData.Rows[0]["WorkTaskInsId"].ToString());
                    if (strmes == "结束节点1")
                    {
                        currRecord.Status = "存档";
                    }
                    else
                    {
                        currRecord.Status = strmes;
                    }
                    if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
                    if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
                    if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
                    if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
                    MainHelper.PlatformSqlMap.Update("UpdateLP_Record", currRecord);
                    rowData = null;
                    if (hqyjcontrol != null)
                    {
                        PJ_lcspyj lcyj = new PJ_lcspyj();
                        lcyj.Charman = MainHelper.User.UserName;
                        lcyj.ID = PJ_lcspyj.Newid();
                        lcyj.RecordID = currRecord.ID;
                        lcyj.taskID = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                        lcyj.Spyj = hqyjcontrol.nowMemoEdit.Text;
                        lcyj.Creattime = DateTime.Now;
                        if (hqyjcontrol.nowMemoEdit.Text != "")
                            MainHelper.PlatformSqlMap.Create<PJ_lcspyj>(lcyj);
                    }
                    if (filecontrol != null)
                    {
                        for (int i = 0; i < filecontrol.FJtable.Rows.Count; i++)
                        {

                            PJ_lcfj lcfu = new PJ_lcfj();
                            lcfu.ID = lcfu.CreateID();
                            lcfu.Filename = Path.GetFileName(filecontrol.FJtable.Rows[i]["FilePath"].ToString());
                            lcfu.FileRelativePath = filecontrol.FJtable.Rows[i]["SaveFileName"].ToString();
                            lcfu.FileSize = Convert.ToInt64(filecontrol.FJtable.Rows[i]["FileSize"]);
                            lcfu.RecordID = currRecord.ID;
                            lcfu.Creattime = DateTime.Now;
                            Thread.Sleep((new TimeSpan(100000)));//0.1毫秒
                            if (filecontrol.FJtable.Rows[i]["Kind"].ToString() != "已上传")
                                MainHelper.PlatformSqlMap.Create<PJ_lcfj>(lcfu);
                        }

                    }
                    //currRecord = newRecord;
                    break;
                case "edit":

                    currRecord.LastChangeTime = DateTime.Now.ToString();
                    // dsoFramerWordControl1.FileSave();
                    //currRecord.DocContent = this.dsoFramerWordControl1.FileDataGzip;
                    //byte[] bt = new byte[0];
                    //currRecord.ImageAttachment = bt;
                    //currRecord.SignImg = bt;
                    currRecord.Content = GetContent();
                    dsoFramerWordControl1.FileSave();
                    //dsoFramerWordControl1.FileClose();
                    wt = (WF_WorkTaskCommands)MainHelper.PlatformSqlMap.GetObject("SelectWF_WorkTaskCommandsList", " where WorkFlowId='" + WorkFlowData.Rows[0]["WorkFlowId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'");
                    if (wt != null)
                    {
                        strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), wt.CommandName);
                    }
                    else
                    {
                        strmes = RecordWorkTask.RunWorkFlow(MainHelper.User.UserID, WorkFlowData.Rows[0]["OperatorInsId"].ToString(), WorkFlowData.Rows[0]["WorkTaskInsId"].ToString(), "提交");
                    }
                    string towho = strmes;
                    strmes = RecordWorkTask.GetWorkFlowTaskCaption(WorkFlowData.Rows[0]["WorkTaskInsId"].ToString());
                    if (strmes.IndexOf("结束节点") > -1)
                    {
                        CurrRecord.Status = "存档";
                    }
                    else
                    {
                        CurrRecord.Status = strmes;
                    }
                    if (towho.IndexOf("未提交至任何人") > -1)
                    {
                        MsgBox.ShowTipMessageBox("未提交至任何人,创建失败,请检查流程模板和组织机构配置是否正确!");
                        return;
                    }
                    else
                        MsgBox.ShowTipMessageBox(towho);
                    if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
                    if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
                    if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
                    if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
                    MainHelper.PlatformSqlMap.Update("UpdateLP_Record", currRecord);
                    if (hqyjcontrol != null)
                    {
                        PJ_lcspyj lcyj = new PJ_lcspyj();
                        lcyj.Charman = MainHelper.User.UserName;
                        lcyj.ID = PJ_lcspyj.Newid();
                        lcyj.RecordID = currRecord.ID;
                        lcyj.taskID = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                        lcyj.Spyj = hqyjcontrol.nowMemoEdit.Text;
                        lcyj.Creattime = DateTime.Now;
                        if (hqyjcontrol.nowMemoEdit.Text != "")
                            MainHelper.PlatformSqlMap.Create<PJ_lcspyj>(lcyj);

                    }

                    rowData = null;
                    break;
            }


            this.DialogResult = DialogResult.OK;
        }
Пример #12
0
        void btn_Submit_Click(object sender, EventArgs e)
        {
            Excel.Workbook wb;
            Excel.Worksheet sheet;
            dsoFramerWordControl1.FileSave();
            //currRecord.BigData = this.dsoFramerWordControl1.FileDataGzip;
            wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            if (filecontrol != null)
            {
                if (filecontrol.Isupfile)
                {
                    MsgBox.ShowTipMessageBox("请稍后,正在上传文件");
                    return;
                }
                if (filecontrol.Isdownfile)
                {
                    if (MsgBox.ShowAskMessageBox("正在下载文件,确认提交?") != DialogResult.OK)
                    {
                        return;
                    }

                }
            }
            if (activeSheetName != "")
            {
                sheet = wb.Application.Sheets[activeSheetName] as Excel.Worksheet;
            }
            else
            {
                sheet = wb.Application.Sheets[1] as Excel.Worksheet;
            }
            activeSheetIndex = sheet.Index;
            
            for (int i = 1; i <= wb.Application.Sheets.Count; i++)
            {
                if (i != activeSheetIndex)
                {
                    Excel.Worksheet tmpSheet = (Excel.Worksheet)wb.Application.Sheets.get_Item(i);
                    try
                    {
                        if (tmpSheet != null) tmpSheet.Visible = Excel.XlSheetVisibility.xlSheetVisible ;
                    }
                    catch { }

                }
            }
            unLockExcel(wb,sheet);
            for (int i = 1; sheet.Protection.AllowEditRanges.Count > 0; )
            {
                Excel.AllowEditRange editRange = sheet.Protection.AllowEditRanges.get_Item(i);
                editRange.Delete();
            }
            LockExcel(wb, sheet);
            byte[] bt = new byte[0];
            string strmes = "";
            WF_WorkTaskCommands wt;
            
           
            //rowData = null;
            ArrayList akeys = new ArrayList(valuehs.Keys);
            List<object> list = new List<object>();
            string strid = DateTime.Now.ToString("yyyyMMddHHmmssffffff");
            for (int i = 0; i < akeys.Count; i++)
            {
                WF_TableFieldValue wfv = valuehs[akeys[i]] as WF_TableFieldValue;
                wfv.ID = wfv.CreateID();
                wfv.RecordId = currRecord.ID;
                wfv.WorkFlowId =modleGuid;
                wfv.WorkFlowInsId = orgname;
                wfv.WorkTaskId = "安全运行记录板";
                wfv.WorkTaskInsId = "安全运行记录板";
                wfv.UserControlId = parentTemple.LPID;
                Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                list.Add(wfv);
                for (int j = 0; j < templeList.Count; j++)
                {
                    if (templeList[j].LPID == wfv.FieldId)
                    {
                        templeList.RemoveAt(j);
                        break;
                    }
                }
            }
            Control ct=null;
            DateTime dt = DateTime.Now;
            Random rd = new Random();
            decimal dtemp = Convert.ToDecimal(dt.ToString("yyyyMMddHHmmssffffff"));
            for (int i = 0; i < templeList.Count; i++)
            {
                WF_TableFieldValue wfv = new  WF_TableFieldValue();
                wfv.ExcelSheetName = templeList[i].KindTable;
                if (templeList[i].CellPos != "")
                {
                    wfv.XExcelPos = GetCellPos(templeList[i].CellPos)[0];
                    wfv.YExcelPos = GetCellPos(templeList[i].CellPos)[1];
                }
                else
                {

                    wfv.XExcelPos = -1;
                    wfv.YExcelPos = -1;
                }
                wfv.FieldId = templeList[i].LPID;
                wfv.FieldName = templeList[i].CellName;
                ct = FindCtrl( templeList[i].LPID);
                if(ct!=null)
                wfv.ControlValue=ct.Text;

                
                if (wfv.XExcelPos != -1 && wfv.YExcelPos != -1)
                    wfv.ID = Convert.ToString((dtemp + wfv.YExcelPos + wfv.XExcelPos * 10000));
                else
                    wfv.ID = Convert.ToString((dtemp + rd.Next() * 10000));
                wfv.RecordId = currRecord.ID;
                wfv.WorkFlowId =modleGuid ;
                wfv.WorkFlowInsId = orgname;
                wfv.WorkTaskId = "安全运行记录板";
                wfv.WorkTaskInsId = "安全运行记录板";
                wfv.UserControlId = parentTemple.LPID;
                Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                list.Add(wfv);
            }
            switch (status)
            {
                case "add":

                    if (list.Count > 0)
                    {
                        Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(list, null, null);
                    }
                    if (filecontrol != null)
                    {
                        for (int i = 0; i < filecontrol.FJtable.Rows.Count; i++)
                        {

                            PJ_lcfj lcfu = new PJ_lcfj();
                            lcfu.ID = lcfu.CreateID();
                            lcfu.Filename = Path.GetFileName(filecontrol.FJtable.Rows[i]["FilePath"].ToString());
                            lcfu.FileRelativePath = filecontrol.FJtable.Rows[i]["SaveFileName"].ToString();
                            lcfu.FileSize = Convert.ToInt64(filecontrol.FJtable.Rows[i]["FileSize"]);
                            lcfu.RecordID = currRecord.ID;
                            lcfu.Creattime = DateTime.Now;
                            Thread.Sleep((new TimeSpan(100000)));//0.1毫秒
                            if (filecontrol.FJtable.Rows[i]["Kind"].ToString() != "已上传")
                                MainHelper.PlatformSqlMap.Create<PJ_lcfj>(lcfu);
                        }

                    }
                    break;

                case "edit":

                    if (list.Count > 0)
                    {
                        foreach (WF_TableFieldValue wfv in list)
                        {
                           WF_TableFieldValue wtfvtemp= Client.ClientHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                + " and   WorkflowId='" + wfv.WorkFlowId + "'"
                                + " and   RecordId='" + wfv.RecordId + "'"
                                + " and   UserControlId='" + wfv.UserControlId + "'"
                                + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
                                + " and   FieldId='" + wfv.FieldId + "'"
                                + " and WorkTaskInsId='安全运行记录板'");
                           wfv.ID = wtfvtemp.ID;
                        }
                        Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(null, list, null);
                    }
                  
                    break;
            }

            dsoFramerWordControl1.FileSave();
            dsoFramerWordControl1.FileClose();

            this.DialogResult = DialogResult.OK;
        }
Пример #13
0
        private void LPFrm_Load(object sender, EventArgs e)
        {
            if (tempCtrlList==null)
            {
                tempCtrlList = new List<Control>();
            }
            this.Text = "安全运行记录板";
            //InitializeComponent();
            if (valuehs == null)
                valuehs = new Hashtable();
            Excel.Workbook wb;
            Excel.Worksheet sheet;
            ExcelAccess ea = new ExcelAccess();
            parentTemple = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where ( ParentID not in (select LPID from LP_Temple where 1=1 and  CtrlSize!='目录') and  CtrlSize!='目录' ) and  CellName = '安全运行记录板'");
            currRecord = rowData;
            if (parentTemple == null)
            {
                MsgBox.ShowWarningMessageBox("没有找到表单安全运行记录板!");
                return;
            }
            //if (currRecord.BigData == null || currRecord.BigData.Length == 0)
            {

                this.dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent;
            }
            //else
            //{

            //    this.dsoFramerWordControl1.FileDataGzip = currRecord.BigData;
            //}
                InitIndex();
                InitContorl();
                InitData();
                if (status == "edit")
                {
                    IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList",
                     " where RecordId='" + currRecord.ID + "' and UserControlId='" + parentTemple.LPID + "' and   WorkflowId='" + modleGuid + "' and WorkFlowInsId='" + orgname + "' ");
                   
                    Excel.Worksheet xx;
                    wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
                    ea.MyWorkBook = wb;
                    ea.MyExcel = wb.Application;
                    string activeSheetName = "";
                    xx = wb.Application.Sheets[1] as Excel.Worksheet;
                    int i = 0;
                    unLockExcel(wb, xx);
                    ArrayList al = new ArrayList();
                    for (i = 1; i <= wb.Application.Sheets.Count; i++)
                    {
                        xx = wb.Application.Sheets[i] as Excel.Worksheet;
                        if (!al.Contains(xx.Name)) al.Add(xx.Name);
                    }
                    for (i = 0; i < tfvli.Count; i++)
                    {
                      
                        Control ctl= FindCtrl(tfvli[i].FieldId);
                        if (ctl != null)
                        {
                            ctl.Text = tfvli[i].ControlValue;
                            ctl.Focus();
                        }
                        if (!al.Contains(tfvli[i].ExcelSheetName))
                        {

                            continue;
                        }
                      
                        
                        
                        if (activeSheetName != tfvli[i].ExcelSheetName)
                        {
                            if (activeSheetName != "")
                            {

                                xx = wb.Application.Sheets[activeSheetName] as Excel.Worksheet;


                            }
                            xx = wb.Application.Sheets[tfvli[i].ExcelSheetName] as Excel.Worksheet;

                            activeSheetName = tfvli[i].ExcelSheetName;

                            ea.ActiveSheet(xx.Index);
                        }

                        //if (tfvli[i].XExcelPos > -1 && tfvli[i].YExcelPos > -1) ea.SetCellValue(tfvli[i].ControlValue, tfvli[i].XExcelPos, tfvli[i].YExcelPos);


                    }
                    LockExcel(wb, xx);
                    dsoFramerWordControl1.FileSave();
                }

              
        }
Пример #14
0
        private void frmLP_FormClosed(object sender, FormClosedEventArgs e)
        {
           
            try
            { 
                //base.Close();
                currRecord = null;

                dsoFramerWordControl1.FileSave();
                dsoFramerWordControl1.FileClose();
                dsoFramerWordControl1.Dispose();
                dockPanel1.ControlContainer.Controls.Clear();
                templeList.Clear();
                    //if (filecontrol != null)
                    //{

                    //    if (filecontrol.upThread != null && filecontrol.upThread.ThreadState == ThreadState.Running)
                    //    {
                            
                    //            filecontrol.upThread.IsBackground = true;
                    //            filecontrol.upThread.Abort();
                           
                    //    }
                    //    if (filecontrol.Isdownfile)
                    //    {

                    //        if (filecontrol.webClient!=null) filecontrol.webClient.CancelAsync();

                    //    }
                    //}
            }
            catch { }
        }
Пример #15
0
        public void FillMutilRows(ExcelAccess ea, int i, LP_Temple lp, string str, List<int> arrCellCount, string[] arrCellPos) {
            StringHelper help = new StringHelper();
            str = help.GetPlitString(str, arrCellCount[1]);
            string[] extraWord = lp.ExtraWord.Split(pchar);

            string[] arrRst = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            int j = 0;
            for (; i < arrCellPos.Length; i++) {
                if (j >= arrRst.Length)
                    break;
                ea.SetCellValue("'" + arrRst[j], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i])) {
                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                    tfv.ControlValue = arrRst[j];
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                    tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                    tfv.ExcelSheetName = activeSheetName;

                } else {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = arrRst[j];
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                    tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                    tfv.ExcelSheetName = activeSheetName;
                    valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                }
                j++;
            }
        }
Пример #16
0
        public void FillTime(ExcelAccess ea, LP_Temple lp, DateTime dt)
        {
            string[] arrCellPos = lp.CellPos.Split(pchar);
            arrCellPos = StringHelper.ReplaceEmpty(arrCellPos).Split(pchar);
            string[] extraWord = lp.ExtraWord.Split(pchar);
            IList<string> strList = new List<string>();
            //if (arrCellPos.Length == 5)
            //{
            //    strList.Add(dt.Year.ToString()); strList.Add(dt.Month.ToString());
            //    strList.Add(dt.Day.ToString()); strList.Add(dt.Hour.ToString()); strList.Add(dt.Minute.ToString());
            //}
            //else if (arrCellPos.Length == 4)
            //{
            //    strList.Add(dt.Day.ToString()); strList.Add(dt.Hour.ToString()); strList.Add(dt.Minute.ToString());
            //}
            //else if (arrCellPos.Length == 3)
            //{
            //    // strList.Add(dt.Year.ToString()); strList.Add(dt.Month.ToString());
            //    //strList.Add(dt.Day.ToString()); strList.Add(dt.Hour.ToString()); strList.Add(dt.Minute.ToString());
            //    strList.Add(dt.Year.ToString());
            //    strList.Add(dt.Month.ToString());
            //    strList.Add(dt.Day.ToString());
            //}
            //else if (arrCellPos.Length == 2)
            //{
            //    strList.Add(dt.Hour.ToString());
            //    strList.Add(dt.Minute.ToString());
            //}
            //else if (arrCellPos.Length == 1)
            //{
            //    strList.Add(dt.ToString());
            //}
            switch (lp.WordCount)
            {
                case "yyyy-MM-dd":

                    strList.Add(dt.Year.ToString());
                    strList.Add(string.Format("{0:D2}", dt.Month));
                    strList.Add(string.Format("{0:D2}", dt.Day));
                    break;
                case "yyyy-MM-dd HH:mm:ss":
                    strList.Add(dt.Year.ToString());
                    strList.Add(string.Format("{0:D2}", dt.Month));
                    strList.Add(string.Format("{0:D2}", dt.Day));
                    strList.Add(string.Format("{0:D2}", dt.Hour));
                    strList.Add(string.Format("{0:D2}", dt.Minute));
                    strList.Add(string.Format("{0:D2}", dt.Second));
                    break;
                case "HH:mm:ss":
                    strList.Add(dt.Hour.ToString());
                    strList.Add(string.Format("{0:D2}", dt.Minute));
                    strList.Add(string.Format("{0:D2}", dt.Second));
                    break;
                case "MM-dd日 HH:mm":
                    strList.Add(string.Format("{0:D2}", dt.Month));
                    strList.Add(string.Format("{0:D2}", dt.Day));
                    strList.Add(string.Format("{0:D2}", dt.Hour));
                    strList.Add(string.Format("{0:D2}", dt.Minute));
                    break;
                case "dd日 HH:mm":
                    strList.Add(string.Format("{0:D2}", dt.Day));
                    strList.Add(string.Format("{0:D2}", dt.Hour));
                    strList.Add(string.Format("{0:D2}", dt.Minute));
                    break;
                case "HH:mm":
                    strList.Add(string.Format("{0:D2}", dt.Hour));
                    strList.Add(string.Format("{0:D2}", dt.Minute));
                    break;
                default:
                    if (lp.WordCount.IndexOf("yyyy") > -1)
                    {
                        if (lp.WordCount.IndexOf("yyyy年") > -1)
                            strList.Add(dt.Year.ToString() + "年");
                        else
                            strList.Add(dt.Year.ToString());

                    }
                    if (lp.WordCount.IndexOf("MM") > -1)
                    {
                        if (lp.WordCount.IndexOf("MM月") > -1)
                            strList.Add(string.Format("{0:D2}", dt.Month) + "月");
                        else
                            strList.Add(string.Format("{0:D2}", dt.Month));
                    }
                    if (lp.WordCount.IndexOf("dd") > -1)
                    {
                        if (lp.WordCount.IndexOf("dd日") > -1)
                            strList.Add(string.Format("{0:D2}", dt.Day) + "日");
                        else
                            strList.Add(string.Format("{0:D2}", dt.Day));
                    }
                    if (lp.WordCount.IndexOf("HH") > -1)
                    {
                        if (lp.WordCount.IndexOf("HH时") > -1)
                            strList.Add(string.Format("{0:D2}", dt.Hour) + "时");
                        else
                            strList.Add(string.Format("{0:D2}", dt.Hour));
                    }
                    if (lp.WordCount.IndexOf("mm") > -1)
                    {
                        if (lp.WordCount.IndexOf("mm分") > -1)
                            strList.Add(string.Format("{0:D2}", dt.Minute) + "分");
                        else
                            strList.Add(string.Format("{0:D2}", dt.Minute));
                    }
                    if (lp.WordCount.IndexOf("ss") > -1)
                    {
                        if (lp.WordCount.IndexOf("ss秒") > -1)
                            strList.Add(string.Format("{0:D2}", dt.Second) + "秒");
                        else
                            strList.Add(string.Format("{0:D2}", dt.Second));
                    }
                    break;
            }
            // int i = 0;
            string value = lp.ExtraWord;
            for (int i = 0; i < strList.Count; i++)
            {
                //if (extraWord.Length > i)
                //{
                //    ea.SetCellValue(strList[i] + extraWord[i], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                //    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                //    {
                //        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                //        tfv.ControlValue = strList[i] + extraWord[i];
                //        tfv.FieldId = lp.LPID;
                //        tfv.FieldName = lp.CellName;
                //        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                //        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                //        tfv.ExcelSheetName = activeSheetName;

                //    }
                //    else
                //    {
                //        WF_TableFieldValue tfv = new WF_TableFieldValue();
                //        tfv.ControlValue = strList[i] + extraWord[i];
                //        tfv.FieldId = lp.LPID;
                //        tfv.FieldName = lp.CellName;
                //        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                //        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                //        tfv.ExcelSheetName = activeSheetName;
                //        valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                //    }
                //}
                //else
                //{
                //    ea.SetCellValue(strList[i], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                //    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                //    {
                //        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                //        tfv.ControlValue = strList[i];
                //        tfv.FieldId = lp.LPID;
                //        tfv.FieldName = lp.CellName;
                //        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                //        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                //        tfv.ExcelSheetName = activeSheetName;

                //    }
                //    else
                //    {
                //        WF_TableFieldValue tfv = new WF_TableFieldValue();
                //        tfv.ControlValue = strList[i];
                //        tfv.FieldId = lp.LPID;
                //        tfv.FieldName = lp.CellName;
                //        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                //        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                //        tfv.ExcelSheetName = activeSheetName;
                //        valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                //    }
                //}
                if (lp.ExtraWord == "")
                {
                    if (arrCellPos.Length > 1)
                    {
                        if (dt.ToString("yyyyMMdd") == "00010101")
                        {
                            strList[i] = " ";
                        }
                        try
                        {
                            if (lp.isExplorer != 1) ea.SetCellValue("'" + strList[i], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                        }
                        catch { }

                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                            tfv.ControlValue = strList[i];
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                            tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                            tfv.ExcelSheetName = activeSheetName;

                            tfv = valuehs[lp.LPID + "$" + arrCellPos[i] + "时间"] as WF_TableFieldValue;
                            if (tfv != null)
                            {
                                tfv.ControlValue = dt.ToString();
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName + "完整时间";
                                tfv.XExcelPos = -1;
                                tfv.YExcelPos = -1;
                                tfv.ExcelSheetName = activeSheetName;
                            }
                        }
                        else
                        {
                            if (dt.ToString("yyyyMMdd") == "00010101")
                            {
                                strList[i] = " ";
                            }
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = strList[i];
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                            tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                            tfv.ExcelSheetName = activeSheetName;
                            valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);

                            tfv = new WF_TableFieldValue();
                            tfv.FieldId = lp.LPID;
                            tfv.ControlValue = dt.ToString();
                            tfv.FieldName = lp.CellName + "完整时间";
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;
                            tfv.ExcelSheetName = activeSheetName;
                            valuehs.Add(lp.LPID + "$" + arrCellPos[i] + "完整时间", tfv);


                        }
                    }
                    else
                    {
                        if (dt.ToString("yyyyMMdd") == "00010101")
                        {
                            //for (int item = 0; i < strList.Count; i++)
                            if (strList[i].IndexOf("年") > -1) strList[i] = "年";
                            else
                                if (strList[i].IndexOf("月") > -1) strList[i] = "      月";
                                else
                                    if (strList[i].IndexOf("日") > -1) strList[i] = "      日";
                                    else
                                        if (strList[i].IndexOf("时") > -1) strList[i] = "      时";
                                        else
                                            if (strList[i].IndexOf("分") > -1) strList[i] = "      分";
                        }
                        value += strList[i];
                        if (strList.Count == i + 1)
                        {
                            try
                            {
                                if (lp.isExplorer != 1) ea.SetCellValue("'" + value, GetCellPos(arrCellPos[0])[0], GetCellPos(arrCellPos[0])[1]);
                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[0]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[0]] as WF_TableFieldValue;
                                tfv.ControlValue = value;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                                tfv.ExcelSheetName = activeSheetName;

                                tfv = valuehs[lp.LPID + "$" + arrCellPos[0] + "时间"] as WF_TableFieldValue;
                                if (tfv != null)
                                {
                                    tfv.ControlValue = dt.ToString();
                                    tfv.FieldId = lp.LPID;
                                    tfv.FieldName = lp.CellName + "完整时间";
                                    tfv.XExcelPos = -1;
                                    tfv.YExcelPos = -1;
                                    tfv.ExcelSheetName = activeSheetName;
                                }

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = value;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                                tfv.ExcelSheetName = activeSheetName;
                                valuehs.Add(lp.LPID + "$" + arrCellPos[0], tfv);

                                tfv = new WF_TableFieldValue();
                                tfv.FieldId = lp.LPID;
                                tfv.ControlValue = dt.ToString();
                                tfv.FieldName = lp.CellName + "完整时间";
                                tfv.XExcelPos = -1;
                                tfv.YExcelPos = -1;
                                tfv.ExcelSheetName = activeSheetName;
                                valuehs.Add(lp.LPID + "$" + arrCellPos[0] + "完整时间", tfv);
                            }
                        }
                    }
                }
                else
                {
                    if (dt.ToString("yyyyMMdd") == "00010101")
                    {
                        strList[i] = " ";
                    }
                    if (lp.ExtraWord.IndexOf("|") == -1)
                    {
                        value = value.Replace("{" + i + "}", strList[i]);
                        if (i == strList.Count - 1)
                        {
                            try
                            {
                                if (lp.isExplorer != 1) ea.SetCellValue("'" + value, GetCellPos(arrCellPos[0])[0], GetCellPos(arrCellPos[0])[1]);
                            }
                            catch { }
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[0]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[0]] as WF_TableFieldValue;
                                tfv.ControlValue = value;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                                tfv.ExcelSheetName = activeSheetName;

                                tfv = valuehs[lp.LPID + "$" + arrCellPos[0] + "时间"] as WF_TableFieldValue;
                                if (tfv != null)
                                {
                                    tfv.ControlValue = dt.ToString();
                                    tfv.FieldId = lp.LPID;
                                    tfv.FieldName = lp.CellName + "完整时间";
                                    tfv.XExcelPos = -1;
                                    tfv.YExcelPos = -1;
                                    tfv.ExcelSheetName = activeSheetName;
                                }
                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = value;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                                tfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                                tfv.ExcelSheetName = activeSheetName;
                                valuehs.Add(lp.LPID + "$" + arrCellPos[0], tfv);

                                tfv = new WF_TableFieldValue();
                                tfv.FieldId = lp.LPID;
                                tfv.ControlValue = dt.ToString();
                                tfv.FieldName = lp.CellName + "完整时间";
                                tfv.XExcelPos = -1;
                                tfv.YExcelPos = -1;
                                tfv.ExcelSheetName = activeSheetName;
                                valuehs.Add(lp.LPID + "$" + arrCellPos[0] + "完整时间", tfv);

                            }
                        }

                    }
                    else
                    {
                        if (dt.ToString("yyyyMMdd") == "00010101")
                        {
                            strList[i] = " ";
                        }
                        string[] strextrlist = lp.ExtraWord.Split('|');
                        value = strList[i];
                        if (strextrlist.Length > i)
                            value += strextrlist[i];
                        try
                        {
                            if (lp.isExplorer != 1) ea.SetCellValue("'" + value, GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                        }
                        catch { }
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[0]))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = value;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                            tfv.ExcelSheetName = activeSheetName;

                            tfv = valuehs[lp.LPID + "$" + arrCellPos[0] + "时间"] as WF_TableFieldValue;
                            if (tfv != null)
                            {
                                tfv.ControlValue = dt.ToString();
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName + "完整时间";
                                tfv.XExcelPos = -1;
                                tfv.YExcelPos = -1;
                                tfv.ExcelSheetName = activeSheetName;
                            }
                        }
                        else
                        {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = value;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellPos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellPos[0])[1];
                            tfv.ExcelSheetName = activeSheetName;
                            valuehs.Add(lp.LPID + "$" + arrCellPos[0], tfv);

                            tfv = new WF_TableFieldValue();
                            tfv.FieldId = lp.LPID;
                            tfv.ControlValue = dt.ToString();
                            tfv.FieldName = lp.CellName + "完整时间";
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;
                            tfv.ExcelSheetName = activeSheetName;
                            valuehs.Add(lp.LPID + "$" + arrCellPos[0] + "完整时间", tfv);
                        }
                    }
                    //ea.SetCellValue(strList[i], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);

                }

            }
            //foreach (string str in strList)
            //{
            //    ea.SetCellValue(str, GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
            //    i++;
            //}
        }
Пример #17
0
        public void FillTime(ExcelAccess ea, LP_Temple lp, DateTime dt) {
            string[] arrCellPos = lp.CellPos.Split(pchar);
            arrCellPos = StringHelper.ReplaceEmpty(arrCellPos).Split(pchar);
            string[] extraWord = lp.ExtraWord.Split(pchar);
            IList<string> strList = new List<string>();
            //if (arrCellPos.Length == 5)
            //{
            //    strList.Add(dt.Year.ToString()); strList.Add(dt.Month.ToString());
            //    strList.Add(dt.Day.ToString()); strList.Add(dt.Hour.ToString()); strList.Add(dt.Minute.ToString());
            //}
            //else if (arrCellPos.Length == 4)
            //{
            //    strList.Add(dt.Day.ToString()); strList.Add(dt.Hour.ToString()); strList.Add(dt.Minute.ToString());
            //}
            //else if (arrCellPos.Length == 3)
            //{
            //    // strList.Add(dt.Year.ToString()); strList.Add(dt.Month.ToString());
            //    //strList.Add(dt.Day.ToString()); strList.Add(dt.Hour.ToString()); strList.Add(dt.Minute.ToString());
            //    strList.Add(dt.Year.ToString());
            //    strList.Add(dt.Month.ToString());
            //    strList.Add(dt.Day.ToString());
            //}
            //else if (arrCellPos.Length == 2)
            //{
            //    strList.Add(dt.Hour.ToString());
            //    strList.Add(dt.Minute.ToString());
            //}
            //else if (arrCellPos.Length == 1)
            //{
            //    strList.Add(dt.ToString());
            //}
            switch (lp.WordCount) {
                case "yyyy-MM-dd":
                    strList.Add(dt.Year.ToString());
                    strList.Add(dt.Month.ToString());
                    strList.Add(dt.Day.ToString());
                    break;
                case "MM-dd日":
                    strList.Add(dt.Month.ToString());
                    strList.Add(dt.Day.ToString());
                    break;
                case "yyyy-MM-dd HH:mm:ss":
                    strList.Add(dt.Year.ToString());
                    strList.Add(dt.Month.ToString());
                    strList.Add(dt.Day.ToString());
                    strList.Add(dt.Hour.ToString());
                    strList.Add(dt.Second.ToString());
                    break;
                case "HH:mm:ss":
                    strList.Add(dt.Hour.ToString());
                    strList.Add(dt.Minute.ToString());
                    strList.Add(dt.Second.ToString());
                    break;
                case "MM-dd日 HH:mm":
                    strList.Add(dt.Month.ToString());
                    strList.Add(dt.Day.ToString());
                    strList.Add(dt.Hour.ToString());
                    strList.Add(dt.Minute.ToString());
                    break;
                case "dd日 HH:mm":
                    strList.Add(dt.Day.ToString());
                    strList.Add(dt.Hour.ToString());
                    strList.Add(dt.Minute.ToString());
                    break;
                case "HH:mm":
                    strList.Add(dt.Hour.ToString());
                    strList.Add(dt.Minute.ToString());
                    break;
                default:
                    strList.Add(dt.Year.ToString());
                    strList.Add(dt.Month.ToString());
                    strList.Add(dt.Day.ToString());
                    strList.Add(dt.Hour.ToString());
                    strList.Add(dt.Minute.ToString());
                    break;
            }
            // int i = 0;
            for (int i = 0; i < strList.Count; i++) {
                if (extraWord.Length > i) {
                    ea.SetCellValue("'" + strList[i] + extraWord[i], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i])) {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                        tfv.ControlValue = strList[i] + extraWord[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                        tfv.ExcelSheetName = activeSheetName;
                        tfv = valuehs[lp.LPID + "$" + arrCellPos[i] + "时间"] as WF_TableFieldValue;
                        if (tfv != null) {
                            tfv.ControlValue = dt.ToString();
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName + "完整时间";
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;
                            tfv.ExcelSheetName = activeSheetName;
                        }
                    } else {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = strList[i] + extraWord[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                        tfv.ExcelSheetName = activeSheetName;
                        valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);

                        tfv = new WF_TableFieldValue();
                        tfv.FieldId = lp.LPID;
                        tfv.ControlValue = dt.ToString();
                        tfv.FieldName = lp.CellName + "完整时间";
                        tfv.XExcelPos = -1;
                        tfv.YExcelPos = -1;
                        tfv.ExcelSheetName = activeSheetName;
                        valuehs.Add(lp.LPID + "$" + arrCellPos[i] + "完整时间", tfv);
                    }
                } else {
                    ea.SetCellValue("'" + strList[i], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i])) {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                        tfv.ControlValue = strList[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                        tfv.ExcelSheetName = activeSheetName;

                        tfv = valuehs[lp.LPID + "$" + arrCellPos[0] + "时间"] as WF_TableFieldValue;
                        if (tfv != null) {
                            tfv.ControlValue = dt.ToString();
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName + "完整时间";
                            tfv.XExcelPos = -1;
                            tfv.YExcelPos = -1;
                            tfv.ExcelSheetName = activeSheetName;
                        }

                    } else {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = strList[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                        tfv.ExcelSheetName = activeSheetName;
                        valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);

                        tfv = new WF_TableFieldValue();
                        tfv.FieldId = lp.LPID;
                        tfv.ControlValue = dt.ToString();
                        tfv.FieldName = lp.CellName + "完整时间";
                        tfv.XExcelPos = -1;
                        tfv.YExcelPos = -1;
                        tfv.ExcelSheetName = activeSheetName;
                        valuehs.Add(lp.LPID + "$" + arrCellPos[0] + "完整时间", tfv);
                    }
                }

            }
            //foreach (string str in strList)
            //{
            //    ea.SetCellValue(str, GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
            //    i++;
            //}
        }
Пример #18
0
        private void LPFrm_Load(object sender, EventArgs e)
        {
            loadbasedata();
            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
            if (tempCtrlList == null)
            {
                tempCtrlList = new List<Control>();
            }
            //InitializeComponent();
            if (valuehs == null)
                valuehs = new Hashtable();
            InitIndex();
            if (kind == null) return;
            if (GetWorkFlowNmae(kind).IndexOf("电力线路") > -1)
            {
                bhht.Clear();
                bhht.Add("宝山供电所", "01");
                bhht.Add("长发供电所", "02");
                bhht.Add("绥胜供电所", "03");
                bhht.Add("红旗供电所", "04");
                bhht.Add("永安供电所", "05");
                bhht.Add("连岗供电所", "06");
                bhht.Add("太平供电所", "07");
                bhht.Add("新华供电所", "08");
                bhht.Add("北郊供电所", "09");

                bhht.Add("东郊供电所", "10");
                bhht.Add("东富供电所", "11");
                bhht.Add("兴福供电所", "12");
                bhht.Add("利民供电所", "13");
                bhht.Add("东津供电所", "14");
                bhht.Add("津河供电所", "15");
                bhht.Add("龙太供电所", "16");
                bhht.Add("秦家供电所", "17");
                bhht.Add("双河供电所", "18");
                bhht.Add("五营供电所", "19");
                bhht.Add("三河供电所", "20");

                bhht.Add("四方台供电所", "21");
                bhht.Add("张维供电所", "22");
                bhht.Add("民吉供电所", "23");
                bhht.Add("三井供电所", "24");
                bhht.Add("联合供电所", "25");
                bhht.Add("新生供电所", "26");
                bhht.Add("张维变电所", "27");

                bhht.Add("秦家变电所", "28");
                bhht.Add("四方台变电所", "29");
                bhht.Add("三河变电所", "30");
                bhht.Add("长发变电所", "31");
                bhht.Add("五营变电所", "32");
                bhht.Add("新华变电所", "33");
                bhht.Add("太平变电所", "34");

                bhht.Add("红旗变电所", "35");
                bhht.Add("连岗变电所", "36");
                bhht.Add("津河变电所", "37");
                bhht.Add("送变电工区", "38");


            }
            //InitContorl();
            WF_TableFieldValue wfv = null;
            ExcelAccess ea = new ExcelAccess();
            LP_Temple lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where  ParentID='" + parentTemple.LPID + "' and SortID=1");
            if (lp != null)
            {
                if (wfv == null)
                {
                    wfv = new WF_TableFieldValue();
                    wfv.ID = wfv.CreateID();
                    wfv.RecordId = currRecord.ID;
                    wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                    wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                    wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                    wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                    wfv.UserControlId = parentTemple.LPID;
                    wfv.ControlValue = "";
                    wfv.FieldId = lp.LPID;
                    wfv.FieldName = lp.CellName;
                    wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                }
                wfv = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                 + " and   WorkflowId='" + wfv.WorkFlowId + "'"
                                 + " and   RecordId='" + wfv.RecordId + "'"
                                 + " and   UserControlId='" + wfv.UserControlId + "'"
                                 + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
                                 + " and   fieldname='" + lp.CellName + "'"
                                 + " and   FieldId='" + lp.LPID + "' and Bigdata is not null"
                                );

            }
            if (status == "add" && parentTemple.DocContent != null && parentTemple.DocContent.Length > 0)
            {
                if (wfv != null && wfv.Bigdata != null && wfv.Bigdata.Length > 0)
                {
                    this.dsoFramerWordControl1.FileDataGzip = wfv.Bigdata;
                }
                else
                    if (GetWorkFlowNmae(kind).IndexOf("电力线路") > -1 && currRecord.DocContent != null && currRecord.DocContent.Length > 0)
                        this.dsoFramerWordControl1.FileDataGzip = currRecord.DocContent;
                    else
                        this.dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent;
                InitContorl();
            }
            else if (status == "edit")
            {
                if (currRecord.DocContent == null)
                {
                    currRecord.DocContent = new byte[0];
                }
                if (currRecord.ID.IndexOf("N") == -1)
                {
                    this.dsoFramerWordControl1.FileDataGzip = currRecord.DocContent;
                }
                else
                {
                    if (wfv != null && wfv.Bigdata != null && wfv.Bigdata.Length > 0)
                    {
                        this.dsoFramerWordControl1.FileDataGzip = wfv.Bigdata;
                    }
                    else
                        if (GetWorkFlowNmae(kind).IndexOf("电力线路") > -1 && currRecord.DocContent != null && currRecord.DocContent.Length > 0)
                            this.dsoFramerWordControl1.FileDataGzip = currRecord.DocContent;
                        else
                            this.dsoFramerWordControl1.FileDataGzip = parentTemple.DocContent;
                }
                InitContorl();

                //LoadContent();
            }

            if ((parentTemple != null && parentTemple.DocContent != null) || (currRecord != null && currRecord.DocContent != null && currRecord.DocContent.Length > 0))
            {
                wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;

                //sheet = wb.Application.Sheets[activeSheetName] as Excel.Worksheet;

                //activeSheetIndex = sheet.Index;
                try
                {
                    for (int i = 1; i <= wb.Application.Sheets.Count; i++)
                    {

                        sheet = wb.Application.Sheets[i] as Excel.Worksheet;
                        Workbook_SheetDeactivate(sheet);
                        //保护工作表
                        LockExcel(wb, sheet);
                        //if (i != activeSheetIndex)
                        //{
                        //    Excel.Worksheet tmpSheet = (Excel.Worksheet)wb.Application.Sheets.get_Item(i);
                        //    try
                        //    {
                        //        if (tmpSheet != null) tmpSheet.Visible = Excel.XlSheetVisibility.xlSheetHidden;

                        //    }
                        //    catch { }

                    }

                }
                catch { }
            }
            IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList",
                    " where RecordId='" + currRecord.ID + "' and UserControlId='" + parentTemple.LPID + "' and   WorkflowId='" + WorkFlowData.Rows[0]["WorkflowId"] + "' and WorkFlowInsId='" + WorkFlowData.Rows[0]["WorkFlowInsId"] + "' order by YExcelPos,XExcelPos");

            Excel.Worksheet xx;
            wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            string activeSheetName = "";
            try
            {
                xx = wb.Application.Sheets[1] as Excel.Worksheet;
            }
            catch { }

            for (int i = 0; i < tfvli.Count; i++)
            {

                Control ctl = FindCtrl(tfvli[i].FieldId);
                if (ctl != null)
                {
                    lp = ctl.Tag as LP_Temple;
                    if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit") == false)
                    {
                        if (lp.CellName != "编号")
                        {
                            if (ctl.Text.IndexOf(tfvli[i].ControlValue) == -1)
                                ctl.Text += tfvli[i].ControlValue;
                        }
                        else
                        {
                            ctl.Text = tfvli[i].ControlValue;
                        }
                        ctl.Focus();
                    }
                    else
                    {

                        IList<WF_TableFieldValue> tfvlitemp = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList",
                    " where RecordId='" + currRecord.ID + "' and UserControlId='" + parentTemple.LPID + "' and   WorkflowId='" + WorkFlowData.Rows[0]["WorkflowId"] + "' and WorkFlowInsId='" + WorkFlowData.Rows[0]["WorkFlowInsId"] + "'  and FieldId='" + tfvli[i].FieldId.ToString() + "' and FieldName='" + tfvli[i].FieldName + "完整时间' order by id desc, YExcelPos,XExcelPos");
                        if (tfvlitemp.Count > 0)
                        {
                            ((DevExpress.XtraEditors.DateEdit)ctl).DateTime = Convert.ToDateTime(tfvlitemp[0].ControlValue);
                        }
                        //((DevExpress.XtraEditors.DateEdit)ctl).DateTime = Convert.ToDateTime(tfvli[i].ControlValue);
                    }
                }
            }
            dsoFramerWordControl1.FileSave();
            //保护工作表
            //    LockExcel(wb,sheet);
            //}
        }
Пример #19
0
        public void FillMutilRowsT(ExcelAccess ea, LP_Temple lp, string str, int cellcount, string arrCellPos, string coltemp) {
            StringHelper help = new StringHelper();
            //str = help.GetPlitString(str, cellcount);
            string[] arrRst = str.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            if (lp.ExtraWord == "横向") {
                for (int i = 0; i < arrRst.Length; i++) {
                    ea.SetCellValue("'" + arrRst[i], GetCellPos(arrCellPos)[0], GetCellPos(arrCellPos)[1] + i);
                    if (valuehs.ContainsKey(lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1])) {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1]] as WF_TableFieldValue;
                        tfv.ControlValue = arrRst[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName + "-" + coltemp;
                        tfv.XExcelPos = GetCellPos(arrCellPos)[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos)[1] + i;
                        tfv.ExcelSheetName = activeSheetName;

                    } else {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = arrRst[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName + "-" + coltemp;
                        tfv.XExcelPos = GetCellPos(arrCellPos)[0];
                        tfv.YExcelPos = GetCellPos(arrCellPos)[1] + i;
                        tfv.ExcelSheetName = activeSheetName;
                        valuehs.Add(lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1], tfv);
                    }
                }
            } else {
                for (int i = 0; i < arrRst.Length; i++) {

                    ea.SetCellValue("'" + arrRst[i], GetCellPos(arrCellPos)[0] + i, GetCellPos(arrCellPos)[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1])) {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1]] as WF_TableFieldValue;
                        tfv.ControlValue = arrRst[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName + "-" + coltemp;
                        tfv.XExcelPos = GetCellPos(arrCellPos)[0] + i;
                        tfv.YExcelPos = GetCellPos(arrCellPos)[1];
                        tfv.ExcelSheetName = activeSheetName;

                    } else {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = arrRst[i];
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName + "-" + coltemp;
                        tfv.XExcelPos = GetCellPos(arrCellPos)[0] + i;
                        tfv.YExcelPos = GetCellPos(arrCellPos)[1];
                        tfv.ExcelSheetName = activeSheetName;
                        valuehs.Add(lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1], tfv);
                    }
                }
            }
        }
Пример #20
0
        void btn_Save_Click(object sender, EventArgs e)
        {

            dsoFramerWordControl1.FileSave();
            try
            {
                currRecord.LastChangeTime = DateTime.Now.ToString();
                currRecord.DocContent = dsoFramerWordControl1.FileDataGzip;
                if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
                if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
                Client.ClientHelper.PlatformSqlMap.Update("UpdateLP_Record", currRecord);
                ArrayList akeys = new ArrayList(valuehs.Keys);
                List<object> list = new List<object>();

                DateTime dt = DateTime.Now;
                Random rd = new Random();
                WF_TableFieldValue wfv = null;
                int irpos = 5001;
                decimal dtemp = Convert.ToDecimal(dt.ToString("yyyyMMddHHmmssffffff"));
                for (int i = 0; i < akeys.Count; i++)
                {
                    wfv = valuehs[akeys[i]] as WF_TableFieldValue;
                    if (wfv.XExcelPos != -1 && wfv.YExcelPos != -1)
                        wfv.ID = Convert.ToString((dtemp + wfv.YExcelPos + wfv.XExcelPos * 10000));
                    else
                    {

                        wfv.ID = Convert.ToString((dtemp + irpos + irpos * 10000));
                        irpos++;
                    }
                    wfv.RecordId = currRecord.ID;
                    wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                    wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                    wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                    wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                    wfv.UserControlId = parentTemple.LPID;
                    //MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                    //Thread.Sleep(new TimeSpan(100000));//0.1毫秒
                    list.Add(wfv);
                    MainHelper.PlatformSqlMap.DeleteByWhere<WF_TableFieldValue>(" where FieldId ='" + wfv.FieldId + "' and WorkFlowInsId='" + WorkFlowData.Rows[0]["WorkFlowInsId"].ToString() + "' and WorkTaskId='" + WorkFlowData.Rows[0]["WorkTaskId"].ToString() + "'");
                }
                //foreach (WF_TableFieldValue wfv in list)
                //{
                //    Console.Write(wfv.ID + "\r\n");
                //}
                foreach (WF_TableFieldValue wfv2 in list)
                {
                    WF_TableFieldValue wtfvtemp = Client.ClientHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                         + " and   WorkflowId='" + wfv2.WorkFlowId + "'"
                         + " and   RecordId='" + wfv2.RecordId + "'"
                         + " and   UserControlId='" + wfv2.UserControlId + "'"
                         + " and   WorkFlowInsId='" + wfv2.WorkFlowInsId + "'"
                         + " and   fieldname='" + wfv2.FieldName + "'"
                         + " and   FieldId='" + wfv2.FieldId + "'"
                         + " and   XExcelPos='" + wfv2.XExcelPos + "'"
                         + " and   YExcelPos='" + wfv2.YExcelPos + "'"
                         + " and   WorkTaskId='" + wfv2.WorkTaskId + "'"
                         );
                    if (wtfvtemp != null)
                        wfv2.ID = wtfvtemp.ID;
                    else
                    {
                        Client.ClientHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv2);
                    }
                }
                Client.ClientHelper.PlatformSqlMap.ExecuteTransationUpdate(null, list, null);
                LP_Temple lp = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where  ParentID='" + parentTemple.LPID + "' and SortID=1");
                if (lp != null)
                {
                    if (wfv == null)
                    {
                        wfv = new WF_TableFieldValue();
                        wfv.ID = wfv.CreateID();
                        wfv.RecordId = currRecord.ID;
                        wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                        wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                        wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                        wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                        wfv.UserControlId = parentTemple.LPID;
                        wfv.ControlValue = "";
                        wfv.FieldId = lp.LPID;
                        wfv.FieldName = lp.CellName;
                        wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                        wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                        wfv.ExcelSheetName = activeSheetName;
                    }

                    wfv = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                     + " and   WorkflowId='" + wfv.WorkFlowId + "'"
                                     + " and   RecordId='" + wfv.RecordId + "'"
                                     + " and   UserControlId='" + wfv.UserControlId + "'"
                                     + " and   WorkFlowInsId='" + wfv.WorkFlowInsId + "'"
                                     + " and   fieldname='" + lp.CellName + "'"
                                     + " and   FieldId='" + lp.LPID + "' and Bigdata is not null"
                                    );
                    dsoFramerWordControl1.FileSave();
                    currRecord.DocContent = dsoFramerWordControl1.FileDataGzip;
                    if (currRecord.ImageAttachment == null) currRecord.ImageAttachment = new byte[0];
                    if (currRecord.SignImg == null) currRecord.SignImg = new byte[0];
                    if (wfv == null)
                    {
                        wfv = new WF_TableFieldValue();
                        wfv.ID = wfv.CreateID();
                        wfv.RecordId = currRecord.ID;
                        wfv.WorkFlowId = WorkFlowData.Rows[0]["WorkFlowId"].ToString();
                        wfv.WorkFlowInsId = WorkFlowData.Rows[0]["WorkFlowInsId"].ToString();
                        wfv.WorkTaskId = WorkFlowData.Rows[0]["WorkTaskId"].ToString();
                        wfv.WorkTaskInsId = WorkFlowData.Rows[0]["WorkTaskInsId"].ToString();
                        wfv.UserControlId = parentTemple.LPID;
                        wfv.ControlValue = "";
                        wfv.FieldId = lp.LPID;
                        wfv.FieldName = lp.CellName;
                        wfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                        wfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                        wfv.ExcelSheetName = activeSheetName;
                        wfv.Bigdata = currRecord.DocContent;
                        MainHelper.PlatformSqlMap.Create<WF_TableFieldValue>(wfv);
                    }
                    else
                    {
                        wfv.Bigdata = currRecord.DocContent;
                        MainHelper.PlatformSqlMap.Update<WF_TableFieldValue>(wfv);

                    }
                }
                MsgBox.ShowTipMessageBox("保存成功!");
                //this.DialogResult = DialogResult.OK;
            }
            catch
            {
                MsgBox.ShowTipMessageBox("出错,保存失败!");
            }
        }
Пример #21
0
 private void btReEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     DataRow dr = gridView1.GetFocusedDataRow();
    
     WF_TableFieldValue tf = new WF_TableFieldValue();
     tf.ID= dr["RecordId"].ToString();
     frmAQYXJLMBTemplate fm = new frmAQYXJLMBTemplate();
     fm.Status = "edit";
     fm.ModleGuid = modleGuid;
     fm.OrgName = parentObj.OrgName;
     fm.RowData = tf;
     if (fm.ShowDialog() == DialogResult.OK)
     {
         InitData();
     }
 }
Пример #22
0
        public static void ExportExcelTQ(string tqCode)
        {
             ExcelAccess ea = new ExcelAccess();
            //SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            string fname =Application.StartupPath + "\\00记录模板\\20低压设备完好率及台区网络图";
            //Ecommon.WriteDoc(obj.BigData,ref fname);
            
            
            //saveFileDialog1.Filter = "Microsoft Excel (*.xls)|*.xls";
            //if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                LP_Temple parentTemple = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where ( ParentID not in (select LPID from LP_Temple where 1=1 and  CtrlSize!='目录') and  CtrlSize!='目录' ) and  CellName like '%低压线路完好率及台区网络图%'");
                LP_Temple lp2 = MainHelper.PlatformSqlMap.GetOne<LP_Temple>(" where  ParentID='" + parentTemple.LPID + "' and SortID=1");
                WF_TableFieldValue wfv = new WF_TableFieldValue();
                    //wfv.ID = wfv.CreateID();
                    //wfv.WorkFlowId = tqCode;
                    //wfv.WorkTaskId = "20低压设备完好率及台区网络图";
                    //wfv.WorkTaskInsId = "20低压设备完好率及台区网络图";
                    //wfv.UserControlId = parentTemple.LPID;
                    //wfv.ControlValue = "";
                    //wfv.FieldId = lp2.LPID;
                

                wfv = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(" where  UserControlId='" + parentTemple.LPID + "'"
                                 + " and   WorkflowId='" + tqCode + "'"
                                 + " and   UserControlId='" + parentTemple.LPID + "'"
                                 + " and   fieldname='" + lp2.CellName + "'"
                                 + " and   FieldId='" + lp2.LPID + "' and Bigdata is not null"
                                );
                DSOFramerControl ds1 = new DSOFramerControl();
                //fname = saveFileDialog1.FileName;
                try
                {;
                IList<LP_Temple> templeList = null;
                 //parentTemple = MainHelper.PlatformSqlMap.GetOne<LP_Temple>("where ( ParentID not in (select LPID from LP_Temple where 1=1 and  CtrlSize!='目录') and  CtrlSize!='目录' ) and  CellName like '%低压线路完好率及台区网络图%'");
                if (parentTemple != null)
                    {
                        if (wfv != null && wfv.Bigdata != null && wfv.Bigdata.Length > 0)
                        ds1.FileDataGzip = wfv.Bigdata;
                        else
                            ds1.FileDataGzip = parentTemple.DocContent;
                        //ds1.FileSave(fname, true);
                        fname = ds1.FileName;
                        ds1.FileClose();
                        
                        
                        ea.Open(fname);
                        templeList = MainHelper.PlatformSqlMap.GetList<LP_Temple>("SelectLP_TempleList",
                            "where ParentID ='" + parentTemple.LPID + "' order by SortID");
                        
                        string valEX = @"[0-9]+(\.)?[0-9]+$";//只允许整数或小数的正则表达式
                        int i=0;
                        ArrayList al = new ArrayList();

                        string activeSheetName = "";
                        foreach (LP_Temple lp in templeList)
                        {
                            object obj = null;
                            double sum = 0;
                            int idw = 1;
                            string value = "";
                            if (lp.isExplorer == 1)
                            {
                                continue;
                            }
                            if ((lp.CellName.IndexOf("补偿电容") > -1 || lp.CellName.IndexOf("电动机") > -1 || lp.CellName.Trim().IndexOf("机井") > -1
                                || lp.CellName.IndexOf("农副业") > -1 || lp.CellName.IndexOf("照明户数") > -1
                                || lp.CellName.IndexOf("单相表数") > -1 || lp.CellName.IndexOf("三相表数") > -1) == false)
                            {
                                continue;
                            }
                            IList<WF_TableFieldValue> tfvli = MainHelper.PlatformSqlMap.GetList<WF_TableFieldValue>("SelectWF_TableFieldValueList",
                            " where   UserControlId='" + parentTemple.LPID + "' and   WorkflowId='" + tqCode + "' and WorkTaskInsId='20低压设备完好率及台区网络图'"
                            + " and  FieldId='" + lp.LPID + "' "
                            + " order by YExcelPos");
                         
                            foreach (WF_TableFieldValue tfv in tfvli)
                            {
                                WF_TableFieldValue tfvtemp = MainHelper.PlatformSqlMap.GetOne<WF_TableFieldValue>(
                                " where   UserControlId='" + parentTemple.LPID+"'"
                                + " and   WorkflowId='" + tqCode + "'"
                                + " and   RecordId='" + tfv.RecordId + "'"
                                + " and   FieldName='类型'"
                                +" and WorkTaskInsId='20低压设备完好率及台区网络图'"
                                + " order by YExcelPos");
                                if (tfvtemp != null && tfvtemp.ControlValue == "新增")
                                    idw = 1;
                                else
                                    if (tfvtemp != null && tfvtemp.ControlValue == "减少")
                                        idw = -1;
                                    else
                                        idw = 1;

                                if (tfv.FieldName.IndexOf("时间") == -1&&lp.IsVisible==0)
                                {
                                    valEX = "^[0-9]+(\\.)?([0-9]+)?$";
                                    if (tfv.ControlValue == "" || Regex.Match(tfv.ControlValue, valEX).Value!="")
                                    {
                                        if (tfv.ControlValue == "")
                                            sum += 0;
                                        else
                                            sum += idw * Convert.ToDouble(tfv.ControlValue);
                                        value = sum.ToString();
                                    }
                                    else
                                    {
                                        valEX = "^[0-9]+(\\.)?([0-9]+)?/[0-9]+(\\.)?([0-9]+)?";
                                        if (Regex.Match(tfv.ControlValue, valEX).Value != "")
                                        {
                                            string[] str1 = tfv.ControlValue.Split('/');
                                            if (value == "")
                                            {

                                                value = (idw * Convert.ToDouble(str1[0])).ToString() + "/" + (idw * Convert.ToDouble(str1[1])).ToString();
                                            }
                                            else if (value.IndexOf('/')>-1)
                                            {
                                                string[] str2 = value.Split('/');
                                                sum = idw * Convert.ToDouble(str1[0]) + Convert.ToDouble(str2[0]);
                                                value = sum.ToString();
                                                sum = idw * Convert.ToDouble(str1[1]) + Convert.ToDouble(str2[1]);
                                                value = value + "/" + sum.ToString();
                                            }
                                        }
                                        else
                                        {
                                            value = tfv.ControlValue;
                                        }
                                        
                                    }
                                }
                                else
                                {
                                    value = tfv.ControlValue;
                                   
                                }
                            }
                          
                               
                                if (activeSheetName != lp.KindTable)
                                {
                                    
                                    activeSheetName = lp.KindTable;
                                    ea.ActiveSheet(activeSheetName);
                                }
                                if (value != null && tfvli.Count > 0 && tfvli[0].XExcelPos > 0 && tfvli[0].XExcelPos > 0)
                                {
                                    string strvalue = value;
                                    valEX = "^[0-9]+(\\.)?([0-9]+)?$";
                                    if (value == "" || Regex.Match(value, valEX).Value != "")
                                    {
                                        if (value=="")
                                            strvalue = value;
                                        else
                                        {
                                            strvalue = Math.Round(Convert.ToDecimal(value), 3).ToString(); 
                                        }

                                    }
                                    else
                                    {
                                        valEX = "^[0-9]+(\\.)?([0-9]+)?/[0-9]+(\\.)?([0-9]+)?";
                                        if (Regex.Match(value, valEX).Value != "")
                                        {
                                            string[] str1 = value.Split('/');

                                            strvalue = Math.Round(Convert.ToDecimal(str1[0]), 3).ToString() + "/" + Math.Round(Convert.ToDecimal(str1[1]), 3).ToString();
                                            
                                        }
                                    }
                                    ea.SetCellValue("'" + strvalue.ToString(), tfvli[0].XExcelPos, tfvli[0].YExcelPos);
                                }

                                       


                        }
                        //if (MsgBox.ShowAskMessageBox("导出成功,是否打开该文档?") != DialogResult.OK)
                        //    return;
                    }
                ea.ShowExcel();
                    //System.Diagnostics.Process.Start(fname);
                }
                catch (Exception mex)
                {
                    Console.WriteLine(mex.Message);
                    MsgBox.ShowWarningMessageBox("无法保存" + fname + "。请用其他文件名保存文件,或将文件存至其他位置。");

                }
            }
            //此处写填充内容代码


        }