Beispiel #1
0
        void cmdDownload_Click(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e)
        {
            if (this.tvTask.SelectedNode != null)
            {
                XTaskFilesInfo model = this.tvTask.SelectedNode.Tag as XTaskFilesInfo;

                string mainId = model.RID;

                bool isExist = this.m_FileAttachBusiness.IsFileExist(mainId);
                if (!isExist)
                {
                    XMessageBox.ShowError("未找到附件!");
                    return;
                }

                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string fileName = this.m_FileAttachBusiness.DownloadFile(mainId, fbd.SelectedPath);

                    if (fileName != string.Empty)
                    {
                        XMessageBox.ShowRemindMessage("下载完成!");
                    }
                    else
                    {
                        XMessageBox.ShowError("下载失败!");
                    }
                }
            }
            else
            {
                XMessageBox.ShowError("请选择要下载附件的记录!");
            }
        }
Beispiel #2
0
        protected virtual bool ValidateDeleteCommon()
        {
            if (this.treeView.SelectedNode == null)
            {
                XMessageBox.ShowError("请选择要删除的节点!");
                return(false);
            }

            XModelBase model = this.treeView.SelectedNode.Tag as XModelBase;

            if (this.m_Business.IsEndNode(model))
            {
                XMessageBox.ShowError("该节点下有子节点,删除前需要先删除子节点!");
                return(false);
            }

            if (this.m_Business.IsUsed(model.ID))
            {
                return(false);
            }

            if (XMessageBox.ShowQuestion("确定要删除选中的记录吗?") == System.Windows.Forms.DialogResult.No)
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 自定义UI校验
        /// </summary>
        /// <returns></returns>
        protected override bool ValidateCustom()
        {
            IList <XModelBase> standFiles = this.grdFiles.DataSource as IList <XModelBase>;

            int maxVersionCount = 0;

            if (standFiles.Count > 0)
            {
                foreach (XStandFilesInfo standFile in standFiles)
                {
                    if (standFile.IsMaxVersion)
                    {
                        maxVersionCount += 1;
                    }
                }
            }

            if (maxVersionCount > 1)
            {
                XMessageBox.ShowError("只能有一个文件集是最新版本!");
                return(false);
            }

            return(true);
        }
Beispiel #4
0
 private void btnExport_Click(object sender, EventArgs e)
 {
     try
     {
         SaveFileDialog sfd = new SaveFileDialog();
         sfd.Filter = "Excel文件(*.xls)|*.xls";
         if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             this.grdExporter.SheetName = this.Text;
             //this.grdData.RootTable.Columns["select"].Visible = false;
             System.IO.Stream stream = new System.IO.FileStream(sfd.FileName, System.IO.FileMode.CreateNew);
             this.grdExporter.Export(stream);
             stream.Close();
             //this.grdData.RootTable.Columns["select"].Visible = true;
             XMessageBox.ShowRemindMessage("导出完成!");
         }
     }
     catch (Exception ex)
     {
         XErrorLogTool.WriteLog(ex.ToString());
         XMessageBox.ShowError("导出失败!");
     }
     finally
     {
         //this.grdData.RootTable.Columns["select"].Visible = true;
     }
 }
Beispiel #5
0
        /// <summary>
        /// 修改明细
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void btnEditDetail_Click(object sender, EventArgs e)
        {
            XButton btnEdit = sender as XButton;
            XGridEx gridEx  = this.FindDetailGridEx(btnEdit.Parent as Janus.Windows.UI.Tab.UITabPage);

            XModelBase currentModel = this.GetCurrentModel(gridEx);

            if (currentModel == null)
            {
                XMessageBox.ShowError("请选择要修改的记录!");
                return;
            }

            frmEditBase frm = this.GetEditDetailForm(sender, currentModel);

            if (frm != null)
            {
                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    gridEx.Refresh();
                }
            }
            else
            {
                XMessageBox.ShowError("未实现修改窗体方法!");
            }
        }
        /// <summary>
        /// 自定义UI校验
        /// </summary>
        /// <returns></returns>
        protected override bool ValidateCustom()
        {
            bool isValidateExist = false;

            string equipmentNo = this.txtEquipmentNo.Text.Trim();

            if (this.m_EditStatus == XEditStatus.AddNew)
            {
                isValidateExist = true;
            }
            else if (this.m_OldEquipmentNo != equipmentNo)
            {
                isValidateExist = true;
            }

            if (isValidateExist)
            {
                if (this.m_EquipmentCheckBusiness.IsEquipmentNoExist(equipmentNo))
                {
                    XMessageBox.ShowError("设备编号已存在!");
                    return(false);
                }
            }

            return(true);
        }
