예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String id = Request.Params["ID"];
            if (!String.IsNullOrEmpty(id))
            {
                string SQL = "SELECT * FROM dbo.sys_document WHERE ID='" + id + "'";

                DataSet    ds  = DbHelperSQL.Query(SQL);
                string     str = ds.Tables[0].Rows[0]["Data"].ToString();
                JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(str);
                if (doc != null)
                {
                    try
                    {
                        string Temp = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "AI".RequestStr()).ToString();

                        Response.Write("<img src='data:image/gif;base64," + Temp + "'  />");
                    }
                    catch
                    {
                        Response.Write("<div style=\"width:400px;height:300px;line-height:300px; text-align:center;\">无图片或图片有误</div>");
                    }
                }
            }
        }
    }
예제 #2
0
        private void NewSheet()
        {
            TreeNode Node    = FpSheetView.SelectedNode;
            Boolean  IsSheet = Convert.ToBoolean(Node.Tag);

            if (!IsSheet)
            {
                string    Code      = DepositorySheetCatlog.GetNextCode(Node.Name);
                string    SheetName = DepositorySheetConfiguration.GetSheetName(Node.Name, "新建表单");
                Sys_Sheet sheet     = new Sys_Sheet();
                sheet.ID         = Guid.NewGuid();
                sheet.CatlogCode = Code;
                sheet.SheetData  = "";
                sheet.Name       = SheetName;
                sheet.SheetXML   = JZCommonHelper.GZipCompressString(SheetConfiguration.BlankSheet);

                Boolean Result = ModuleHelperClient.SaveSheet(sheet);
                if (Result)
                {
                    TreeNode SubNode = new TreeNode();
                    SubNode.Name = sheet.ID.ToString();
                    SubNode.Text = SheetName;
                    SubNode.SelectedImageIndex = 2;
                    SubNode.ImageIndex         = 2;
                    SubNode.Tag = true;

                    Node.Nodes.Add(SubNode);
                    Node.Expand();
                    Node.TreeView.SelectedNode = SubNode;
                }
            }
        }
예제 #3
0
 public string RoomInfo(string Cell)
 {
     try
     {
         return(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, Cell).ToString());
     }
     catch {
         return("");
     }
 }
예제 #4
0
        private string ProcessSheetLikeXML(string id, string xml)
        {
            if (IsContainerXml(xml))
            {
                var zip = JZCommonHelper.GZipCompressString(xml);
                ExcuteCommand("UPDATE dbo.sys_sheet SET SheetXML = '" + zip + "' WHERE ID='" + id + "'");
                return(zip);
            }

            return(xml);
        }
예제 #5
0
 public string RoomInfo(string Cell)
 {
     try
     {
         return(JZCommonHelper.GetCellValue(sheetDataAreaCells, sheetDataAreaCells.Sheets[0].ID, Cell).ToString());
     }
     catch
     {
         return("");
     }
 }
예제 #6
0
        private void Execute(object paremeter)
        {
            ThreadParameter p             = paremeter as ThreadParameter;
            JZDocument      document      = p.document;
            Sys_Module      module        = p.module;
            String          invalidString = "";

            if (module != null)
            {
                if (module.QualifySettings != null && module.QualifySettings.Count > 0)
                {
                    foreach (QualifySetting qs in module.QualifySettings)
                    {
                        Object obj = JZCommonHelper.GetCellValue(document, qs.SheetID, qs.CellName);
                        if (obj != null && obj.ToString() != "")
                        {
                            invalidString = obj.ToString().Trim(' ', '\r', '\n');
                            break;
                        }
                    }
                }
            }
            if (invalidString != "")
            {
                try
                {
                    String[] arr = invalidString.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr.Length < 3)
                    {
                        logger.Error("无效的不合格短信内容,document的ID为" + document.ID + ";短信内容为:" + invalidString);
                        return;
                    }
                    Boolean    needSendSMS = false;
                    SMSManager smsManager  = new SMSManager();
                    if (!p.IsAdministrator)
                    {
                        needSendSMS = smsManager.NeedSendSMS(document.ID.ToString(), invalidString);
                        logger.Error(invalidString + "needsendsms=" + needSendSMS);
                    }

                    if (needSendSMS)
                    {
                        smsManager.SendSMS(document.ID.ToString(), invalidString, p.LineID, p.TestRoomCode, p.SegmentName, p.CompanyName, p.TestRoomName, p.LineName);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("更新合格字段IsQualified失败,原因是" + ex.Message);
                }
            }
            icm.SyncInvalidReport(document.ID, invalidString);
        }
예제 #7
0
        private void HyperLinkSettingDialog_Load(object sender, EventArgs e)
        {
            if (ActiveCell.CellType is FarPoint.Win.Spread.CellType.HyperLinkCellType)
            {
                FarPoint.Win.Spread.CellType.HyperLinkCellType hlnkCell = ActiveCell.CellType as FarPoint.Win.Spread.CellType.HyperLinkCellType;

                var tag   = ActiveCell.Value as string;
                var model = "超链接";

                if (!string.IsNullOrEmpty(tag))
                {
                    model = tag;
                }

                var text = hlnkCell.Text;
                var link = hlnkCell.Link;

                switch (model)
                {
                case "超链接":
                    txtLinkUrl.Text = link;
                    break;

                case "附件":
                    Img = new Bitmap(JZCommonHelper.StringToBitmap(Convert.ToString(link)));
                    break;
                }

                if (Img == null)
                {
                    var bitmap   = new Bitmap(Preview.Width, Preview.Height);
                    var graphics = Graphics.FromImage(bitmap);
                    var brush    = new SolidBrush(Color.Gray);
                    var format   = new StringFormat();

                    format.Alignment     = StringAlignment.Center;
                    format.LineAlignment = StringAlignment.Center;
                    graphics.DrawString("当前无预览", this.Font, brush, Preview.ClientRectangle, format);     //这里文字以0,0为中心居中
                    graphics.Dispose();

                    Preview.Image = bitmap;
                }
                else
                {
                    Preview.Image = Img;
                }

                txtShowText.Text    = text;
                RadioAttach.Checked = model == "附件";
                RadioLink.Checked   = model == "超链接";
            }
        }
예제 #8
0
        /// <summary>
        /// 通过SheetID找到该Sheet的XML结构
        /// </summary>
        /// <param name="SheetIndex"></param>
        /// <returns></returns>
        public static String GetSheetXMLByID(Guid SheetIndex)
        {
            String str = Agent.CallService("Yqun.BO.BusinessManager.dll", "GetSheetXMLByID", new object[] { SheetIndex }).ToString();

            if (IsContainerXml(str))
            {
                return(str);
            }
            else
            {
                return(JZCommonHelper.GZipDecompressString(str));
            }
        }
예제 #9
0
        public JZFile GetSpecialFile(Guid moduleID)
        {
            String[] files = new String[] { "sys_biz_ModuleCatlog", "sys_biz_SheetCatlog", "sys_dictionary",
                                            "sys_formulas", "sys_module", "sys_sheet", "sys_module_sheet", "sys_stadium_config", "sys_module_config" };
            List <String> moduleIDs = new List <string>();

            moduleIDs.Add(moduleID.ToString());
            Boolean flag        = true;
            String  moduleIDStr = "'" + String.Join("','", moduleIDs.ToArray()) + "'";

            try
            {
                String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "update");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                List <String> list = new List <string>();
                foreach (String tbName in files)
                {
                    list.Add(Path.Combine(path, tbName + ".dat"));
                    flag = flag && OutPutFile(tbName, path, moduleIDStr, true);
                }
                String zipFile = Path.Combine(path, moduleID + ".zip");
                if (File.Exists(zipFile))
                {
                    File.Delete(zipFile);
                }
                flag = flag && JZCommonHelper.CreateZipFile(list, zipFile);
                if (flag)
                {
                    FileStream stream = null;
                    JZFile     f      = new JZFile();
                    f.FileName = moduleID + ".zip";
                    stream     = new FileInfo(zipFile).OpenRead();
                    Byte[] buffer = new Byte[stream.Length];
                    stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                    f.FileType = "all";
                    f.FileData = buffer;
                    stream.Close();
                    return(f);
                }
            }
            catch (Exception ex)
            {
                logger.Error("generate special file error for module " + moduleID + ": " + ex.Message);
            }
            return(null);
        }
예제 #10
0
        public Boolean RunSpecialUpdate(JZFile file, String server, String userName, String password, Guid moduleID)
        {
            String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "update");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            String fName = Path.Combine(path, file.FileName);

            File.WriteAllBytes(fName, file.FileData);
            Boolean flag = JZCommonHelper.UnZipFile(fName);

            if (flag)
            {
                String[] files = new String[] { "sys_biz_ModuleCatlog", "sys_biz_SheetCatlog", "sys_dictionary",
                                                "sys_formulas", "sys_module", "sys_sheet", "sys_module_sheet", "sys_stadium_config", "sys_module_config" };

                foreach (String item in files)
                {
                    String fPath = Path.Combine(path, item + ".dat");
                    if (File.Exists(fPath))
                    {
                        String bcp = "bcp " + Connection.Database + ".dbo." + item + "_update in " + fPath + " -c -S " + server +
                                     " -U " + userName + " -P " + password;
                        flag = flag && JZCommonHelper.ExeCommand(bcp);
                        logger.Error(bcp);
                    }
                }
                if (flag)
                {
                    String sql = @"UPDATE dbo.sys_module_update SET ID=b.ID, Name=b.Name, Description=b.Description
	                                FROM dbo.sys_module_update a JOIN dbo.sys_module b
	                                ON b.ID='"     + moduleID + @"' 
	                                UPDATE dbo.sys_formulas_update SET ModuleID='"     + moduleID + @"' 
	                                UPDATE dbo.sys_module_sheet_update SET ModuleID='"     + moduleID + @"' 
	                                UPDATE dbo.sys_module_config_update SET ModuleID='"     + moduleID + @"' 
	                                UPDATE dbo.sys_stadium_config_update SET ID='"     + moduleID + @"'";
                    ExcuteCommand(sql);
                    int i = RunStoreProcedure("sp_update");
                    flag = i > 0;
                }
            }
            return(flag);
        }
