Newer
Older
GHFX_REFACTOR / FrmHotFuncStatTitle.cs
wxn on 2 Nov 2016 4 KB 提交
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Windows.Forms.DataVisualization.Charting;
using System.IO;

namespace Cyberpipe
{
    public partial class FrmHotFuncStatTitle : Office2007Form
    {
        Chart chart1;
        string title; 
        PATM_logicfile.PATM_Affair PEDAClass = new Cyberpipe.PATM_logicfile.PATM_Affair();//实例化ModuleClass文件夹下的FrmAffairClass公共类

        public FrmHotFuncStatTitle(Chart chart,string title)
        {
            InitializeComponent();
            this.chart1 = chart;
            this.title = title;

            txtThemticMap.Text = title;
            //初始化comboBox
            //initProjects();
        }
        ////初始化已有工程
        //public void initProjects() {
        //    cboProjects.Items.Clear();
        //    string sql = "select NODENAME from casic_hfs where NODEPID = 0 and NODESIGN='"
        //        +Utility.userName+"'";
        //    DataTable table = OledbHelper.QueryTable(sql);

        //    if (table != null)
        //    {
        //        for (int i = 0; i < table.Rows.Count; i++)
        //        {
        //            cboProjects.Items.Add(table.Rows[i][0].ToString());
        //        }
        //    }
        //    else {
        //        MessageBox.Show("mo");
        //    }
        
        //}
        private void buttonX1_Click(object sender, EventArgs e)
        {
            int n = 0;
            //判断有无文件夹,若有则直接加入该文件夹,若没有则创建该文件夹
            if (cboProjects2.Text.Trim() == "")
            {
                MessageBox.Show("项目名称不能为空。");
                return;
            }
            else //判断有无文件夹,若有则直接加入该文件夹,若没有则创建该文件夹,且写入数据库
            {
                n = Folder_Handle(cboProjects2.Text.Trim());
            }

            int result = File_Handle(cboProjects2.Text.Trim(), this.txtThemticMap.Text.Trim());
            if (result == 1) {
                MessageBox.Show("保存成功");
            }
                            
            Close();
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            Close();
        }
        //对文件夹的操作
        private int Folder_Handle(string NewName) {
            string url = textBoxX1.Text +"\\"+ NewName;
           
            //判断在files下有无newname的文件夹,有则返回1,且检查数据库中有无该文件夹的数据;
            //若没有该文件夹则创建该名称的文件夹并返回0,且数据库中添加该文件夹的数据;
            if (Directory.Exists(url) == true)
            {
                MessageBox.Show("文件夹" + NewName + "已存在,专题图将直接添加。"); 
            }else{
                Directory.CreateDirectory(url); 
            } 
            return 0;
             
        }

        //对文件的操作
        private int File_Handle(string folderName,string FileName)
        {
            string url = textBoxX1.Text + "\\" + folderName + "\\" + FileName + ".png";
              
            if (File.Exists(url) == true)
            { //文件存在
                MessageBox.Show("文件" + FileName + "已存在,可以另修改文件名后保存。");  

            }
            else {//文件不存在
                this.chart1.SaveImage(url, System.Drawing.Imaging.ImageFormat.Png); 
                return 1;
            }

            return 0;
        
        }
        string tempstr = "";
        private void buttonX3_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)                  //打开文件夹对话框
            {
                textBoxX1.Text = folderBrowserDialog1.SelectedPath;      
                tempstr = folderBrowserDialog1.SelectedPath;                                                            //执行当前线程

            }
        }

        private void textBoxX1_TextChanged(object sender, EventArgs e)
        {

        }

        private void labelX3_Click(object sender, EventArgs e)
        {

        }
    }
}