Beispiel #7
0
        /// <summary>
        /// 执行Sql语句
        /// </summary>
        /// <param name="sql"></param>
        /// <returns>执行失败则返回0或者-1</returns>
        public virtual int ExecuteNonQueryByTrans(string sql)
        {
            DbTransaction trans = null;

            try
            {
                if (this.m_Connection.State == ConnectionState.Closed)
                {
                    this.m_Connection.Open();
                }
                trans = this.m_Connection.BeginTransaction();
                DbCommand command = this.GetDbCommand();
                command.Transaction = trans;
                command.CommandText = sql;
                command.Connection  = this.m_Connection;
                int result = command.ExecuteNonQuery();
                trans.Commit();
                return(result);
            }
            catch (Exception ex)
            {
                XMessageBox.ShowError(ex.ToString());
                XErrorLogTool.WriteLog(ex.ToString());
                trans.Rollback();
                return(-1);
            }
            finally
            {
                if (this.m_Connection.State == ConnectionState.Open)
                {
                    this.m_Connection.Close();
                }
            }
        }
Beispiel #8
0
        protected virtual bool ValidateTreeDeleteCommon()
        {
            if (this.treeView.SelectedNode == null)
            {
                XMessageBox.ShowError("请选择要删除的节点!");
                return(false);
            }
            if (this.treeView.SelectedNode.Tag == null)
            {
                return(false);
            }

            XModelBase model = this.treeView.SelectedNode.Tag as XModelBase;

            if (!this.m_TreeBusiness.IsEndModel(model))
            {
                XMessageBox.ShowError("该文件夹下有子文件夹,不能删除!");
                return(false);
            }

            if (XMessageBox.ShowQuestion("确定要删除选中的节点吗?") == System.Windows.Forms.DialogResult.No)
            {
                return(false);
            }
            return(true);
        }
Beispiel #9
0
        private void EditFiles()
        {
            if (this.grdFiles.CurrentRow == null ||
                this.grdFiles.CurrentRow.RowType != Janus.Windows.GridEX.RowType.Record)
            {
                XMessageBox.ShowError("请选择要编辑的记录!");
                return;
            }

            XModelBase currentModel = this.grdFiles.CurrentRow.DataRow as XModelBase;

            XTaskFilesInfo taskFileInfo = currentModel as XTaskFilesInfo;

            if (taskFileInfo.InputUserId != XCommon.LoginUsersInfo.RID)
            {
                XMessageBox.ShowError("不能修改非本人提交的任务文档!");
                return;
            }

            frmTaskFilesEdit frm = new frmTaskFilesEdit(currentModel);

            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.grdFiles.Refresh();
            }
        }
Beispiel #10
0
 /// <summary>
 /// 获得执行结果第一行第一列的值
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public virtual object ExecuteScalar(string sql)
 {
     try
     {
         if (this.m_Connection.State == ConnectionState.Closed)
         {
             this.m_Connection.Open();
         }
         DbCommand command = this.GetDbCommand();
         command.Connection  = this.m_Connection;
         command.CommandText = sql;
         return(command.ExecuteScalar());
     }
     catch (Exception ex)
     {
         XMessageBox.ShowError(ex.Message);
         XErrorLogTool.WriteLog(ex.ToString());
         return(null);
     }
     finally
     {
         if (this.m_Connection != null && this.m_Connection.State == ConnectionState.Closed)
         {
             this.m_Connection.Close();
         }
     }
 }
Beispiel #11
0
        private void AddFiles()
        {
            TreeNode selectedNode = this.tvTask.SelectedNode;

            if (!this.IsChildTaskNode(selectedNode))
            {
                XMessageBox.ShowError("请选择要提交文档的子任务!");
                return;
            }

            IList <XModelBase> gridList = this.grdFiles.DataSource as IList <XModelBase>;

            XTaskInfo taskInfo = selectedNode.Tag as XTaskInfo;

            if (taskInfo.AssignPeople != XCommon.LoginUsersInfo.RID)
            {
                XMessageBox.ShowError("当前登录人不是任务负责人,不能提交文档!");
                return;
            }

            frmTaskFilesEdit frm = new frmTaskFilesEdit(gridList, selectedNode);

            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.grdFiles.DataSource = null;
                this.grdFiles.DataSource = frm.ModelList;
                this.grdFiles.Refresh();
            }
        }