예제 #11
0
        public static FpSpread GetModuleByID(Guid moduleID, JZDocument document, String DBName)
        {
            if (moduleList.ContainsKey(moduleID))
            {
                return(moduleList[moduleID]);
            }
            else
            {
                FpSpread fpSpread = new FpSpread();
                try
                {
                    Dictionary <Guid, SheetView>            SheetCollection = new Dictionary <Guid, SheetView>();
                    List <FarPoint.CalcEngine.FunctionInfo> Infos           = DBHelper.CallLocalService("Yqun.BO.BusinessManager.dll", "GetFunctionInfosNew", new object[] { }, DBName) as List <FarPoint.CalcEngine.FunctionInfo>;

                    foreach (JZSheet sheet in document.Sheets)
                    {
                        String    xml       = DBHelper.CallLocalService("Yqun.BO.BusinessManager.dll", "GetSheetXMLByID", new object[] { sheet.ID }, DBName).ToString();
                        String    sheetXML  = JZCommonHelper.GZipDecompressString(xml);
                        SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                        SheetView.Tag = sheet.ID;
                        SheetView.Cells[0, 0].Value = "";
                        SheetView.Protect           = true;

                        fpSpread.Sheets.Add(SheetView);

                        SheetCollection.Add(sheet.ID, SheetView);

                        foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos)
                        {
                            SheetView.AddCustomFunction(Info);
                        }
                    }
                    moduleList.Add(moduleID, fpSpread);
                }
                catch (Exception ex)
                {
                    logger.Error("采集构造Farpoint组件错误:" + ex.Message);
                    return(null);
                }
                return(fpSpread);
            }
        }
예제 #12
0
 /// <summary>
 /// 同步生成相关文件
 /// </summary>
 /// <param name="fpSpread"></param>
 /// <param name="documentID"></param>
 /// <param name="reportIndex"></param>
 public void CreateRalationFilesSync(FpSpread fpSpread, Guid documentID, Int32 reportIndex, string docDateDir)
 {
     if (documentID == null || fpSpread == null)
     {
         return;
     }
     try
     {
         String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "source/" + docDateDir);
         JZCommonHelper.SaveToExcel(documentID, fpSpread, path);
         JZCommonHelper.FarpointToImage0(documentID, fpSpread, path, reportIndex);
         //String excelPath = Path.Combine(path,documentID.ToString() + ".xls");
         String pdfFilePath = Path.Combine(path, documentID.ToString() + ".pdf");
         JZCommonHelper.FarpointToPDF0(fpSpread, pdfFilePath, reportIndex);
     }
     catch (Exception ex)
     {
         logger.Error("create ralation files:" + ex.Message);
     }
 }
예제 #13
0
        private void Execute(object paremeter)
        {
            ThreadParameter p = paremeter as ThreadParameter;

            if (p.documentID == null || p.fpSpread == null)
            {
                return;
            }
            try
            {
                String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "source/" + p.docDateDir);
                JZCommonHelper.SaveToExcel(p.documentID, p.fpSpread, path);
                JZCommonHelper.FarpointToImage(p.documentID, p.fpSpread, path);
                String excelPath   = Path.Combine(path, p.documentID.ToString() + ".xls");
                String pdfFilePath = Path.Combine(path, p.documentID.ToString() + ".pdf");
                JZCommonHelper.FarpointToPDF(p.fpSpread, pdfFilePath, p.reportIndex);
            }
            catch (Exception ex)
            {
                logger.Error("create ralation files:" + ex.Message);
            }
        }
예제 #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtShowText.Text))
            {
                MessageBox.Show("请输入显示文字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtLinkUrl.Focus();
                return;
            }

            if (ActiveCell.CellType is FarPoint.Win.Spread.CellType.HyperLinkCellType)
            {
                FarPoint.Win.Spread.CellType.HyperLinkCellType hlnkCell = ActiveCell.CellType as FarPoint.Win.Spread.CellType.HyperLinkCellType;

                if (RadioAttach.Checked)
                {
                    if (Img == null)
                    {
                        MessageBox.Show("请选择附件文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    ActiveCell.Value = "附件";
                    hlnkCell.Link    = JZCommonHelper.BitmapToString(Img);
                }

                if (RadioLink.Checked)
                {
                    ActiveCell.Value = "超链接";
                    hlnkCell.Link    = txtLinkUrl.Text;
                }

                hlnkCell.Text = txtShowText.Text;

                ActiveCell.CellType = hlnkCell;
                MessageBox.Show("设置成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = DialogResult.OK;
            }
        }
예제 #15
0
        /// <summary>
        ///上传试验室综合情况
        /// </summary>
        public void UploadTestRoomInfo(string strTestRoomCodeMap, String uploadAddress, String jsdwCode)
        {
            try
            {
                Hashtable     testRoomCodeMap = InitTestRoomCodeMap(strTestRoomCodeMap);
                String        moduleID        = "E77624E9-5654-4185-9A29-8229AAFDD68B"; //试验室综合情况
                String        ksign           = "01";                                   //01表示试验室
                UploadSetting set             = GetUploadSettingByModuleID(moduleID);
                if (set != null)
                {
                    String        sql   = "SELECT TestRoomCode,Data FROM dbo.sys_document WHERE ModuleID='" + moduleID + "' AND Status>0";
                    DataTable     dt    = GetDataTable(sql);
                    List <String> files = new List <string>();
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Temp/TestDataUpload/试验室基本属性");
                        DeleteDirAllFile(path);
                        if (!Directory.Exists(path))
                        {
                            try
                            {
                                Directory.CreateDirectory(path);
                            }
                            catch (Exception ee)
                            {
                                logger.Error(ee.Message);
                            }
                        }
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            String testRoomCode = dt.Rows[i]["TestRoomCode"].ToString();
                            if (testRoomCodeMap.ContainsKey(testRoomCode))
                            {
                                testRoomCode = testRoomCodeMap[testRoomCode].ToString();
                            }

                            JZDocument doc      = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(dt.Rows[i]["Data"].ToString());
                            String     fileName = Path.Combine(path, testRoomCode + ".xml");
                            if (CreatXMLFile(set, fileName, doc, testRoomCode))
                            {
                                files.Add(fileName);
                            }
                            doc = null;
                            Thread.Sleep(3000);
                        }
                        if (files.Count > 0)
                        {
                            String zipFile = Path.Combine(path, "试验室基本属性.zip");
                            if (File.Exists(zipFile))
                            {
                                try
                                {
                                    File.Delete(zipFile);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                }
                            }
                            if (JZCommonHelper.CreateZipFile(files, zipFile))
                            {
                                FileStream stream = null;
                                stream = new FileInfo(zipFile).OpenRead();
                                Byte[] buffer = new Byte[stream.Length];
                                stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                                stream.Close();
                                String result = UploadToServer(uploadAddress, buffer, ksign, jsdwCode);
                                if (result == "1")
                                {
                                    logger.Error("试验室综合情况数据上传成功");
                                }
                                else
                                {
                                    logger.Error("试验室综合情况数据上传失败,返回值为:" + result);
                                }
                            }
                        }
                    }
                    else
                    {
                        logger.Error("未找到试验室综合情况信息");
                    }
                }
                else
                {
                    logger.Error("未找到该模板对应的上传设置");
                }
            }
            catch (Exception ex)
            {
                logger.Error("UploadTestRoomInfo error:" + ex.ToString());
            }
        }
예제 #16
0
        /// <summary>
        /// 上传人员信息
        /// </summary>
        public void UploadPersonInfo(string strTestRoomCodeMap, String uploadAddress, String jsdwCode)
        {
            try
            {
                Hashtable     testRoomCodeMap = InitTestRoomCodeMap(strTestRoomCodeMap);
                String        moduleID        = "08899BA2-CC88-403E-9182-3EF73F5FB0CE"; //试验人员
                String        ksign           = "02";                                   //02表示试验人员
                UploadSetting set             = GetUploadSettingByModuleID(moduleID);
                if (set != null)
                {
                    String        sql   = "SELECT ID,TestRoomCode,Data FROM dbo.sys_document WHERE ModuleID='" + moduleID + "' AND Status>0";
                    DataTable     dt    = GetDataTable(sql);
                    List <String> files = new List <String>();
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Temp/TestDataUpload/试验室人员");
                        DeleteDirAllFile(path);
                        if (!Directory.Exists(path))
                        {
                            try
                            {
                                Directory.CreateDirectory(path);
                            }
                            catch (Exception ee)
                            {
                                logger.Error(ee.Message);
                            }
                        }
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            String    testRoomCode = dt.Rows[i]["TestRoomCode"].ToString();
                            DataRow[] drArr        = dt.Select(string.Format("TestRoomCode='{0}'", testRoomCode));
                            if (testRoomCodeMap.ContainsKey(testRoomCode))
                            {
                                testRoomCode = testRoomCodeMap[testRoomCode].ToString();
                            }

                            String fileName = Path.Combine(path, testRoomCode + ".xml");
                            if (CreatMultiXMLFile(set, fileName, drArr, testRoomCode))
                            {
                                files.Add(fileName);
                                ProcessPersonPhoto(drArr, files, path);
                                foreach (DataRow row in drArr)
                                {
                                    dt.Rows.Remove(row);
                                }
                            }
                            drArr = null;
                            Thread.Sleep(3000);
                        }
                        if (files.Count > 0)
                        {
                            String zipFile = Path.Combine(path, "试验室人员.zip");
                            if (File.Exists(zipFile))
                            {
                                try
                                {
                                    File.Delete(zipFile);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                }
                            }
                            if (JZCommonHelper.CreateZipFile(files, zipFile))
                            {
                                FileStream stream = null;
                                stream = new FileInfo(zipFile).OpenRead();
                                Byte[] buffer = new Byte[stream.Length];
                                stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                                stream.Close();
                                String result = UploadToServer(uploadAddress, buffer, ksign, jsdwCode);
                                if (result == "1")
                                {
                                    logger.Error("试验室人员上传成功");
                                }
                                else
                                {
                                    logger.Error("试验室人员上传失败,返回值为:" + result);
                                }
                            }
                        }
                    }
                    else
                    {
                        logger.Error("未找到试验人员信息");
                    }
                }
                else
                {
                    logger.Error("未找到该模板对应的上传设置");
                }
            }
            catch (Exception ex)
            {
                logger.Error("UploadPersonInfo error:" + ex.ToString());
            }
        }
