示例#1
0
 /// <summary>
 /// 重置控件
 /// </summary>
 private void ResetControl()
 {
     foreach (Control item in Controls)
     {
         if (!(item is Label))
         {
             if (item is TextBox || item is DateTimePicker)
             {
                 item.ResetText();
             }
             else if (item is NumericUpDown)
             {
                 (item as NumericUpDown).Value = 0;
             }
             else if (item is ComboBox)
             {
                 if (!item.Name.Equals("cbo_stage") && !item.Name.Equals("txt_fileName"))
                 {
                     (item as ComboBox).SelectedIndex = 0;
                 }
             }
         }
     }
     txt_unit.Text = UserHelper.GetUser().UserUnitName;
 }
示例#2
0
        private void Frm_Export_Load(object sender, EventArgs e)
        {
            LoadFileInfo(UserHelper.GetUser().UserSpecialId);
            List <object[]> projectIds = SQLiteHelper.ExecuteColumnsQuery($"SELECT pi_id FROM project_info WHERE pi_obj_id='{UserHelper.GetUser().UserSpecialId}'", 1);

            for (int i = 0; i < projectIds.Count; i++)
            {
                LoadFileInfo(projectIds[i][0]);
                List <object[]> pro_top_ids = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id FROM topic_info WHERE ti_obj_id='{projectIds[i][0]}'", 1);
                for (int j = 0; j < pro_top_ids.Count; j++)
                {
                    LoadFileInfo(pro_top_ids[j][0]);
                    List <object[]> pro_top_sub_ids = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id FROM subject_info WHERE si_obj_id='{pro_top_ids[j][0]}'", 1);
                    for (int k = 0; k < pro_top_sub_ids.Count; k++)
                    {
                        LoadFileInfo(pro_top_sub_ids[k][0]);
                    }
                }
            }
            List <object[]> topicIds = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id FROM topic_info WHERE ti_obj_id='{UserHelper.GetUser().UserSpecialId}'", 1);

            for (int i = 0; i < topicIds.Count; i++)
            {
                LoadFileInfo(topicIds[i][0]);
                List <object[]> pro_top_sub_ids = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id FROM subject_info WHERE si_obj_id='{topicIds[i][0]}'", 1);
                for (int k = 0; k < pro_top_sub_ids.Count; k++)
                {
                    LoadFileInfo(pro_top_sub_ids[k][0]);
                }
            }

            pro_Show.Maximum = list.Count;
        }
