HYDocumentMS.FileAuth.UserFileAuthFrm.btnFolderSubmit_Click C# (CSharp) Метод

btnFolderSubmit_Click() приватный Метод

private btnFolderSubmit_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void
        private void btnFolderSubmit_Click(object sender, EventArgs e)
        {
            createDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string folderKey = "";
            //TreeNode node = this.trvFolderDir.SelectedNode;

            getListFolderId();

            if (listFolderChk == null || listFolderChk.Count == 0)
            {
                MessageBox.Show("没有选中需要设定权限的文件夹!!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }
            //if (node == null)
            //{
            //    MessageBox.Show("没有选中需要设定权限的文件夹!!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
            //    return;
            //}
            else
            {
                //  folderKey = node.Tag.ToString();
            }
            fileView = this.chkView.Checked == true ? "Y" : "N";
            fileEdit = this.chkEdit.Checked == true ? "Y" : "N";
            fileDelete = this.chkDelete.Checked == true ? "Y" : "N";
            fileUpload = this.chkUpLoad.Checked == true ? "Y" : "N";
            fileDownLoad = this.chkDownLoad.Checked == true ? "Y" : "N";
            fileChkIn = this.chkCheckIN.Checked == true ? "Y" : "N";
            fileChkOut = this.chkCheckOut.Checked == true ? "Y" : "N";
            createDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            folderCreate = this.chkFolderCreate.Checked == true ? "Y" : "N";
            folderDelete = this.chkFolderDelete.Checked == true ? "Y" : "N";
            folderEdit = this.chkFolderEdit.Checked == true ? "Y" : "N";
            FILE_AUTH auth = null;
            Boolean blStart = true;
            if (fileView == "N" && fileEdit == "N" && fileDelete == "N" && fileUpload == "N" && fileDownLoad == "N" && fileChkIn == "N" && fileChkOut == "N" && folderCreate == "N" && folderDelete == "N" && folderEdit == "N")
            {
                if (MessageBox.Show("没有设定任何权限,请确认是否继续!!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.OK)
                {

                }
                else
                {
                    blStart = false;
                }
            }

            if (blStart)
            {
                if (AuthObjectType == DataType.AuthObjectType.UserRole)
                {

                    //if (!folderKey.Equals(""))
                    //{
                    foreach (string ss in listFolderChk)
                    {
                        folderKey = ss;
                        try
                        {
                            auth = _fileAuth.GetFileAuth(DataType.AuthObjectType.UserRole.ToString(), this.UserRole, "Y", folderKey);
                            if (auth == null)
                            {
                                auth = new FILE_AUTH();
                                auth.CREATEUSER = LoginInfo.LoginID;
                                auth.CREATEDATE = createDate;
                                auth.FAU_ID = Guid.NewGuid().ToString();
                            }
                            else
                            {
                                auth.LASTUPDATEUSER = LoginInfo.LoginID;
                                auth.LASTUPDATEDATE = createDate;
                            }
                            auth.DEL_FLAG = "N";
                            auth.FAU_CHECKIN = fileChkIn;
                            auth.FAU_CHECKOUT = fileChkOut;
                            auth.FAU_DELETE = fileDelete;
                            auth.FAU_DOWNLOAD = fileDownLoad;
                            auth.FAU_UPLOAD = fileUpload;
                            auth.FAU_VIEW = fileView;
                            auth.FAU_EDIT = fileEdit;
                            auth.FOLDERCREATE = this.folderCreate;
                            auth.FOLDERDELETE = this.folderDelete;
                            auth.FOLDEREDIT = this.folderEdit;

                            auth.FAU_OBJ_TYPE = DataType.AuthObjectType.UserRole.ToString();
                            auth.FAU_OBJ_VALUE = this.UserRole.ToString();
                            auth.DFL_ID = folderKey.ToString();
                            auth.FAU_IS_FOLDER = "Y";
                            auth.Save();

                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString(), "插入异常", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                            return;
                        }
                    }
                    MessageBox.Show("插入成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    this.Close();
                }
                //else
                //{
                //    MessageBox.Show("选中的文件夹主键不能为空!!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                //    return;
                //}
                //MessageBox.Show("插入成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                //this.Close();
                //DOC_FILE_LIST list = new DOC_FILE_LIST();

                else if (AuthObjectType == DataType.AuthObjectType.SingleUser)
                {
                    //if (!folderKey.Equals(""))
                    //{
                    foreach (string ss in listFolderChk)
                    {
                        folderKey = ss;
                        try
                        {
                            //Boolean operState = true;
                            auth = _fileAuth.GetFileAuth(DataType.AuthObjectType.SingleUser.ToString(), this.UserAccount, "Y", folderKey);
                            if (auth == null)
                            {
                                auth = new FILE_AUTH();
                                auth.CREATEUSER = LoginInfo.LoginID;
                                auth.CREATEDATE = createDate;
                                auth.FAU_ID = Guid.NewGuid().ToString();
                            }
                            else
                            {
                                auth.LASTUPDATEUSER = LoginInfo.LoginID;
                                auth.LASTUPDATEDATE = createDate;
                                //  operState = false;
                            }
                            auth.DEL_FLAG = "N";
                            auth.FAU_CHECKIN = fileChkIn;
                            auth.FAU_CHECKOUT = fileChkOut;
                            auth.FAU_DELETE = fileDelete;
                            auth.FAU_DOWNLOAD = fileDownLoad;
                            auth.FAU_UPLOAD = fileUpload;
                            auth.FAU_VIEW = fileView;
                            auth.FAU_EDIT = fileEdit;
                            auth.FOLDERCREATE = this.folderCreate;
                            auth.FOLDERDELETE = this.folderDelete;
                            auth.FOLDEREDIT = this.folderEdit;

                            auth.FAU_OBJ_TYPE = DataType.AuthObjectType.SingleUser.ToString();
                            auth.FAU_OBJ_VALUE = this.UserAccount.ToString();
                            auth.DFL_ID = folderKey.ToString();
                            auth.FAU_IS_FOLDER = "Y";
                            auth.Save();
                            //if (operState)
                            //{
                            //    auth.Save();
                            //}
                            //else
                            //{
                            //    auth.Update();
                            //}
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString(), "插入异常", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                            return;
                        }
                    }
                    MessageBox.Show("插入成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    this.Close();
                }
            }
        }