예제 #17
0
    public void LoadReport()
    {
        string DocumentID = "ID".RequestStr();
        string SheetIndex = "SI".RequestStr();


        string SheetXML      = "";
        string sheetData     = "";
        string SheetName     = "";
        string SheetID       = "";
        string ReportSheetID = "";



        SheetIndex = SheetIndex.IsNullOrEmpty() ? "0" : SheetIndex;

        try
        {
            JZDocument    sheetDataAreaCells;
            List <JZCell> Cells = new List <JZCell>();

            #region 查询数据

            DataTable _TempTable = new DataTable();

            string _TempStr = @"
Select testroomcode, m.reportsheetid,d.Data
 from [dbo].[sys_document] d 
 left outer  join [dbo].[sys_module] m 
 on d.ModuleId = m.ID 
 where d.ModuleID = 'E77624E9-5654-4185-9A29-8229AAFDD68B'
 ANd TestRoomCode = '{0}'";

            _TempStr = string.Format(_TempStr, DocumentID);
            BLL_Document Bll = new BLL_Document();
            _TempTable = Bll.GetDataTable(_TempStr);


            if (_TempTable.Rows.Count > 0)
            {
                sheetData          = _TempTable.Rows[SheetIndex.Toint()]["Data"].ToString();
                sheetDataAreaCells = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(sheetData);
                SheetCount         = _TempTable.Rows.Count;


                ReportSheetID = _TempTable.Rows[SheetIndex.Toint()]["reportsheetid"].ToString();
                foreach (JZSheet Jzs in sheetDataAreaCells.Sheets)
                {
                    if (Jzs.ID.ToString() == ReportSheetID)
                    {
                        SheetName = Jzs.Name;
                        SheetID   = Jzs.ID.ToString();
                        Cells     = Jzs.Cells;
                        break;
                    }
                }


                _TempStr = "select SheetXML ,SheetData  from  sys_sheet where ID = '{0}'";
                SheetXML = Bll.ExcuteScalar(string.Format(_TempStr, ReportSheetID)).ToString();
            }
            else
            {
                throw new Exception("占无报告数据");
            }

            _TempTable.Clear();
            _TempTable.Dispose();

            #endregion

            #region 创建WIN组件
            FarPoint.Win.Spread.FpSpread WinSp = new FarPoint.Win.Spread.FpSpread();
            WinSp.Sheets.Clear();
            SheetXML = JZCommonHelper.GZipDecompressString(SheetXML);
            int a = SheetXML.Length;
            FarPoint.Win.Spread.SheetView SheetView = Serializer.LoadObjectXml(typeof(FarPoint.Win.Spread.SheetView), SheetXML, "SheetView") as FarPoint.Win.Spread.SheetView;
            SheetView.SheetName = "Document";

            if (sheetDataAreaCells != null)
            {
                foreach (JZCell cell in Cells)
                {
                    //
                    if (SheetView.Cells[cell.Name].CellType.ToString() == "图片")
                    {
                        SheetView.Cells[cell.Name].ResetCellType();

                        SheetView.Cells[cell.Name].Value = "<img src='data:image/gif;base64," + cell.Value.ToString().Replace("\r\n", "") + "'  />";
                    }
                    else if (SheetView.Cells[cell.Name].CellType.ToString() == "文本")
                    {
                        SheetView.Cells[cell.Name].Value = cell.Value;
                    }
                    else if (SheetView.Cells[cell.Name].CellType.ToString() == "长文本")
                    {
                        SheetView.Cells[cell.Name].ResetCellType();
                        SheetView.Cells[cell.Name].Value = cell.Value;
                    }
                    else if (SheetView.Cells[cell.Name].CellType.ToString() == "超链接")
                    {
                        SheetView.Cells[cell.Name].ResetCellType();
                        if (cell.Value != null)
                        {
                            try
                            {
                                string[] Temp = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(cell.Value.ToString());
                                SheetView.Cells[cell.Name].Value = Temp[0] + "[" + Temp[2] + "]<img src='data:image/gif;base64," + Temp[1].Replace("\r\n", "") + "'  />";
                            }
                            catch
                            { }
                        }
                    }
                }
            }

            WinSp.Sheets.Add(SheetView);



            WinSp.LoadFormulas(true);

            #endregion

            #region 临时文件
            string        SitePath = Server.MapPath("~/Temp");
            DirectoryInfo Dir      = new System.IO.DirectoryInfo(SitePath);
            if (!Dir.Exists)
            {
                Dir.Create();
            }
            #endregion

            #region Save HTML

            string FileName = SitePath + "/" + SheetID + DateTime.Now.ToString("yyMMddhhmmss") + ".html";


            WinSp.ActiveSheet.SaveHtml(FileName);


            FileInfo   FHtml = new System.IO.FileInfo(FileName);
            FileStream Fs    = FHtml.OpenRead();
            byte[]     Buuff = new byte[Fs.Length];
            Fs.Read(Buuff, 0, (int)Fs.Length);
            Fs.Close();
            Fs.Dispose();

            string HTML = ASCIIEncoding.UTF8.GetString(Buuff);



            File.Delete(FileName);

            #endregion


            #region show Element



            StringBuilder Nav  = new StringBuilder();
            StringBuilder Cont = new StringBuilder();
            Nav.Append("<ul class=\"nav nav-tabs\">");
            Cont.Append("<div class=\"tab-content\">");
            if (SheetCount.Toint() > 1)
            {
                for (int i = 0; i < SheetCount; i++)
                {
                    Nav.Append("<li class=\"" + (i == SheetIndex.Toint() ? "active" : "") + "\" ><a data=\"testroominfo.aspx?ID=" + DocumentID + "&SI=" + i + "&R=" + new Random().Next(0, 100000) + "\" href=\"#t" + i + "\" data-toggle=\"tab\" >第" + (i + 1).ToString() + "</a></li>");


                    Cont.Append("<div class=\"tab-pane CPane " + (i == SheetIndex.Toint() ? "active" : "") + " \" id=\"t" + i.ToString() + "\">" + ((i == SheetIndex.Toint()) ? HTML : "") + "</div>");
                }
                Nav.Append("</ul>");
                Cont.Append("</div>");
                form1.InnerHtml = Nav.ToString() + Cont.ToString();
            }
            else
            {
                form1.InnerHtml = HTML;
            }


            #endregion
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
    }
예제 #18
0
        private void ProcessDoc(JZDocument doc, FpSpread sp, List <JZFormulaData> CrossSheetLineFormulaInfos)
        {
            foreach (SheetView sheet in sp.Sheets)
            {
                for (int i = 0; i < sheet.RowCount; i++)
                {
                    for (int j = 0; j < sheet.ColumnCount; j++)
                    {
                        Cell cell = sheet.Cells[i, j];
                        cell.Formula = "";
                        cell.Value   = JZCommonHelper.GetCellValue(doc, new Guid(sheet.Tag.ToString()), cell.Column.Label + cell.Row.Label);
                    }
                }
            }
            sp.LoadFormulas(true);
            foreach (JZFormulaData formula in CrossSheetLineFormulaInfos)
            {
                SheetView Sheet = GetSheetByID(sp, formula.SheetIndex);
                if (Sheet != null)
                {
                    Cell cell = Sheet.Cells[formula.RowIndex, formula.ColumnIndex];
                    if (cell != null)
                    {
                        try
                        {
                            if (formula.Formula.ToUpper().Trim() == "NA()")
                            {
                                cell.Formula = "";
                            }
                            else
                            {
                                cell.Formula = formula.Formula;
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }
                    }
                }
            }
            sp.LoadFormulas(true);

            foreach (JZSheet sheet in doc.Sheets)
            {
                SheetView view = GetSheetByID(sp, sheet.ID);
                if (view == null)
                {
                    continue;
                }
                foreach (JZCell dataCell in sheet.Cells)
                {
                    Cell cell = view.Cells[dataCell.Name];
                    if (cell != null)
                    {
                        if (String.IsNullOrEmpty(cell.Formula))
                        {
                            continue;
                        }
                        IGetFieldType FieldTypeGetter = cell.CellType as IGetFieldType;
                        if (FieldTypeGetter != null && FieldTypeGetter.FieldType.Description == "图片")
                        {
                            continue;
                        }
                        else if (FieldTypeGetter != null && FieldTypeGetter.FieldType.Description == "数字")
                        {
                            if (cell.Value != null)
                            {
                                Decimal d;
                                if (Decimal.TryParse(cell.Value.ToString().Trim(' ', '\r', '\n'), out d))
                                {
                                    dataCell.Value = d;
                                }
                                else
                                {
                                    dataCell.Value = null;
                                }
                            }
                        }
                        else
                        {
                            dataCell.Value = cell.Value;
                        }
                        if (dataCell.Value != null && dataCell.Value is String)
                        {
                            dataCell.Value = dataCell.Value.ToString().Trim(' ', '\r', '\n');
                        }
                    }
                }
            }
        }
예제 #19
0
        public void GenerateDBUpdate(DataTable dt)
        {
            if (dt != null && dt.Rows.Count > 0)
            {
                List <String> newTB = new List <string>();
                newTB.Add("dbo.sys_formulas");
                newTB.Add("dbo.sys_line_formulas");
                newTB.Add("dbo.sys_module");
                newTB.Add("dbo.sys_sheet");
                newTB.Add("dbo.sys_stadium_config");
                Boolean hasNewUpdate = false;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String tbName = dt.Rows[i]["TableName"].ToString().ToLower();
                    String sql    = String.Format("SELECT COUNT(1) FROM {0} WHERE Scts_1>'{1}' ", tbName,
                                                  Convert.ToDateTime(dt.Rows[i]["LastTime"]).ToString("yyyy-MM-dd HH:mm:ss.fff"));
                    if (newTB.Contains(tbName))
                    {
                        sql = String.Format("SELECT COUNT(1) FROM {0} WHERE LastEditedTime>'{1}' ", tbName,
                                            Convert.ToDateTime(dt.Rows[i]["LastTime"]).ToString("yyyy-MM-dd HH:mm:ss.fff"));
                    }
                    sql = String.Format("SELECT COUNT(1) FROM sys_sheet WHERE LastEditedTime>'{0}' ",
                                        Convert.ToDateTime(dt.Rows[i]["LastTime"]).ToString("yyyy-MM-dd HH:mm:ss.fff"));
                    Object obj = ExcuteScalar(sql);
                    if (obj != null && obj != DBNull.Value)
                    {
                        hasNewUpdate = Convert.ToInt32(obj) > 0;
                        if (hasNewUpdate)
                        {
                            break;
                        }
                    }
                }
                if (hasNewUpdate)
                {
                    String userName = "******";
                    String pw       = "wdxlzyn@#830";
                    String server   = "ISSDCPLCDMK";
                    String valid    = " -c -S " + server + " -U " + userName + " -P " + pw;

                    String subFolder = GetSubFolder("3");
                    String path      = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "update\\" + subFolder);
                    String file      = Path.Combine(path, "sys_sheet.dat");
                    String bcp       = "bcp \"SELECT * FROM " + Connection.Database + ".dbo.sys_sheet WHERE LastEditedTime > '" +
                                       Convert.ToDateTime(dt.Rows[0]["LastTime"]).ToString("yyyy-MM-dd HH:mm:ss.fff") + "' \" queryout " + file + valid;
                    JZCommonHelper.ExeCommand(bcp);
                    String fileName = Yqun.Common.ContextCache.ApplicationContext.Current.UserName + "_" +
                                      Yqun.Common.ContextCache.ApplicationContext.Current.Identification.MacAddress + "_" +
                                      DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff") + ".zip";
                    String zipFile = Path.Combine(path, fileName);
                    if (File.Exists(zipFile))
                    {
                        File.Delete(zipFile);
                    }
                    List <String> list = new List <string>();
                    list.Add(file);
                    Boolean flag = JZCommonHelper.CreateZipFile(list, zipFile);
                    SaveUpdateInfo(Guid.NewGuid().ToString(), fileName, "3", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                }
            }
        }
예제 #20
0
        public bool CreatReportInfoXMLFile(UploadSetting[] setArr, String path, DataRow[] drArr, String trCode, int[] wucArr)
        {
            if (File.Exists(path))
            {
                try
                {
                    File.Delete(path);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml("<?xml version=\"1.0\" encoding=\"gb2312\"?><ROOT></ROOT>");
            //logger.Error("CreatReportInfoXMLFile 0");
            for (int i = 0; i < drArr.Length; i++)
            {
                //logger.Error("CreatReportInfoXMLFile drArr i" + i);
                if (setArr[i] != null && setArr[i].Items != null)
                {
                    //logger.Error("CreatReportInfoXMLFile setArr i" + i);
                    XmlElement root = xmldoc.CreateElement(setArr[i].Name);
                    xmldoc.DocumentElement.AppendChild(root);
                    JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(drArr[i]["Data"].ToString());
                    XmlElement ele = null;
                    foreach (var item in setArr[i].Items)
                    {
                        ele = xmldoc.CreateElement(item.Name);
                        String value = "";
                        if (item.NeedSetting)
                        {
                            Object obj = JZCommonHelper.GetCellValue(doc, item.SheetID, item.CellName);
                            if (obj != null)
                            {
                                value = obj.ToString();
                            }
                        }
                        else
                        {
                            switch (item.Name)
                            {
                            case "F_TRCODE":    //试验室编号
                                value = trCode;
                                break;

                            case "F_NEWVERSION":    //试验室编号
                                value = wucArr[i].ToString();
                                break;

                            default:
                                break;
                            }
                        }
                        ele.InnerText = value;
                        root.AppendChild(ele);
                    }
                }
            }
            try
            {
                xmldoc.Save(path);
                return(true);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                return(false);
            }
        }
예제 #21
0
        /// <summary>
        /// 上传试验数据
        /// </summary>
        public void UploadTestDataInfo(string strTestRoomCodeMap, String uploadAddress, String jsdwCode)
        {
            try
            {
                Hashtable testRoomCodeMap = InitTestRoomCodeMap(strTestRoomCodeMap);
//                String sql = @"SELECT top 100 ID,TestRoomCode,Data,WillUploadCount,ModuleID,BGBH,CreatedTime FROM dbo.sys_document WHERE
//            ModuleID NOT IN ('E77624E9-5654-4185-9A29-8229AAFDD68B','08899BA2-CC88-403E-9182-3EF73F5FB0CE',
//            'BA23C25D-7C79-4CB3-A0DC-ACFA6C285295') AND Status>0 AND NeedUpload=1 and BGBH is not null and BGBH<>''  ORDER BY CreatedTime ";//排除人员、设备、试验室
                String         sql   = @"SELECT top 100 ID FROM dbo.sys_document WHERE 
            ModuleID NOT IN ('E77624E9-5654-4185-9A29-8229AAFDD68B','08899BA2-CC88-403E-9182-3EF73F5FB0CE',
            'BA23C25D-7C79-4CB3-A0DC-ACFA6C285295') AND Status>0 AND NeedUpload=1 and BGBH is not null and BGBH<>''  ORDER BY CreatedTime ";//排除人员、设备、试验室
                DataTable      dtIDs = GetDataTable(sql);
                ModuleHelper   mh    = new ModuleHelper();
                DocumentHelper dh    = new DocumentHelper();
                if (dtIDs != null && dtIDs.Rows.Count > 0)
                {
                    String        ksign = "05";//05表示试验数据
                    List <String> files = new List <String>();
                    #region 创建目录
                    String path = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Temp/TestDataUpload/试验数据");
                    DeleteDirAllFile(path);
                    if (!Directory.Exists(path))
                    {
                        try
                        {
                            Directory.CreateDirectory(path);
                        }
                        catch (Exception ee)
                        {
                            logger.Error(ee.Message);
                        }
                    }
                    #endregion
                    #region 回收应用程序池
                    //string strRealPath = System.Web.Hosting.HostingEnvironment.MapPath("~");
                    //logger.Error("strRealPath:" + strRealPath);
                    //strRealPath = strRealPath.Substring(0, strRealPath.Length - 1);
                    //int LastIndex = strRealPath.LastIndexOf('\\');
                    //string AppPoolName = strRealPath.Substring(LastIndex + 1, strRealPath.Length - LastIndex - 1);
                    //logger.Error("AppPoolName:" + AppPoolName);
                    //string method = "Recycle";
                    //try
                    //{
                    //    DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
                    //    DirectoryEntry findPool = appPool.Children.Find(AppPoolName, "IIsApplicationPool");
                    //    findPool.Invoke(method, null);
                    //    appPool.CommitChanges();
                    //    appPool.Close();
                    //    logger.Error("应用程序池名称回收成功");
                    //}
                    //catch (Exception ex)
                    //{
                    //    logger.Error("回收失败:" + ex.Message);
                    //}
                    #endregion
                    StringBuilder   strIDs    = new StringBuilder();
                    UploadSetting[] usArr     = new UploadSetting[dtIDs.Rows.Count];
                    DataRow[]       docRowArr = new DataRow[dtIDs.Rows.Count];
                    int[]           wucArr    = new int[dtIDs.Rows.Count];//WillUploadCount
                    #region 创建资料列表
                    for (int i = 0; i < dtIDs.Rows.Count; i++)
                    {
                        string    strID           = dtIDs.Rows[i]["ID"].ToString();
                        string    strSQL          = "SELECT ID,TestRoomCode,Data,WillUploadCount,ModuleID,BGBH,CreatedTime FROM dbo.sys_document where ID='" + strID + "'";
                        DataTable dt              = GetDataTable(strSQL);
                        String    testRoomCode    = dt.Rows[0]["TestRoomCode"].ToString();
                        string    strModuleID     = dt.Rows[0]["ModuleID"].ToString();
                        string    strBGBH         = dt.Rows[0]["BGBH"].ToString();
                        string    docDateDir      = DateTime.Parse(dt.Rows[0]["CreatedTime"].ToString()).ToString("yyyy/MM/dd");
                        int       WillUploadCount = int.Parse(dt.Rows[0]["WillUploadCount"].ToString());
                        strIDs.AppendFormat("'{0}'", strID);
                        if (i < dt.Rows.Count - 1)
                        {
                            strIDs.Append(",");
                        }
                        Sys_Module    module = mh.GetModuleBaseInfoByID(new Guid(strModuleID));
                        UploadSetting set    = module.UploadSetting;
                        if (set != null)
                        {
                            if (testRoomCodeMap.ContainsKey(testRoomCode))
                            {
                                testRoomCode = testRoomCodeMap[testRoomCode].ToString();
                            }
                            string strSourceFile = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), string.Format("source/{0}/{1}.pdf", docDateDir, strID));
                            string strDestFile   = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), string.Format("Temp/TestDataUpload/试验数据/{0}_{1}.pdf", testRoomCode, strBGBH));
                            if (!File.Exists(strSourceFile))
                            {
                                //logger.Error(string.Format("{1} ID:{0}不存在,生成文件开始", strID, i));
                                #region 生成PDF和图片
                                JZDocument doc      = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(dt.Rows[0]["Data"].ToString());
                                FpSpread   fpSpread = new FpSpread();
                                //int rIndex = 0;
                                //foreach (JZSheet sheet in doc.Sheets)
                                //{
                                //if (rIndex == module.ReportIndex)
                                //{
                                String    sheetXML  = JZCommonHelper.GZipDecompressString(mh.GetSheetXMLByID(doc.Sheets[module.ReportIndex].ID));// mh.GetSheetXMLByID(sheet.ID);
                                SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                                SheetView.Tag = doc.Sheets[module.ReportIndex].ID;
                                SheetView.Cells[0, 0].Value = "";
                                SheetView.Protect           = true;
                                foreach (JZCell dataCell in doc.Sheets[module.ReportIndex].Cells)
                                {
                                    Cell cell = SheetView.Cells[dataCell.Name];

                                    if (cell != null)
                                    {
                                        cell.Value = dataCell.Value;
                                    }
                                }
                                fpSpread.Sheets.Add(SheetView);
                                //}
                                //else
                                //{
                                //    //fpSpread.Sheets.Add(null);
                                //}
                                //sheetXML = null;
                                //SheetView = null;
                                //    rIndex++;
                                //}

                                //自动生成Excel,图片和报告页的pdf
                                SourceHelper sourceHelper = new SourceHelper();
                                sourceHelper.CreateRalationFilesSync(fpSpread, doc.ID, module.ReportIndex, docDateDir);
                                fpSpread.Dispose();
                                doc = null;
                                #endregion
                                logger.Error(string.Format("{1} ID:{0}不存在,生成文件成功", strID, i));
                                //Thread.Sleep(10000);
                            }
                            else
                            {
                                logger.Error(string.Format("{1} ID:{0}存在,不需要生成文件", strID, i));
                            }
                            File.Copy(strSourceFile, strDestFile, true);
                            files.Add(strDestFile);

                            usArr[i]     = set;
                            docRowArr[i] = dt.Rows[0];
                            wucArr[i]    = WillUploadCount;
                            //JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject<JZDocument>(dt.Rows[i]["Data"].ToString());
                            //String fileName = Path.Combine(path, dt.Rows[i]["ID"].ToString() + ".xml");
                            //if (CreatXMLFile(set, fileName, doc, testRoomCode))
                            //{
                            //    files.Add(fileName);
                            //}
                        }
                        else
                        {
                            usArr[i]     = null;
                            docRowArr[i] = dt.Rows[0];
                            wucArr[i]    = WillUploadCount;
                            logger.Error("未找到该模板对应的上传设置,资料ID:" + strID);
                        }
                    }
                    #endregion
                    //logger.Error("reportInfo 0");
                    String fileName = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Temp/TestDataUpload/试验数据/reportInfo.xml");
                    //生成reportInfo.xml
                    CreatReportInfoXMLFile(usArr, fileName, docRowArr, jsdwCode, wucArr);
                    //logger.Error("reportInfo 1");
                    files.Add(fileName);

                    #region   资料
                    if (files.Count > 0)
                    {
                        String zipFile = Path.Combine(path, "试验报告.zip");
                        if (File.Exists(zipFile))
                        {
                            try
                            {
                                File.Delete(zipFile);
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.Message);
                            }
                        }
                        if (JZCommonHelper.CreateZipFile(files, zipFile))
                        {
                            FileStream stream = null;
                            stream = new FileInfo(zipFile).OpenRead();
                            Byte[] buffer = new Byte[stream.Length];
                            stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
                            stream.Close();
                            String result = UploadToServer(uploadAddress, buffer, ksign, jsdwCode);
                            if (result == "1")
                            {
                                logger.Error("试验报告上传成功");
                                if (strIDs.Length > 0)
                                {
                                    dh.UpdateDocumentNeedUpload(strIDs.ToString());
                                }
                            }
                            else
                            {
                                logger.Error("试验报告上传失败,返回值为:" + result);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    logger.Info("未找到试验数据信息");
                }
            }
            catch (Exception ex)
            {
                logger.Error("UploadTestDataInfo error:" + ex.ToString());
            }
        }
예제 #22
0
파일: LogDialog.cs 프로젝트: scaperow/-V2.0
        private void LogDialog_Load(object sender, EventArgs e)
        {
            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);
            InitLogCategoryInfo();
            Dictionary <Guid, SheetView> SheetCollection = new Dictionary <Guid, SheetView>();

            try
            {
                List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos();
                FpSpread.Sheets.Clear();
                if (dataID == Guid.Empty)
                {
                    return;
                }
                JZDocument document        = DocumentHelperClient.GetDocumentByID(dataID);
                JZDocument defaultDocument = ModuleHelperClient.GetDefaultDocument(moduleID);

                List <JZFormulaData> CrossSheetFormulaInfos = ModuleHelperClient.GetFormulaByModuleIndex(moduleID);

                foreach (JZSheet sheet in defaultDocument.Sheets)
                {
                    ProgressScreen.Current.SetStatus = "正在初始化表单‘" + sheet.Name + "’";
                    String    sheetXML  = ModuleHelperClient.GetSheetXMLByID(sheet.ID);
                    SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                    SheetView.Tag               = sheet.ID;
                    SheetView.SheetName         = sheet.Name;
                    SheetView.Cells[0, 0].Value = "";
                    SheetView.Protect           = true;
                    FpSpread.Sheets.Add(SheetView);

                    SheetCollection.Add(sheet.ID, SheetView);
                    foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos)
                    {
                        SheetView.AddCustomFunction(Info);
                    }
                    foreach (JZCell dataCellDefault in sheet.Cells)
                    {
                        Cell    cell     = SheetView.Cells[dataCellDefault.Name];
                        Object  value    = JZCommonHelper.GetCellValue(document, sheet.ID, dataCellDefault.Name);
                        Boolean hasValue = true;
                        if (value == null || value.ToString() == "")
                        {
                            hasValue = false;
                        }
                        if (cell != null)
                        {
                            cell.Font = defaultFont;
                            if (cell.CellType is DownListCellType)
                            {
                                DownListCellType CellType = cell.CellType as DownListCellType;
                                CellType.DropDownButton = false;
                                CellType.DesignMode     = false;
                                cell.Value = value;
                            }
                            else if (cell.CellType is TextCellType)
                            {
                                TextCellType CellType = cell.CellType as TextCellType;
                                if (CellType.FieldType.Description == FieldType.Text.Description)
                                {
                                    CellType.Multiline = true;
                                    CellType.WordWrap  = true;
                                }
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is LongTextCellType)
                            {
                                LongTextCellType CellType = cell.CellType as LongTextCellType;
                                if (CellType.FieldType.Description == FieldType.LongText.Description)
                                {
                                    CellType.Multiline = true;
                                    CellType.WordWrap  = true;
                                }
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is DateTimeCellType)
                            {
                                DateTimeCellType CellType = cell.CellType as DateTimeCellType;
                                CellType.MinimumDate = new DateTime(1753, 1, 1);
                                CellType.MaximumDate = new DateTime(9999, 12, 31);
                                cell.Value           = value;
                            }
                            else if (cell.CellType is RichTextCellType)
                            {
                                RichTextCellType CellType = cell.CellType as RichTextCellType;
                                CellType.Multiline = false;
                                CellType.WordWrap  = false;
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is NumberCellType)
                            {
                                NumberCellType CellType = cell.CellType as NumberCellType;
                                CellType.MaximumValue = 999999999.9999;
                                CellType.MinimumValue = -999999999.9999;
                                cell.Value            = value;
                            }
                            else if (cell.CellType is MaskCellType)
                            {
                                MaskCellType CellType = cell.CellType as MaskCellType;
                                CellType.Mask = "00000000000000000000000000000000000";
                                if (CellType.CustomMaskCharacters != null && CellType.CustomMaskCharacters.Length > 0)
                                {
                                    CellType.CustomMaskCharacters[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-()()复检";
                                }
                                cell.Value = value;
                            }
                            else if (cell.CellType is ImageCellType)
                            {
                                if (value != null)
                                {
                                    cell.Value = JZCommonHelper.StringToBitmap(value.ToString());
                                }
                            }
                            else
                            {
                                cell.Value = value;
                            }
                        }
                    }
                }

                ProgressScreen.Current.SetStatus = "正在初始化跨表公式...";

                foreach (JZFormulaData formula in CrossSheetFormulaInfos)
                {
                    SheetView Sheet = SheetCollection[formula.SheetIndex];
                    try
                    {
                        Sheet.Cells[formula.RowIndex, formula.ColumnIndex].Formula = formula.Formula;
                    }
                    catch
                    {
                    }
                }

                FpSpread.LoadFormulas(true);

                ProgressScreen.Current.SetStatus = "正在显示资料...";

                UpdateChart();
                UpdateEquation();
                SetNotes();
                //设置只读模式
                if (ReadOnly)
                {
                    foreach (SheetView sheet in FpSpread.Sheets)
                    {
                        sheet.OperationMode = OperationMode.ReadOnly;
                    }
                }
            }
            catch (TimeoutException ex1)
            {
                MessageBox.Show("网络原因造成数据无法访问,请检查本机网络连接,或稍后再试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("加载试验模板出错!\r\n原因:" + (ex.InnerException != null ? ex.InnerException.Message : ex.Message), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                try
                {
                    this.RemoveOwnedForm(ProgressScreen.Current);
                    ProgressScreen.Current.CloseSplashScreen();
                    this.Activate();
                }
                catch (Exception ex1) { }
            }
        }
예제 #23
0
    public void LoadReport(string DSource, string DName, string UID, string PWD, string DocumentID)
    {
        try
        {
            string        SheetXML    = "";
            string        sheetData   = "";
            string        SheetName   = "";
            string        SheetID     = "";
            string        ReportIndex = "0";
            JZDocument    sheetDataAreaCells;
            List <JZCell> Cells = new List <JZCell>();

            #region 查询数据

            DataTable _TempTable = new DataTable();
            using (SqlConnection _Conn = new SqlConnection("Data Source=" + DSource + ";Initial Catalog=" + DName + ";User ID=" + UID + ";Pwd=" + PWD))
            {
                _Conn.Open();
                string _TempStr = "Select m.reportsheetid,d.Data from [dbo].[sys_document] d left outer  join [dbo].[sys_module] m on d.ModuleId = m.ID where d.id = '{0}'";
                using (SqlCommand _Cmd = new SqlCommand(string.Format(_TempStr, DocumentID), _Conn))
                {
                    using (SqlDataAdapter _Adp = new SqlDataAdapter(_Cmd))
                    {
                        _Adp.Fill(_TempTable);
                        if (_TempTable.Rows.Count > 0)
                        {
                            sheetData = _TempTable.Rows[0]["Data"].ToString();
                            //ReportIndex = Convert.ToInt32(_TempTable.Rows[0]["reportsheetid"].ToString());
                            ReportIndex = _TempTable.Rows[0]["reportsheetid"].ToString();


                            _TempTable.Clear();
                            _TempTable         = new System.Data.DataTable();
                            sheetDataAreaCells = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(sheetData);
                            _TempStr           = "select Name ,SheetXML ,SheetData  from  sys_sheet where ID = '{0}'";
                            _Cmd.CommandText   = string.Format(_TempStr, ReportIndex);

                            foreach (JZSheet Jzs in sheetDataAreaCells.Sheets)
                            {
                                if (Jzs.ID.ToString() == ReportIndex)
                                {
                                    SheetName = Jzs.Name;
                                    SheetID   = Jzs.ID.ToString();
                                    Cells     = Jzs.Cells;
                                }
                            }
                            _Adp.SelectCommand = _Cmd;
                            _Adp.Fill(_TempTable);

                            SheetXML = _TempTable.Rows[0]["SheetXML"].ToString();
                        }
                        else
                        {
                            throw new Exception("占无报告数据");
                        }
                    }
                }
                _Conn.Close();
            }
            _TempTable.Clear();
            _TempTable.Dispose();

            #endregion


            #region 创建WIN组件
            FarPoint.Win.Spread.FpSpread WinSp = new FarPoint.Win.Spread.FpSpread();
            WinSp.Sheets.Clear();
            SheetXML = JZCommonHelper.GZipDecompressString(SheetXML);
            int a = SheetXML.Length;
            FarPoint.Win.Spread.SheetView SheetView = Serializer.LoadObjectXml(typeof(FarPoint.Win.Spread.SheetView), SheetXML, "SheetView") as FarPoint.Win.Spread.SheetView;
            SheetView.SheetName = SheetName;

            if (sheetDataAreaCells != null)
            {
                //for (int i = 0; i < SheetView.RowCount; i++)
                //{
                //    for (int j = 0; j < SheetView.ColumnCount; j++)
                //    {
                //        if (SheetView.Cells[i, j].CellType!=null && SheetView.Cells[i, j].CellType.ToString() == "下拉框")
                //        {
                //            SheetView.Cells[i, j].CellType = null;
                //        }
                //    }
                //}
                //SheetView.Columns.Remove(16, 4);

                foreach (JZCell cell in Cells)
                {
                    dataCells.Add(SheetView.Cells[cell.Name]);

                    SheetView.Cells[cell.Name].Value = cell.Value;
                }
            }

            WinSp.Sheets.Add(SheetView);

            //dtCellStyle = ModuleHelperClient.GetCellStyleBySheetID(sheetID);
            //for (int i = 0; i < dtCellStyle.Rows.Count; i++)
            //{
            //    if (dtCellStyle.Rows[i]["CellStyle"] != null)
            //    {
            //        JZCellStyle CurrentCellStyle = Newtonsoft.Json.JsonConvert.DeserializeObject<JZCellStyle>(dtCellStyle.Rows[i]["CellStyle"].ToString());
            //        if (CurrentCellStyle != null)
            //        {
            //            string strCellName = dtCellStyle.Rows[i]["CellName"].ToString();
            //            FarPoint.Win.Spread.Cell cell = SheetView.Cells[strCellName];
            //            cell.ForeColor = CurrentCellStyle.ForColor;
            //            cell.BackColor = CurrentCellStyle.BackColor;
            //            cell.Font = new Font(CurrentCellStyle.FamilyName, CurrentCellStyle.FontSize, CurrentCellStyle.FontStyle);
            //        }
            //    }
            //}

            WinSp.LoadFormulas(true);


            UpdateChart(WinSp);
            UpdateEquation(WinSp);



            #endregion

            #region 临时文件
            string        SitePath = Server.MapPath("~/Temp");
            DirectoryInfo Dir      = new System.IO.DirectoryInfo(SitePath);
            if (!Dir.Exists)
            {
                Dir.Create();
            }
            #endregion

            #region Save HTML

            string FileName = SitePath + "/" + SheetID + DateTime.Now.ToString("yyMMddhhmmss") + ".html";

            WinSp.ActiveSheet.SaveHtml(FileName);


            FileInfo   FHtml = new System.IO.FileInfo(FileName);
            FileStream Fs    = FHtml.OpenRead();
            byte[]     Buuff = new byte[Fs.Length];
            Fs.Read(Buuff, 0, (int)Fs.Length);
            Fs.Close();
            Fs.Dispose();

            string HTML = ASCIIEncoding.UTF8.GetString(Buuff);
            html.InnerHtml = HTML;

            //WinSp.SaveExcel(SitePath + "/" + SheetID + ".xls");
            File.Delete(FileName);
            #endregion

            #region Save Excel
            //WinSp.SaveExcel(SitePath + "/222.xls",FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat);



            //fp1.OpenExcel(SitePath + "/" + SheetID + ".xls");
            //fp1.CommandBar.Visible = false;
            //fp1.Sheets[0].PageSize = fp1.Sheets[0].Rows.Count;

            //File.Delete(SitePath + "/" + SheetID + ".xlsx");
            //fp1.Visible = true;
            #endregion
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
            //fp1.Visible = false;
        }
        finally
        {
        }



        //Response.Write(stopwatch.ElapsedMilliseconds.ToString());
    }
예제 #24
0
        private void ButtonUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog FileDialog = new OpenFileDialog();

            FileDialog.Filter           = "图片文件(*.bmp,*.jpg,*.png)|*.bmp,*.jpg,*.png|所有文件(*.*)|*.*";
            FileDialog.FilterIndex      = 2;
            FileDialog.InitialDirectory = Application.StartupPath;
            FileDialog.RestoreDirectory = true;
            if (DialogResult.OK == FileDialog.ShowDialog())
            {
                try
                {
                    Bitmap bitmap      = new Bitmap(FileDialog.FileName);
                    int    iCellWidth  = 800; // (int)view.Cells[cell.Row.Index, cell.Column.Index, cell.Row.Index + cell.RowSpan, cell.Column.Index + cell.ColumnSpan].Column.Width;
                    int    iCellHeight = 600; // (int)view.Cells[cell.Row.Index, cell.Column.Index, cell.Row.Index + cell.RowSpan, cell.Column.Index + cell.ColumnSpan].Row.Height;

                    float fCellRate = (float)iCellHeight / iCellWidth;
                    int   imgWidth, imgHeight, imgCutWidth, imgCutHeight;
                    imgWidth  = bitmap.Width;
                    imgHeight = bitmap.Height;
                    if (imgWidth <= iCellWidth && imgHeight <= iCellHeight)
                    {
                        imgCutWidth  = imgWidth;
                        imgCutHeight = imgHeight;
                    }
                    else
                    {
                        float imgRate;
                        imgRate = (float)imgHeight / imgWidth;
                        if (imgRate < fCellRate)
                        {//高小了
                            if (imgWidth < iCellWidth)
                            {
                                imgCutWidth = imgWidth;
                            }
                            else
                            {
                                imgCutWidth = iCellWidth;
                            }
                            imgCutHeight = (int)(imgCutWidth * imgRate);
                        }
                        else
                        {
                            if (imgHeight < iCellHeight)
                            {
                                imgCutHeight = imgHeight;
                            }
                            else
                            {
                                imgCutHeight = iCellHeight;
                            }
                            imgCutWidth = (int)(imgCutHeight / imgRate);
                        }
                    }

                    Img           = JZCommonHelper.KiResizeImage(bitmap, imgCutWidth, imgCutHeight, 0);
                    Preview.Image = Img;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #25
0
        public bool CreatXMLFile(UploadSetting set, String path, JZDocument doc, String trCode)
        {
            if (File.Exists(path))
            {
                try
                {
                    File.Delete(path);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml("<?xml version=\"1.0\" encoding=\"gb2312\"?><ROOT></ROOT>");
            XmlElement root = xmldoc.CreateElement(set.Name);

            xmldoc.DocumentElement.AppendChild(root);

            if (set.Items != null)
            {
                XmlElement ele = null;
                foreach (var item in set.Items)
                {
                    ele = xmldoc.CreateElement(item.Name);
                    String value = "";
                    if (item.NeedSetting)
                    {
                        Object obj = JZCommonHelper.GetCellValue(doc, item.SheetID, item.CellName);
                        if (obj != null)
                        {
                            value = obj.ToString();
                        }
                    }
                    else
                    {
                        switch (item.Name)
                        {
                        case "F_TRCODE":    //试验室编号
                            value = trCode;
                            break;

                        default:
                            break;
                        }
                    }
                    ele.InnerText = value;
                    root.AppendChild(ele);
                }
            }
            try
            {
                xmldoc.Save(path);
                return(true);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                return(false);
            }
        }
예제 #26
0
        private void SheetDesinger_Load(object sender, EventArgs e)
        {
            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);

            ProgressScreen.Current.SetStatus = "正在初始化表单...";

            try
            {
                Sys_Sheet sheetItem = ModuleHelperClient.GetSheetItemByID(sheetID);
                FpSpread.Sheets.Clear();

                if (ModuleHelperClient.IsContainerXml(sheetItem.SheetXML))
                {
                    sheetItem.SheetXML = sheetItem.SheetXML;
                }
                else
                {
                    sheetItem.SheetXML = JZCommonHelper.GZipDecompressString(sheetItem.SheetXML);
                }

                SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetItem.SheetXML, "SheetView") as SheetView;

                SheetView.SheetName = sheetItem.Name;

                List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos();
                foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos)
                {
                    SheetView.AddCustomFunction(Info);
                }

                List <JZCell> sheetDataAreaCells = Newtonsoft.Json.JsonConvert.DeserializeObject <List <JZCell> >(sheetItem.SheetData);
                if (sheetDataAreaCells != null)
                {
                    foreach (JZCell cell in sheetDataAreaCells)
                    {
                        dataCells.Add(SheetView.Cells[cell.Name]);
                    }
                }

                FpSpread.Sheets.Add(SheetView);
                dtCellStyle = ModuleHelperClient.GetCellStyleBySheetID(sheetID);
                for (int i = 0; i < dtCellStyle.Rows.Count; i++)
                {
                    if (dtCellStyle.Rows[i]["CellStyle"] != null)
                    {
                        JZCellStyle CurrentCellStyle = Newtonsoft.Json.JsonConvert.DeserializeObject <JZCellStyle>(dtCellStyle.Rows[i]["CellStyle"].ToString());
                        if (CurrentCellStyle != null)
                        {
                            string strCellName = dtCellStyle.Rows[i]["CellName"].ToString();
                            Cell   cell        = SheetView.Cells[strCellName];
                            cell.ForeColor = CurrentCellStyle.ForColor;
                            cell.BackColor = CurrentCellStyle.BackColor;
                            cell.Font      = new Font(CurrentCellStyle.FamilyName, CurrentCellStyle.FontSize, CurrentCellStyle.FontStyle);
                        }
                    }
                }

                FpSpread.LoadFormulas(true);
                fpSheetEditor1.EnableToolStrip(true);

                UpdateChart();
                UpdateEquation();
            }
            catch (Exception ex)
            {
                MessageBox.Show("加载表单出错!\r\n原因:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.RemoveOwnedForm(ProgressScreen.Current);
                ProgressScreen.Current.CloseSplashScreen();
                this.Activate();
            }
        }
예제 #27
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        sys_line sysBaseLine = System.Web.HttpContext.Current.Session["SysBaseLine"] as sys_line;

        if (sysBaseLine.IsActive == 1)
        {
            string  SQL = "SELECT * FROM dbo.sys_document WHERE  ModuleID='BA23C25D-7C79-4CB3-A0DC-ACFA6C285295' ";
            DataSet ds  = DbHelperSQL.Query(SQL);
            SQL = " TRUNCATE TABLE biz_machinelist ";
            DbHelperSQL.Query(SQL);

            DateTime d_min = DateTime.Parse(SqlDateTime.MinValue.ToString());
            DateTime d_max = DateTime.Parse(SqlDateTime.MaxValue.ToString());



            if (ds != null)
            {
                List <biz_machinelist> list = new List <biz_machinelist>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string     str = dr["Data"].ToString();
                    JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(str);
                    if (doc != null)
                    {
                        #region
                        for (int i = 6; i < 32; i++)
                        {
                            biz_machinelist biz = new biz_machinelist();
                            biz.SCTS = DateTime.Parse(dr["CreatedTime"].ToString());
                            biz.SCPT = dr["TestRoomCode"].ToString();
                            //int n=0;
                            //if (Int32.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "A" + i).ToString(),out n))
                            //{
                            //    biz.col_norm_A6 = Int32.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "A" + i).ToString());
                            //}
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i) != null)
                            {
                                biz.col_norm_B6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "C" + i) != null)
                            {
                                biz.col_norm_C6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "C" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D" + i) != null)
                            {
                                biz.col_norm_D6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i) != null)
                            {
                                biz.col_norm_E6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "F" + i) != null)
                            {
                                biz.col_norm_F6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "F" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G" + i) != null)
                            {
                                biz.col_norm_G6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i) != null)
                            {
                                DateTime date = new DateTime();
                                if (DateTime.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString(), out date) == false)
                                {
                                    biz.col_norm_H6 = null;
                                }
                                else
                                {
                                    if (DateTime.Compare(d_min, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString())) < 0 && DateTime.Compare(d_max, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString())) >= 0)
                                    {
                                        biz.col_norm_H6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "H" + i).ToString());
                                    }
                                    else
                                    {
                                        biz.col_norm_H6 = null;
                                    }
                                }
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "I" + i) != null)
                            {
                                biz.col_norm_I6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "I" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "J" + i) != null)
                            {
                                biz.col_norm_J6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "J" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i) != null)
                            {
                                biz.col_norm_K6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L" + i) != null)
                            {
                                biz.col_norm_L6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i) != null)
                            {
                                biz.col_norm_M6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i) != null)
                            {
                                DateTime date = new DateTime();
                                if (DateTime.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString(), out date) == false)
                                {
                                    biz.col_norm_N6 = null;
                                }
                                else
                                {
                                    //biz.col_norm_N6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString());
                                    if (DateTime.Compare(d_min, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString())) < 0 && DateTime.Compare(d_max, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString())) >= 0)
                                    {
                                        biz.col_norm_N6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "N" + i).ToString());
                                    }
                                    else
                                    {
                                        biz.col_norm_N6 = null;
                                    }
                                }
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i) != null)
                            {
                                DateTime date = new DateTime();
                                if (DateTime.TryParse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString(), out date) == false)
                                {
                                    biz.col_norm_O6 = null;
                                }
                                else
                                {
                                    //biz.col_norm_O6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString());
                                    if (DateTime.Compare(d_min, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString())) < 0 && DateTime.Compare(d_max, DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString())) >= 0)
                                    {
                                        biz.col_norm_O6 = DateTime.Parse(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "O" + i).ToString());
                                    }
                                    else
                                    {
                                        biz.col_norm_O6 = null;
                                    }
                                }
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "P" + i) != null)
                            {
                                biz.col_norm_P6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "P" + i).ToString();
                            }
                            if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "Q" + i) != null)
                            {
                                biz.col_norm_Q6 = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "Q" + i).ToString();
                            }
                            if (biz.col_norm_B6 == null && biz.col_norm_C6 == null && biz.col_norm_D6 == null && biz.col_norm_E6 == null && biz.col_norm_F6 == null)
                            {
                            }
                            else
                            {
                                list.Add(biz);
                            }
                        }
                        #endregion
                    }
                }

                #region
                foreach (var item in list)
                {
                    long n = 0;
                    n = Add(item);
                }
                #endregion

                SQL = "DELETE dbo.biz_machinelist WHERE  col_norm_B6='' AND col_norm_C6='' AND col_norm_D6='' AND col_norm_E6='' AND col_norm_F6='' AND col_norm_G6='' ";
                DbHelperSQL.Query(SQL);
                Label1.Text = "执行成功";
            }
        }
    }
