Ejemplo n.º 1
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;
        }
Ejemplo n.º 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);


                }
            }
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
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("出错,保存失败!");
            }
        }
Ejemplo n.º 5
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);
            //}
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 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;
            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;
        }
Ejemplo n.º 8
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);
            //}
        }