Esempio n. 1
0
        private void Btn_Delete_Click(object sender, EventArgs e)
        {
            if (UserHelper.GetUserRole() != UserRole.DocManager)
            {
                XtraMessageBox.Show("仅档案管理员可以删除文件。", "提示");
                return;
            }
            int[] rowCount = view.GetSelectedRows();
            if (rowCount.Length > 0)
            {
                if (XtraMessageBox.Show($"确认删除选中的{rowCount.Length}条数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    string ids = string.Empty;
                    foreach (int rowIndex in rowCount)
                    {
                        ids += $"'{view.GetRowCellValue(rowIndex, "at_id")}',";
                    }
                    if (!string.IsNullOrEmpty(ids))
                    {
                        ids = ids.Substring(0, ids.Length - 1);
                    }

                    string deleteSQL = $"DELETE FROM Attachment WHERE at_id IN({ids});";
                    SqlHelper.ExecuteNonQuery(deleteSQL);
                    XtraMessageBox.Show("删除成功!");
                    Frm_Download_Load(null, null);
                }
            }
        }
Esempio n. 2
0
        private void Btn_Upload_Click(object sender, EventArgs e)
        {
            if (UserHelper.GetUserRole() != UserRole.DocManager)
            {
                XtraMessageBox.Show("仅档案管理员可以上传文件。", "提示");
                return;
            }
            Frm_UploadFile uploadFile = new Frm_UploadFile();

            if (uploadFile.ShowDialog() == DialogResult.OK)
            {
                string filePath    = uploadFile.txt_filePath.Text;
                string fileName    = uploadFile.txt_fileName.Text;
                string fileCode    = uploadFile.txt_fileCode.Text;
                string fileVersion = uploadFile.txt_fileVersion.Text;
                int    fileType    = uploadFile.cbo_fileType.SelectedIndex;

                progressBar.Visible            = true;
                progressBar.Properties.Stopped = false;
                progressBar.Text = "正在上传文件...";
                new Thread(delegate()
                {
                    string insertSQL  = string.Empty;
                    SqlConnection con = SqlHelper.GetConnect();
                    FileInfo info     = new FileInfo(filePath);
                    string primaryKey = Guid.NewGuid().ToString();
                    insertSQL        += "INSERT INTO Attachment(at_id, at_name, at_size, at_date, at_uploader, at_entity, at_version, at_type, at_code) " +
                                        $"VALUES ('{primaryKey}' ,'{fileName}' ,'{(float)(info.Length / 1024f)}' ,'{DateTime.Now}' ,'{UserHelper.GetUser().UserKey}', @fileByte, '{fileVersion}', {fileType}, '{fileCode}');";
                    byte[] fileByte = GetByteFromFile(info);
                    SqlCommand com  = new SqlCommand(insertSQL, con);
                    com.Parameters.Add("@fileByte", SqlDbType.Image, fileByte.Length);
                    com.Parameters["@fileByte"].Value = fileByte;
                    com.ExecuteNonQuery();
                    progressBar.Properties.Stopped = true;
                    progressBar.Text = "文件上传成功。";
                }).Start();
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 获取当前登录用户的身份
 /// </summary>
 public static string GetUserRoleName()
 {
     if (UserHelper.GetUserRole() == UserRole.Worker)
     {
         return("加工人员");
     }
     else if (UserHelper.GetUserRole() == UserRole.Qualityer)
     {
         return("质检人员");
     }
     else if (UserHelper.GetUserRole() == UserRole.W_Q_Manager)
     {
         return("管理员(线上)");
     }
     else if (UserHelper.GetUserRole() == UserRole.DocManager)
     {
         return("档案管理员");
     }
     else if (UserHelper.GetUserRole() == UserRole.Ordinary)
     {
         return("普通用户");
     }
     return("未知身份");
 }