예제 #28
0
        /// <summary>
        /// 保存表单样式
        /// </summary>
        private void SaveSheetStyle()
        {
            try
            {
                Sys_Sheet sheet = new Sys_Sheet();
                sheet.ID       = sheetID;
                sheet.Name     = SheetName;
                sheet.SheetXML = JZCommonHelper.GZipCompressString(Editor.GetActiveSheetXml());
                List <JZCell>        cells            = new List <JZCell>();
                List <CellLogic>     cellLogicList    = new List <CellLogic>();
                List <JZFormulaData> cellFormulasList = new List <JZFormulaData>();
                //bool bIsKeyDescEmpty = false;
                #region CellLogic
                foreach (Cell cell in dataCells)
                {
                    if (cell == null)
                    {
                        continue;
                    }

                    JZCell c = new JZCell();
                    c.Name  = cell.Column.Label + cell.Row.Label;
                    c.Value = cell.Value;
                    bool bHasExist = false;
                    foreach (JZCell cc in cells)
                    {
                        if (cc.Name == c.Name)
                        {
                            bHasExist = true;
                            break;
                        }
                    }
                    if (bHasExist == true)
                    {
                        continue;
                    }
                    cells.Add(c);

                    CellLogic cl = new CellLogic();
                    cl.Name = c.Name;
                    JZCellProperty p = cell.Tag as JZCellProperty;
                    if (p != null)
                    {
                        cl.Description = p.Description;
                        cl.IsKey       = p.IsKey;
                        cl.IsNotCopy   = p.IsNotCopy;
                        cl.IsNotNull   = p.IsNotNull;
                        cl.IsPingxing  = p.IsPingxing;
                        cl.IsReadOnly  = p.IsReadOnly;
                        cl.IsUnique    = p.IsUnique;
                        if (cl.IsKey == true && string.IsNullOrEmpty(cl.Description))
                        {
                            //bIsKeyDescEmpty = true;
                            MessageBox.Show(string.Format("单元格{0}的描述不能为空", c.Name));
                            return;
                        }
                    }
                    cellLogicList.Add(cl);
                }
                #endregion
                #region Formulas
                if (FpSpread.Sheets[0] != null)
                {
                    for (int j = 0; j < FpSpread.Sheets[0].ColumnCount; j++)
                    {
                        for (int m = 0; m < FpSpread.Sheets[0].RowCount; m++)
                        {
                            Cell          c  = FpSpread.Sheets[0].Cells[m, j];
                            JZFormulaData cl = new JZFormulaData();
                            if (c != null)
                            {
                                if (!string.IsNullOrEmpty(c.Formula))
                                {
                                    //logger.Error(string.Format("Name:{0} ColumnIndex:{1} RowIndex:{2} Formula:{3} ", ((char)('A' + c.Column.Index)).ToString() + (c.Row.Index + 1).ToString(), c.Column.Index, c.Row.Index, c.Formula));
                                    cl.ColumnIndex = c.Column.Index;
                                    cl.RowIndex    = c.Row.Index;
                                    cl.Formula     = c.Formula;
                                    cellFormulasList.Add(cl);
                                }
                            }
                        }
                    }
                }
                #endregion
                sheet.SheetData = Newtonsoft.Json.JsonConvert.SerializeObject(cells);
                sheet.CellLogic = JZCommonHelper.GZipCompressString(Newtonsoft.Json.JsonConvert.SerializeObject(cellLogicList));
                sheet.Formulas  = JZCommonHelper.GZipCompressString(Newtonsoft.Json.JsonConvert.SerializeObject(cellFormulasList));

                if (ModuleHelperClient.SaveSheet(sheet))
                {
                    MessageBox.Show("保存成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("保存失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败。" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #29
0
        private void lb_img_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenFileDialog _OpenFileDialog = new OpenFileDialog();

            _OpenFileDialog.Filter = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg|*.gif|*.bmp";
            //int MAX_IMAGE_SIZE = 100;//图片最大上传大小,单位KB
            int   MAX_IMAGE_WIDTH  = 800;                                       //图片最大宽度
            int   MAX_IMAGE_HEIGHT = 600;                                       //图片最大高度
            float MAX_RATE         = (float)MAX_IMAGE_HEIGHT / MAX_IMAGE_WIDTH; //高宽比

            if (_OpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                MemoryStream tempms = new MemoryStream(File.ReadAllBytes(_OpenFileDialog.FileName));
                //long size = tempms.Length / 1024;
                //if (size > MAX_IMAGE_SIZE)
                //{
                //    MessageBox.Show(string.Format("图片大小不能超出{0}KB", MAX_IMAGE_SIZE), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
                Bitmap bitmap = new Bitmap(tempms);
                #region 判断要裁剪的图片的高度
                int imgWidth, imgHeight, imgCutWidth, imgCutHeight;
                imgWidth  = bitmap.Width;
                imgHeight = bitmap.Height;
                if (imgWidth <= MAX_IMAGE_WIDTH && imgHeight <= MAX_IMAGE_HEIGHT)
                {
                    imgCutWidth  = imgWidth;
                    imgCutHeight = imgHeight;
                }
                else
                {
                    float imgRate;
                    imgRate = (float)imgHeight / imgWidth;
                    if (imgRate < MAX_RATE)
                    {//高小了
                        if (imgWidth < MAX_IMAGE_WIDTH)
                        {
                            imgCutWidth = imgWidth;
                        }
                        else
                        {
                            imgCutWidth = MAX_IMAGE_WIDTH;
                        }
                        imgCutHeight = (int)(imgCutWidth * imgRate);
                    }
                    else
                    {
                        if (imgHeight < MAX_IMAGE_HEIGHT)
                        {
                            imgCutHeight = imgHeight;
                        }
                        else
                        {
                            imgCutHeight = MAX_IMAGE_HEIGHT;
                        }
                        imgCutWidth = (int)(imgCutHeight / imgRate);
                    }
                }
                #endregion
                Bitmap imgCut = JZCommonHelper.KiResizeImage(bitmap, imgCutWidth, imgCutHeight, 0);

                //ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);

                //System.Drawing.Imaging.Encoder myEncoder =
                //    System.Drawing.Imaging.Encoder.Quality;

                //EncoderParameters myEncoderParameters = new EncoderParameters(1);

                //EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L);
                //myEncoderParameters.Param[0] = myEncoderParameter;

                //using (MemoryStream stream = new MemoryStream())
                //{
                //    b.Save(stream, jgpEncoder, myEncoderParameters);
                //    b = new Bitmap(stream);
                //}
                MemoryStream stream = new MemoryStream();
                imgCut.Save(stream, ImageFormat.Jpeg);

                JZFile file = new JZFile();
                file.FileData = stream.ToArray();
                String newImgID = DocumentHelperClient.SaveInvalidImage(invalidReportID, file, GetSeletedText());
                if (newImgID != "")
                {
                    //AddImage(new Bitmap(tempms), tabControl1.SelectedIndex, newImgID, true);
                    AddImage(new Bitmap(stream), tabControl1.SelectedIndex, newImgID, true);
                    tempms.Close();
                    tempms.Dispose();
                    stream.Close();
                    stream.Dispose();
                }
                else
                {
                    MessageBox.Show("图片上传失败");
                }
            }
        }
예제 #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String id = Request.Params["id"];
            if (!String.IsNullOrEmpty(id))
            {
                sys_line sysBaseLine = System.Web.HttpContext.Current.Session["SysBaseLine"] as sys_line;
                if (sysBaseLine.IsActive == 0)
                {
                    #region
                    BLL_UserInfo bll = new BLL_UserInfo();
                    DataTable    dt  = bll.GetUserInfo(id);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        lbl_xingming.Text        = dt.Rows[0]["col_norm_D6"].ToString();
                        lbl_xingbie.Text         = dt.Rows[0]["col_norm_G6"].ToString();
                        lbl_nianling.Text        = dt.Rows[0]["col_norm_K6"].ToString();
                        lbl_jishuzhicheng.Text   = dt.Rows[0]["col_norm_D7"].ToString();
                        lbl_zhiwu.Text           = dt.Rows[0]["col_norm_G7"].ToString();
                        lbl_gongzuonianxian.Text = dt.Rows[0]["col_norm_K7"].ToString();
                        lbl_zhuanye.Text         = dt.Rows[0]["col_norm_D8"].ToString();
                        lbl_xueli.Text           = dt.Rows[0]["col_norm_G8"].ToString();


                        try
                        {
                            lbl_biyeshijian.Text = Convert.ToDateTime(dt.Rows[0]["col_norm_K8"].ToString()).ToShortDateString();
                        }
                        catch
                        {
                            lbl_biyeshijian.Text = dt.Rows[0]["col_norm_K8"].ToString();
                        }

                        lbl_lianxidianhua.Text = dt.Rows[0]["col_norm_D9"].ToString();
                        lbl_biyexuexiao.Text   = dt.Rows[0]["col_norm_G9"].ToString();

                        //dt.Rows[0]["col_norm_L6"].ToString()

                        #region
                        StringBuilder sb1 = new StringBuilder();
                        if (!string.IsNullOrEmpty(dt.Rows[0]["col_norm_L6"].ToString()))
                        {
                            string pathname = dt.Rows[0]["ID"].ToString();
                            string fullPath = Server.MapPath("../userphoto/ ") + pathname + ".jpg";
                            if (!File.Exists(fullPath))
                            {
                                object o = dt.Rows[0]["col_norm_L6"];
                                var    _tempMemoryStream = new MemoryStream((byte[])o);
                                System.Drawing.Image img = System.Drawing.Image.FromStream(_tempMemoryStream);
                                img.Save(fullPath);
                                _tempMemoryStream.Close();
                            }
                            else
                            {
                            }
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../userphoto/" + pathname + ".jpg\" />");
                        }
                        else
                        {
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../images/nohead.png\" />");
                        }
                        Literal3.Text = sb1.ToString();
                        #endregion


                        #region
                        if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B14"].ToString()))
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 14; i < 28; i++)
                            {
                                if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B" + i + ""].ToString()))
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + dt.Rows[0]["col_norm_B" + i + ""].ToString() + "</td>");
                                    sb.Append("<td colspan=\"3\">" + dt.Rows[0]["col_norm_E" + i + ""].ToString() + "</td>");
                                    sb.Append("<td>" + dt.Rows[0]["col_norm_K" + i + ""].ToString() + "</td>");
                                    sb.Append("<td>" + dt.Rows[0]["col_norm_M" + i + ""].ToString() + "</td></tr>");
                                }
                            }
                            Literal1.Text = sb.ToString();
                        }
                        else
                        {
                            tr_gzjl.Style["display"]    = "none";
                            tr_gzjl_mx.Style["display"] = "none";
                        }

                        if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B31"].ToString()))
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 31; i < 37; i++)
                            {
                                if (!String.IsNullOrEmpty(dt.Rows[0]["col_norm_B" + i + ""].ToString()))
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + dt.Rows[0]["col_norm_B" + i + ""].ToString() + "</td>");
                                    sb.Append("<td colspan=\"4\">" + dt.Rows[0]["col_norm_E" + i + ""].ToString() + "</td>");


                                    try
                                    {
                                        string[] Temp = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(dt.Rows[0]["col_norm_K" + i + ""].ToString());

                                        sb.Append("<td>" + Temp[0] + "<img src='data:image/gif;base64," + Temp[1] + "' /></td></tr>");
                                    }
                                    catch
                                    {
                                        sb.Append("<td>" + dt.Rows[0]["col_norm_K" + i + ""].ToString() + "' /></td></tr>");
                                    }
                                }
                            }
                            Literal2.Text = sb.ToString();
                        }
                        else
                        {
                            tr_pxjl.Style["display"]    = "none";
                            tr_pxjl_mx.Style["display"] = "none";
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    string SQL = "SELECT * FROM dbo.sys_document WHERE ID='" + id + "'";

                    DataSet    ds  = DbHelperSQL.Query(SQL);
                    string     str = ds.Tables[0].Rows[0]["Data"].ToString();
                    JZDocument doc = Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(str);
                    if (doc != null)
                    {
                        #region
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D6") != null)
                        {
                            lbl_xingming.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D6").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G6") != null)
                        {
                            lbl_xingbie.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G6").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K6") != null)
                        {
                            lbl_nianling.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K6").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D7") != null)
                        {
                            lbl_jishuzhicheng.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D7").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G7") != null)
                        {
                            lbl_zhiwu.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G7").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K7") != null)
                        {
                            lbl_gongzuonianxian.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K7").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D8") != null)
                        {
                            lbl_zhuanye.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D8").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G8") != null)
                        {
                            lbl_xueli.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G8").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K8") != null)
                        {
                            lbl_biyeshijian.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K8").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D9") != null)
                        {
                            lbl_lianxidianhua.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D9").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G9") != null)
                        {
                            lbl_biyexuexiao.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "G9").ToString();
                        }
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D10") != null)
                        {
                            lbl_idcard.Text = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "D10").ToString();
                        }
                        #endregion

                        #region
                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B14") != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 14; i < 28; i++)
                            {
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "") != null)
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<tr><td colspan=\"2\"></td>");
                                }
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "") != null)
                                {
                                    sb.Append("<td colspan=\"3\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<td colspan=\"3\"></td>");
                                }

                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "") != null)
                                {
                                    sb.Append("<td>" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<td></td>");
                                }

                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i + "") != null)
                                {
                                    sb.Append("<td>" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "M" + i + "").ToString() + "</td></tr>");
                                }
                                else
                                {
                                    sb.Append("<td></td></tr>");
                                }
                            }
                            Literal1.Text = sb.ToString();
                        }
                        else
                        {
                            tr_gzjl.Style["display"]    = "none";
                            tr_gzjl_mx.Style["display"] = "none";
                        }


                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B31") != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            for (int i = 31; i < 37; i++)
                            {
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "") != null)
                                {
                                    sb.Append("<tr><td colspan=\"2\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "B" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<tr><td colspan=\"2\"></td>");
                                }
                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "") != null)
                                {
                                    sb.Append("<td colspan=\"4\">" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "E" + i + "").ToString() + "</td>");
                                }
                                else
                                {
                                    sb.Append("<td colspan=\"4\"></td>");
                                }

                                if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "") != null)
                                {
                                    try
                                    {
                                        string[] Temp = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString());

                                        System.Drawing.Image img = BizCommon.JZCommonHelper.StringToBitmap(Temp[1]);

                                        sb.Append("<td>" + Temp[0] + "&nbsp;&nbsp;&nbsp;&nbsp;<a title=\"点击查看大图\" href=\"javascript:Show('" + id + "','" + doc.Sheets[0].ID.ToString() + "'," + i + ")\"><img src='data:image/gif;base64," + Temp[1] + "' height=\"30px;\" /></a></td>");
                                    }
                                    catch
                                    {
                                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString() != "[null,null,null]")
                                        {
                                            sb.Append("<td>" + JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "K" + i + "").ToString() + "</td>");
                                        }
                                        else
                                        {
                                            sb.Append("<td></td>");
                                        }
                                    }
                                }
                                else
                                {
                                    sb.Append("<td></td>");
                                }
                            }
                            Literal2.Text = sb.ToString();
                        }
                        else
                        {
                            tr_pxjl.Style["display"]    = "none";
                            tr_pxjl_mx.Style["display"] = "none";
                        }

                        #endregion

                        #region
                        StringBuilder sb1 = new StringBuilder();


                        if (JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L6") != null)
                        {
                            string pathname = id;
                            string fullPath = Server.MapPath("../userphoto/ ") + pathname + ".jpg";
                            if (!File.Exists(fullPath))
                            {
                                object o = JZCommonHelper.GetCellValue(doc, doc.Sheets[0].ID, "L6");
                                System.Drawing.Image img = null;
                                byte[] bitmapBytes       = System.Convert.FromBase64String(o.ToString());
                                using (MemoryStream memoryStream = new MemoryStream(bitmapBytes))
                                {
                                    img = System.Drawing.Image.FromStream(memoryStream);
                                    img.Save(fullPath);
                                    memoryStream.Close();
                                }
                            }
                            //else
                            //{
                            //    sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../images/nohead.png\" />");
                            //}
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../userphoto/" + pathname + ".jpg\" />");
                        }
                        else
                        {
                            sb1.Append("<img width=\"130px\" height=\"165px\" src=\"../images/nohead.png\" />");
                        }
                        Literal3.Text = sb1.ToString();
                        #endregion
                    }
                }
            }
        }
    }