示例#3
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            string yPW = txt_PassWord.Text;

            if (UserHelper.GetUser().PassWord.Equals(yPW))
            {
                string nPW  = txt_NewPassWord.Text;
                string nPWA = txt_NewPassWordAgain.Text;
                if (nPW.Equals(nPWA) && MessageBox.Show("确定要修改密码吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    SQLiteHelper.ExecuteNonQuery($"UPDATE user_info SET ui_password='******' WHERE ui_id='{UserHelper.GetUser().UserId}'");
                    UserHelper.GetUser().PassWord = nPW;
                    MessageBox.Show("修改成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    Close();
                }
                else
                {
                    MessageBox.Show("两次输入密码不一致。", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("原密码不正确。", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        private void pic_Manager_Click(object sender, EventArgs e)
        {
            string specialId = UserHelper.GetUser().UserSpecialId;

            if (!string.IsNullOrEmpty(specialId))
            {
                Frm_Manager manager = new Frm_Manager(specialId);
                manager.ShowDialog();
            }
            else
            {
                MessageBox.Show("当前用户尚未指定专项。");
            }
        }
示例#5
0
        /// <summary>
        /// 开始读取
        /// </summary>
        private void btn_Import_Click_1(object sender, EventArgs e)
        {
            string sPath = txt_FilePath.Text;

            if (!string.IsNullOrEmpty(sPath))
            {
                if (SQLiteHelper.ExecuteCountQuery($"SELECT COUNT(*) FROM backup_files_info WHERE bfi_name='{UserHelper.GetUser().RealName}' AND bfi_code='-1'") == 0)
                {
                    object IPAddress = null;
                    if (ServerHelper.GetConnectState(ref IPAddress))
                    {
                        string rootFolder = @"\\" + IPAddress + @"\共享文件夹\";

                        btn_Import.Enabled = false;
                        count = okCount = noCount = indexCount = 0;
                        int totalFileAmount = Directory.GetFiles(sPath, "*", SearchOption.AllDirectories).Length;
                        pro_Show.Value   = pro_Show.Minimum;
                        pro_Show.Maximum = totalFileAmount;

                        string primaryKey = Guid.NewGuid().ToString();
                        SQLiteHelper.ExecuteNonQuery($"INSERT INTO backup_files_info(bfi_id, bfi_code, bfi_name, bfi_date, bfi_userid) VALUES " +
                                                     $"('{primaryKey}', '{-1}', '{UserHelper.GetUser().RealName}', '{DateTime.Now.ToString("s")}', '{UserHelper.GetUser().UserId}')");
                        new Thread(delegate()
                        {
                            CopyFile(sPath, rootFolder, primaryKey);

                            CopyDataTable(sPath, rootFolder);

                            MessageBox.Show($"读取完毕,共计{count}个文件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            DialogResult = DialogResult.OK;
                            Close();
                            Thread.CurrentThread.Abort();
                        }).Start();
                    }
                    else
                    {
                        MessageBox.Show("访问备份服务器失败。", "连接错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (MessageBox.Show("当前专项已导入,是否删除当前数据记录。", "操作失败", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    SQLiteHelper.ExecuteNonQuery($"DELETE FROM backup_files_info WHERE bfi_userid='{UserHelper.GetUser().UserId}'");
                    MessageBox.Show("删除完毕,重新导入即可。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
示例#6
0
        private void Frm_MainFrame_Shown(object sender, EventArgs e)
        {
            string querySql = $"SELECT spi_id, spi_name FROM special_info WHERE spi_id=(SELECT ui_special_id FROM user_info WHERE ui_id='{UserHelper.GetUser().UserId}')";

            object[] obj = SQLiteHelper.ExecuteRowsQuery(querySql);
            if (obj == null)
            {
                Frm_IdentityChoose frm_Identity = new Frm_IdentityChoose();
                if (frm_Identity.ShowDialog() == DialogResult.OK)
                {
                    obj = SQLiteHelper.ExecuteRowsQuery(querySql);
                }
            }
            if (obj != null)
            {
                rootId = GetValue(obj[0]);
                UserHelper.GetUser().UserSpecialId = rootId;
                UserHelper.GetUser().SpecialName   = GetValue(obj[1]);
                LoadTreeList(rootId);
                NodeMouseClick(sender, new TreeNodeMouseClickEventArgs(tv_DataTree.Nodes[0], MouseButtons.Left, 1, 0, 0));

                new Frm_Explain().ShowDialog();
            }
        }
示例#7
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            string username = txt_Username.Text;
            string password = txt_Password.Text;

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
            {
                object uid = SQLiteHelper.ExecuteOnlyOneQuery($"SELECT ui_id FROM user_info WHERE ui_username='******' AND ui_password='******'");
                if (!string.IsNullOrEmpty(GetValue(uid)))
                {
                    DataRow row  = SQLiteHelper.ExecuteSingleRowQuery($"SELECT * FROM user_info WHERE ui_id='{uid}'");
                    User    user = UserHelper.GetUser();
                    user.UserId        = uid;
                    user.UserName      = username;
                    user.RealName      = GetValue(row["ui_realname"]);
                    user.UserSpecialId = GetValue(row["ui_special_id"]);
                    user.UserUnitId    = GetValue(row["ui_unit"]);
                    user.UserUnitName  = SQLiteHelper.GetValueByKey(user.UserUnitId);
                    user.PassWord      = password;

                    DataRow spRow = SQLiteHelper.ExecuteSingleRowQuery($"SELECT * FROM special_info WHERE spi_id='{user.UserSpecialId}'");
                    if (spRow != null)
                    {
                        user.SpecialName = GetValue(spRow["spi_name"]);
                    }

                    Frm_MainFrame frm = new Frm_MainFrame();
                    frm.Show();
                    Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误。", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
示例#8
0
        private void btn_Sure_Click(object sender, EventArgs e)
        {
            object id      = cbo_ChooseIdentity.SelectedValue;
            string name    = cbo_ChooseIdentity.Text;
            string depName = txt_Unit.Text;

            if (string.IsNullOrEmpty(depName))
            {
                new ErrorProvider().SetError(txt_Unit, "提示:单位名称不能为空。");
            }
            else if (MessageBox.Show($"选择后不可修改,确定是属于{name}吗?", "确认提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
            {
                SQLiteHelper.ExecuteNonQuery($"UPDATE user_info SET ui_department='{depName}', ui_special_id='{id}' WHERE ui_id='{UserHelper.GetUser().UserId}'");
                DialogResult = DialogResult.OK;
                Close();
            }
        }
示例#9
0
        private void Btn_Start_Click(object sender, EventArgs e)
        {
            progressBar1.Maximum = GetTotalFileAmountBySpiId(UserHelper.GetUser().UserSpecialId);
            int    count = progressBar1.Maximum, okcount = 0, nocount = 0;
            string rootFolder = txt_FilePath.Text + "\\" + SQLiteHelper.ExecuteOnlyOneQuery($"SELECT spi_name FROM special_info WHERE spi_id='{UserHelper.GetUser().UserSpecialId}'");

            if (!Directory.Exists(rootFolder))
            {
                Directory.CreateDirectory(rootFolder);
            }
            //专项下的文件
            CopyFile(ref okcount, ref nocount, rootFolder, GetFileLinkByObjId(UserHelper.GetUser().UserSpecialId));
            //专项下的项目
            List <object[]> list2 = SQLiteHelper.ExecuteColumnsQuery($"SELECT pi_id, pi_name FROM project_info WHERE pi_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2);

            for (int i = 0; i < list2.Count; i++)
            {
                string _rootFolder = rootFolder + "\\" + list2[i][1];
                if (!Directory.Exists(_rootFolder))
                {
                    Directory.CreateDirectory(_rootFolder);
                }
                //项目下的文件
                CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list2[i][0]));

                //项目下的课题
                List <object[]> list5 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{list2[i][0]}'", 2);
                for (int j = 0; j < list5.Count; j++)
                {
                    string _rootFolder2 = _rootFolder + "\\" + list5[j][1];
                    if (!Directory.Exists(_rootFolder2))
                    {
                        Directory.CreateDirectory(_rootFolder2);
                    }
                    //课题下的文件
                    CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list5[j][0]));

                    //课题下的子课题
                    List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list5[j][0]}'", 2);
                    for (int k = 0; k < list6.Count; k++)
                    {
                        string _rootFolder3 = _rootFolder2 + "\\" + list6[k][1];
                        if (!Directory.Exists(_rootFolder3))
                        {
                            Directory.CreateDirectory(_rootFolder3);
                        }
                        CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0]));
                    }
                }
                //项目下的子课题
                List <object[]> list7 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list2[i][0]}'", 2);
                for (int j = 0; j < list7.Count; j++)
                {
                    string _rootFolder2 = _rootFolder + "\\" + list7[j][1];
                    if (!Directory.Exists(_rootFolder2))
                    {
                        Directory.CreateDirectory(_rootFolder2);
                    }
                    CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list7[j][0]));
                }
            }
            //专项下的课题
            List <object[]> list4 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2);

            for (int i = 0; i < list4.Count; i++)
            {
                string _rootFolder = rootFolder + "\\" + list4[i][1];
                if (!Directory.Exists(_rootFolder))
                {
                    Directory.CreateDirectory(_rootFolder);
                }
                //课题下的文件
                CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list4[i][0]));

                //课题下的子课题
                List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list4[i][0]}'", 2);
                for (int k = 0; k < list6.Count; k++)
                {
                    string _rootFolder3 = _rootFolder + "\\" + list6[k][1];
                    if (!Directory.Exists(_rootFolder3))
                    {
                        Directory.CreateDirectory(_rootFolder3);
                    }
                    CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0]));
                }
            }
            MessageBox.Show($"备份完成,共计{count}个文件,成功{okcount}个,失败{nocount}个。", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            Close();
        }
示例#10
0
        /// <summary>
        /// 拷贝文件到备份服务器
        /// </summary>
        /// <param name="sPath">源文件夹路径</param>
        /// <param name="rootFolder">目标文件夹基路径</param>
        private void CopyFile(string sPath, string rootFolder, string pid)
        {
            DirectoryInfo info = new DirectoryInfo(sPath);

            FileInfo[] file = info.GetFiles();
            count += file.Length;
            for (int i = 0; i < file.Length; i++)
            {
                string primaryKey = Guid.NewGuid().ToString();
                try
                {
                    SetTip($"正在备份文件[{file[i].Name}]");
                    SQLiteHelper.ExecuteNonQuery($"INSERT INTO backup_files_info(bfi_id, bfi_code, bfi_name, bfi_path, bfi_date, bfi_pid, bfi_userid) VALUES " +
                                                 $"('{primaryKey}', '{indexCount++.ToString().PadLeft(6, '0')}', '{file[i].Name}', '{rootFolder}', '{DateTime.Now.ToString("s")}', '{pid}', '{UserHelper.GetUser().UserId}')");
                    ServerHelper.UploadFile(file[i].FullName, rootFolder, file[i].Name);
                    okCount++;
                }
                catch (Exception)
                {
                    noCount++;
                }
                pro_Show.Value += 1;
            }
            DirectoryInfo[] infos = info.GetDirectories();
            for (int i = 0; i < infos.Length; i++)
            {
                string primaryKey = Guid.NewGuid().ToString();
                SQLiteHelper.ExecuteNonQuery($"INSERT INTO backup_files_info(bfi_id, bfi_code, bfi_name, bfi_path, bfi_date, bfi_pid, bfi_userid) VALUES " +
                                             $"('{primaryKey}', '{indexCount++.ToString().PadLeft(6, '0')}', '{infos[i].Name}', '{rootFolder}', '{DateTime.Now.ToString("s")}', '{pid}', '{UserHelper.GetUser().UserId}')");
                CopyFile(infos[i].FullName, rootFolder + infos[i].Name + @"\", primaryKey);
            }
        }
示例#11
0
        private void btn_Export_Click(object sender, EventArgs e)
        {
            object KEY   = "SAVE_PATH";
            object value = SQLiteHelper.ExecuteOnlyOneQuery($"SELECT dd_name FROM data_dictionary WHERE dd_code='{KEY}'");

            if (value != null)
            {
                /* ----复制文件----*/
                pro_Show.Maximum = GetTotalFileAmountBySpiId(UserHelper.GetUser().UserSpecialId);
                int    count = pro_Show.Maximum, okcount = 0, nocount = 0;
                string rootFolder = value + "\\" + SQLiteHelper.ExecuteOnlyOneQuery($"SELECT spi_name FROM special_info WHERE spi_id='{UserHelper.GetUser().UserSpecialId}'");
                if (!Directory.Exists(rootFolder))
                {
                    Directory.CreateDirectory(rootFolder);
                }
                //专项下的文件
                CopyFile(ref okcount, ref nocount, rootFolder, GetFileLinkByObjId(UserHelper.GetUser().UserSpecialId));
                //专项下的项目
                List <object[]> list2 = SQLiteHelper.ExecuteColumnsQuery($"SELECT pi_id, pi_name FROM project_info WHERE pi_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2);
                for (int i = 0; i < list2.Count; i++)
                {
                    string _rootFolder = rootFolder + "\\" + list2[i][1];
                    if (!Directory.Exists(_rootFolder))
                    {
                        Directory.CreateDirectory(_rootFolder);
                    }
                    //项目下的文件
                    CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list2[i][0]));

                    //项目下的课题
                    List <object[]> list5 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{list2[i][0]}'", 2);
                    for (int j = 0; j < list5.Count; j++)
                    {
                        string _rootFolder2 = _rootFolder + "\\" + list5[j][1];
                        if (!Directory.Exists(_rootFolder2))
                        {
                            Directory.CreateDirectory(_rootFolder2);
                        }
                        //课题下的文件
                        CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list5[j][0]));

                        //课题下的子课题
                        List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list5[j][0]}'", 2);
                        for (int k = 0; k < list6.Count; k++)
                        {
                            string _rootFolder3 = _rootFolder2 + "\\" + list6[k][1];
                            if (!Directory.Exists(_rootFolder3))
                            {
                                Directory.CreateDirectory(_rootFolder3);
                            }
                            CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0]));
                        }
                    }
                    //项目下的子课题
                    List <object[]> list7 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list2[i][0]}'", 2);
                    for (int j = 0; j < list7.Count; j++)
                    {
                        string _rootFolder2 = _rootFolder + "\\" + list7[j][1];
                        if (!Directory.Exists(_rootFolder2))
                        {
                            Directory.CreateDirectory(_rootFolder2);
                        }
                        CopyFile(ref okcount, ref nocount, _rootFolder2, GetFileLinkByObjId(list7[j][0]));
                    }
                }
                //专项下的课题
                List <object[]> list4 = SQLiteHelper.ExecuteColumnsQuery($"SELECT ti_id, ti_name FROM topic_info WHERE ti_obj_id='{UserHelper.GetUser().UserSpecialId}'", 2);
                for (int i = 0; i < list4.Count; i++)
                {
                    string _rootFolder = rootFolder + "\\" + list4[i][1];
                    if (!Directory.Exists(_rootFolder))
                    {
                        Directory.CreateDirectory(_rootFolder);
                    }
                    //课题下的文件
                    CopyFile(ref okcount, ref nocount, _rootFolder, GetFileLinkByObjId(list4[i][0]));

                    //课题下的子课题
                    List <object[]> list6 = SQLiteHelper.ExecuteColumnsQuery($"SELECT si_id, si_name FROM subject_info WHERE si_obj_id='{list4[i][0]}'", 2);
                    for (int k = 0; k < list6.Count; k++)
                    {
                        string _rootFolder3 = _rootFolder + "\\" + list6[k][1];
                        if (!Directory.Exists(_rootFolder3))
                        {
                            Directory.CreateDirectory(_rootFolder3);
                        }
                        CopyFile(ref okcount, ref nocount, _rootFolder3, GetFileLinkByObjId(list6[k][0]));
                    }
                }
                MessageBox.Show($"备份完成,共计{count}个文件,成功{okcount}个,失败{nocount}个。", "操作成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                /* ----合成文件清单----*/
                string filePath = value + "\\重大专项项目(课题)档案交接清单";
                MicrosoftWordHelper.WriteDocument(filePath, list);
                if (MessageBox.Show("文件清单合成完毕, 是否需要现在打开?", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                {
                    LoadDocumnet(filePath);
                }
                Close();
            }
            else
            {
                MessageBox.Show("尚未指定文件存放路径。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
示例#12
0
 private void Frm_EditPassword_Load(object sender, EventArgs e)
 {
     lbl_UserName.Text = UserHelper.GetUser().UserName;
 }