Beispiel #12
0
 /// <summary>
 /// 菜单单击事件
 /// </summary>
 /// <param name="menuInfo"></param>
 /// <param name="e"></param>
 protected virtual void menuFolderTool_MenuClickEvent(XMenuInfo menuInfo, EventArgs e)
 {
     try
     {
         frmBase frm = Assembly.Load(menuInfo.NameSpace).CreateInstance(menuInfo.FullAssembleName) as frmBase;
         if (frm == null)
         {
             XMessageBox.ShowError("该功能未实现或者实现的接口不正确!");
             return;
         }
         if (menuInfo.IsDialogModel)
         {
             frm.StartPosition = FormStartPosition.CenterParent;
             frm.ShowDialog();
         }
         else
         {
             this.ShowTabbedMdi(frm);
         }
     }
     catch (Exception ex)
     {
         XMessageBox.ShowError(ex.Message);
         XErrorLogTool.WriteLog(ex.ToString());
     }
 }
Beispiel #13
0
        void cmdFinishTask_Click(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e)
        {
            TreeNode selectedNode = this.tvTask.SelectedNode;

            if (selectedNode == null)
            {
                XMessageBox.ShowError("请选择要结束的任务!");
                return;
            }

            XTaskInfo taskInfo = selectedNode.Tag as XTaskInfo;

            if (taskInfo == null)
            {
                XMessageBox.ShowError("请选择要结束的任务!");
                return;
            }

            if (XMessageBox.ShowQuestion("确定要结束选中的任务吗?") == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            if (this.m_TaskBusiness.UpdateTaskStatus("结束", taskInfo.ID))
            {
                XMessageBox.ShowRemindMessage("结束任务成功!");
            }
            else
            {
                XMessageBox.ShowError("结束任务失败!");
            }
        }
Beispiel #14
0
        /// <summary>
        /// 校验删除记录
        /// </summary>
        /// <returns></returns>
        protected virtual bool ValidateDelete()
        {
            int selectedCount = 0;

            this.m_SelectedModels.Clear();
            foreach (GridEXRow gridRow in this.grdDetail.GetRows())
            {
                if (gridRow.IsChecked)
                {
                    selectedCount += 1;
                    XModelBase currentModel = gridRow.DataRow as XModelBase;
                    this.m_SelectedModels.Add(currentModel);
                }
            }
            if (selectedCount == 0)
            {
                XMessageBox.ShowError("请选择要删除的记录!");
                return(false);
            }
            if (XMessageBox.ShowQuestion("确定要删除选中的记录吗?") == System.Windows.Forms.DialogResult.No)
            {
                return(false);
            }
            return(true);
        }
Beispiel #15
0
        /// <summary>
        /// 自定义UI校验
        /// </summary>
        /// <returns></returns>
        protected override bool ValidateCustom()
        {
            bool isValidateExist = false;

            string userId = this.txtUserId.ValueMember;

            if (userId != string.Empty)
            {
                if (this.m_EditStatus == XEditStatus.AddNew)
                {
                    isValidateExist = true;
                }
                else if (this.m_EditStatus == XEditStatus.Edit)
                {
                    if (this.m_OldUserId != this.txtUserId.ValueMember)
                    {
                        isValidateExist = true;
                    }
                }

                if (isValidateExist)
                {
                    XStaffInfoBusiness business = this.m_Business as XStaffInfoBusiness;
                    if (business.IsUserIdHaveStaff(userId))
                    {
                        XMessageBox.ShowError("该关联用户已经关联其他人员信息!");
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #16
0
 protected override bool ValidataForm()
 {
     if (this.txtPassword.Text.Trim() != this.txtRepass.Text.Trim())
     {
         XMessageBox.ShowError("两次输入的密码不一致!");
         return(false);
     }
     return(true);
 }
Beispiel #17
0
 protected virtual bool ValidateAddCommon()
 {
     if (this.grdData.CurrentRow == null || this.grdData.CurrentRow.RowType != Janus.Windows.GridEX.RowType.Record)
     {
         XMessageBox.ShowError("请选择要添加明细的主表记录!");
         return(false);
     }
     return(true);
 }
Beispiel #18
0
 /// <summary>
 /// 修改前校验
 /// </summary>
 /// <returns></returns>
 protected virtual bool ValidateBeforeEdit()
 {
     if (this.treeView.SelectedNode == null)
     {
         XMessageBox.ShowError("请选择要修改的节点!");
         return(false);
     }
     return(true);
 }
Beispiel #19
0
        public bool InsertCustom(XModelBase model)
        {
            DbConnection  sqlConn = this.m_DataAccess.Connection;
            DbTransaction trans   = null;

            try
            {
                if (sqlConn.State == ConnectionState.Closed)
                {
                    sqlConn.Open();
                }

                trans = sqlConn.BeginTransaction();

                string sql = this.GetInsertSql(model) + ";";

                XVTaskFilesInfo taskFilesInfo = model as XVTaskFilesInfo;

                //更新任务状态为结束
                sql += "UPDATE Task SET TaskStatus='结束' WHERE RID='" + taskFilesInfo.MainId + "';";

                if (taskFilesInfo.FileFullName != string.Empty)
                {
                    //上传附件
                    DbCommand fileCommand = this.GetFileCommand(taskFilesInfo);
                    fileCommand.Connection  = sqlConn;
                    fileCommand.Transaction = trans;
                    DbDataReader reader = fileCommand.ExecuteReader();
                    reader.Close();
                }

                DbCommand cmd = this.m_DataAccess.GetDbCommand();
                cmd.Connection  = sqlConn;
                cmd.CommandText = sql;
                cmd.Transaction = trans;
                bool isSuccess = cmd.ExecuteNonQuery() > 0;
                trans.Commit();

                return(isSuccess);
            }
            catch (Exception ex)
            {
                XMessageBox.ShowError(ex.Message);
                XErrorLogTool.WriteLog(ex.ToString());
                trans.Rollback();
            }
            finally
            {
                if (sqlConn.State == ConnectionState.Open)
                {
                    sqlConn.Close();
                }
            }

            return(false);
        }
Beispiel #20
0
        /// <summary>
        /// 自定义UI校验
        /// </summary>
        /// <returns></returns>
        protected override bool ValidateCustom()
        {
            if (this.m_EditStatus == XEditStatus.AddNew)
            {
                if (this.txtPassWord.Text.Trim() != this.txtRepass.Text.Trim())
                {
                    XMessageBox.ShowError("两次密码输入的不一致!");
                    return(false);
                }
            }

            bool isValidateExist = false;

            if (this.m_EditStatus == XEditStatus.AddNew)
            {
                isValidateExist = true;
            }
            else if (this.m_EditStatus == XEditStatus.Edit)
            {
                if (this.m_OldUserName != this.txtUserName.Text.Trim())
                {
                    isValidateExist = true;
                }
            }

            if (isValidateExist)
            {
                if (this.m_Business.IsExist(this.txtUserName.Text.Trim()))
                {
                    XMessageBox.ShowError("用户名已存在!");
                    return(false);
                }
            }

            bool isValidateRealNameExist = false;

            if (this.m_EditStatus == XEditStatus.AddNew)
            {
                isValidateRealNameExist = true;
            }
            else if (this.m_EditStatus == XEditStatus.Edit)
            {
                if (this.m_OldRealName != this.txtRealName.Text.Trim())
                {
                    isValidateRealNameExist = true;
                }
            }

            if (isValidateRealNameExist && this.m_UsersBusiness.IsRealNameExist(this.txtRealName.Text.Trim()))
            {
                XMessageBox.ShowError("真实姓名已存在!");
                return(false);
            }

            return(true);
        }
Beispiel #21
0
        protected override bool ValidateEditCustom()
        {
            if (this.m_Business.IsCheck(this.m_CurrentModel))
            {
                XMessageBox.ShowError("要修改的记录已审核,不能修改!");
                return(false);
            }

            return(true);
        }
Beispiel #22
0
        protected virtual bool ValidateImportCommon()
        {
            if (this.grdData.RowCount == 0)
            {
                XMessageBox.ShowError("没有要导入的记录!");
                return(false);
            }

            return(true);
        }
Beispiel #23
0
        public static bool Preview(string fileId)
        {
            string where = " and FileId='" + fileId + "'";

            IList <XModelBase> fileAttachInfos = m_FileAttachBusiness.QueryByWhere(where);

            if (fileAttachInfos.Count == 0)
            {
                XMessageBox.ShowError("未找到附件,无法预览!");
                return(false);
            }

            XFileAttachmentInfo fileInfo = fileAttachInfos[0] as XFileAttachmentInfo;

            string[] imageTypes  = new string[] { ".png", ".jpg", ".jpeg" };
            string[] officeTypes = new string[] { ".doc", ".docx", ".xls", ".xlsx" };

            if (!imageTypes.Contains(fileInfo.AtchType) &&
                !officeTypes.Contains(fileInfo.AtchType))
            {
                XMessageBox.ShowError("不支持预览格式为[" + fileInfo.AtchType + "]的文件!");
                return(false);
            }

            string path     = XCommon.TempPath;
            string fileName = Guid.NewGuid().ToString();

            fileName = m_FileAttachBusiness.DownLoadFile(fileId, path, fileName);

            if (imageTypes.Contains(fileInfo.AtchType))
            {
                //如果是图片
                frmImagePreview frm = new frmImagePreview(fileName);
                frm.ShowDialog();
            }
            else
            {
                frmOfficeFilePreview frm = new frmOfficeFilePreview(fileName);
                frm.ShowDialog();
            }

            if (File.Exists(fileName))
            {
                try
                {
                    File.Delete(fileName);
                }
                catch (Exception ex)
                {
                    XErrorLogTool.WriteLog(ex.ToString());
                }
            }

            return(true);
        }
Beispiel #24
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                XUsersBusiness usersBusiness = new XUsersBusiness();
                //if (usersBusiness.GetServerTime() >= new DateTime(2014, 2, 28))
                //{
                //    XMessageBox.ShowError("出现异常,无法登录!");
                //    return;
                //}

                if (this.ValidateLogin())
                {
                    this.m_UserInfo = this.GetLoginUsersInfo();
                    if (this.m_UserInfo == null)
                    {
                        XMessageBox.ShowError("用户名或者密码错误!");
                        return;
                    }

                    if (this.m_UserInfo.IsUsed == false)
                    {
                        XMessageBox.ShowError("该用户不可用!");
                        return;
                    }

                    XCommon.LoginUsersInfo = this.m_UserInfo.Clone() as XUsersInfo;
                    if (this.m_UserInfo != null)
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        try
                        {
                            this.LoginLog();
                        }
                        catch (Exception ex)
                        {
                            XErrorLogTool.WriteLog(ex.ToString());
                        }
                    }
                    this.RememberLoginUser();
                }
            }
            catch (Exception ex)
            {
                XMessageBox.ShowError(ex.Message);
                XErrorLogTool.WriteLog(ex.ToString());
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #25
0
 private void Preview()
 {
     try
     {
         this.fcWord.Open(m_FileName);
     }
     catch (Exception ex)
     {
         XMessageBox.ShowError(ex.Message);
         XErrorLogTool.WriteLog(ex.ToString());
     }
 }
Beispiel #26
0
 /// <summary>
 /// 公共校验
 /// </summary>
 /// <returns></returns>
 protected virtual bool ValidateCommon()
 {
     if (this.m_EditStatus == XEditStatus.AddNew && this.chkRootNode.Checked == false)
     {
         if (this.treeView.SelectedNode == null)
         {
             XMessageBox.ShowError("请选择父节点!");
             return(false);
         }
     }
     return(true);
 }
Beispiel #27
0
        protected virtual bool ValidateEditDetailCommon()
        {
            if (this.grdDetail.CurrentRow == null || this.grdDetail.CurrentRow.RowType != Janus.Windows.GridEX.RowType.Record)
            {
                XMessageBox.ShowError("请选择要修改的明细记录!");
                return(false);
            }

            m_CurrentDetailModel = this.grdDetail.CurrentRow.DataRow as XModelBase;

            return(true);
        }
Beispiel #28
0
        /// <summary>
        /// 自定义UI校验
        /// </summary>
        /// <returns></returns>
        protected override bool ValidateCustom()
        {
            if (this.m_EditStatus == XEditStatus.AddNew)
            {
                if (this.txtFilePath.Text.Trim() == string.Empty)
                {
                    XMessageBox.ShowError("文档路径不能为空!");
                    return(false);
                }
            }

            return(true);
        }
Beispiel #29
0
 protected virtual bool ValidateEditDetail()
 {
     if (this.grdDetail.CurrentRow != null && this.grdDetail.CurrentRow.RowType == Janus.Windows.GridEX.RowType.Record)
     {
         this.m_CurrentDetailModel = this.grdDetail.CurrentRow.DataRow as XModelBase;
     }
     if (this.m_CurrentDetailModel == null)
     {
         XMessageBox.ShowError("请选择要修改的记录!");
         return(false);
     }
     return(true);
 }
Beispiel #30
0
 private void Preview()
 {
     try
     {
         Image image = Image.FromFile(this.m_FileName);
         this.picFile.BackgroundImage = image;
     }
     catch (Exception ex)
     {
         XMessageBox.ShowError(ex.Message);
         XErrorLogTool.WriteLog(ex.ToString());
     }
 }