Exemplo n.º 1
0
        /// <summary>
        /// 填充实体信息
        /// </summary>
        protected override void FillModelInfo()
        {
            XVTaskFilesInfo info = this.m_CurrentModel as XVTaskFilesInfo;

            if (this.m_EditStatus == XEditStatus.AddNew || this.m_EditStatus == XEditStatus.AddContinue)
            {
                info.RID    = this.GetNewId();
                info.ID     = info.RID;
                info.MainId = XHelper.GetString(txtChildTaskName.Tag);
            }

            info.FileName       = this.txtFileName.Text;
            info.FileDesc       = this.txtFileDesc.Text;
            info.Remark         = this.txtRemark.Text;
            info.FileFullName   = this.txtFilePath.Text.Trim();
            info.UpdateUserName = XCommon.LoginUsersInfo.RealName;
            info.InputUserName  = XCommon.LoginUsersInfo.RealName;

            info.TaskName         = this.txtChildTaskName.Text;
            info.TaskNo           = this.txtChildTaskNo.Text;
            info.StartDate        = XHelper.GetFormatedDate(this.dtChildTaskStartDate.Value);
            info.PreEndDate       = XHelper.GetFormatedDate(this.dtChildTaskPreEnd.Value);
            info.ParentTaskName   = this.txtMainId.Text;
            info.ParentTaskNo     = this.txtTaskNo.Text;
            info.ParentStartDate  = XHelper.GetFormatedDate(this.dtStartDate.Value);
            info.ParentPreEndDate = XHelper.GetFormatedDate(this.dtPreEndDate.Value);

            base.FillModelInfo();
        }
Exemplo n.º 2
0
        private DbCommand GetFileCommand(XVTaskFilesInfo taskFileInfo)
        {
            string fileDesc = string.Empty;

            string fileName = taskFileInfo.FileFullName;

            FileInfo fi = new FileInfo(fileName);

            double fileSize = 0;

            fileSize = Math.Round(XHelper.GetDouble(fi.Length) / XHelper.GetDouble(1024), 2);

            byte[] bData = XHelper.GetFileBytes(fileName);

            string fileId = taskFileInfo.RID;

            string sql = "DELETE FROM FileAttachment WHERE FileId='" + fileId + "';";

            sql += "INSERT INTO FileAttachment (RID,FileId,AtchName,AtchDesc,AtchType," +
                   "AtchSize,AtchPath,AtchShotGifPath,AtchImag,InputUserId,InputTime)values" +
                   "(@RId,@FileId,@AtchName,@AtchDesc,@AtchType,@AtchSize,@AtchPath,@AtchShotGifPath," +
                   "@AtchImag,@UserId,getdate())";
            DbConnection conn = this.m_DataAccess.Connection;
            DbCommand    cmd  = this.m_DataAccess.GetDbCommand();

            cmd.CommandText = sql;

            DbParameter parameterId = this.m_DataAccess.GetParameter("@RId", Guid.NewGuid().ToString());

            cmd.Parameters.Add(parameterId);
            DbParameter parameterMainId = this.m_DataAccess.GetParameter("@FileId", fileId);

            cmd.Parameters.Add(parameterMainId);
            DbParameter parameterFileName = this.m_DataAccess.GetParameter("@AtchName", fi.Name);

            cmd.Parameters.Add(parameterFileName);
            DbParameter parameterAtchDesc = this.m_DataAccess.GetParameter("@AtchDesc", fileDesc);

            cmd.Parameters.Add(parameterAtchDesc);
            DbParameter parameterAtchType = this.m_DataAccess.GetParameter("@AtchType", fi.Extension);

            cmd.Parameters.Add(parameterAtchType);
            DbParameter parameterAtchSize = this.m_DataAccess.GetParameter("@AtchSize", fileSize);

            cmd.Parameters.Add(parameterAtchSize);
            DbParameter parameterAtchPath = this.m_DataAccess.GetParameter("@AtchPath", fi.FullName);

            cmd.Parameters.Add(parameterAtchPath);
            DbParameter parameterAtchShotGifPath = this.m_DataAccess.GetParameter("@AtchShotGifPath", "");

            cmd.Parameters.Add(parameterAtchShotGifPath);
            DbParameter parameterFile = this.m_DataAccess.GetParameter("@AtchImag", bData);

            cmd.Parameters.Add(parameterFile);
            DbParameter parameterUser = this.m_DataAccess.GetParameter("@UserId", taskFileInfo.UpdateUserId);

            cmd.Parameters.Add(parameterUser);

            return(cmd);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        protected override void FillRowViewInfos(XModelBase model, System.Data.DataRow modelRow)
        {
            XVTaskFilesInfo info = model as XVTaskFilesInfo;

            info.InputUserName  = XHelper.GetString(modelRow["InputUserName"]);
            info.UpdateUserName = XHelper.GetString(modelRow["UpdateUserName"]);

            info.TaskName         = XHelper.GetString(modelRow["TaskName"]);
            info.TaskNo           = XHelper.GetString(modelRow["TaskNo"]);
            info.StartDate        = XHelper.GetString(modelRow["StartDate"]);
            info.PreEndDate       = XHelper.GetString(modelRow["PreEndDate"]);
            info.ParentTaskName   = XHelper.GetString(modelRow["ParentTaskName"]);
            info.ParentTaskNo     = XHelper.GetString(modelRow["ParentTaskNo"]);
            info.ParentStartDate  = XHelper.GetString(modelRow["ParentStartDate"]);
            info.ParentPreEndDate = XHelper.GetString(modelRow["ParentPreEndDate"]);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 设置修改时的默认值
        /// </summary>
        protected override void SetDefaultValue()
        {
            XVTaskFilesInfo info = this.m_CurrentModel as XVTaskFilesInfo;

            //this.txtMainId.Text = info.MainId;
            this.txtFileName.Text = info.FileName;
            this.txtFileDesc.Text = info.FileDesc;
            this.txtRemark.Text   = info.Remark;

            this.txtChildTaskName.Text      = info.TaskName;
            this.txtChildTaskName.Tag       = info.RID;
            this.txtChildTaskNo.Text        = info.TaskNo;
            this.dtChildTaskStartDate.Value = XHelper.GetDateTime(info.StartDate);
            this.dtChildTaskPreEnd.Value    = XHelper.GetDateTime(info.PreEndDate);
            this.txtMainId.Text             = info.ParentTaskName;
            this.txtTaskNo.Text             = info.ParentTaskNo;
            this.dtStartDate.Value          = XHelper.GetDateTime(info.ParentStartDate);
            this.dtPreEndDate.Value         = XHelper.GetDateTime(info.ParentPreEndDate);
        }
Exemplo n.º 6
0
        private void tvTask_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode selectedNode = e.Node;

            XVTaskInfo info = selectedNode.Tag as XVTaskInfo;

            if (m_LastSelctedNode != null)
            {
                m_LastSelctedNode.BackColor = Color.White;
            }
            selectedNode.BackColor = Color.LightBlue;
            m_LastSelctedNode      = selectedNode;

            if (info != null)
            {
                //如果选中的是任务节点
                this.tabTask.SelectedIndex = 0;

                this.txtTaskTypeId.Text   = info.TaskType;
                this.txtTaskName.Text     = info.TaskName;
                this.txtTaskNo.Text       = info.TaskNo;
                this.txtStartPeople.Text  = info.StartPeople;
                this.dtDispatchDate.Value = XHelper.GetDateTime(info.DispatchDate);
                this.txtAssignPeople.Text = info.AssignPeopleName;
                this.dtStartDate.Value    = XHelper.GetDateTime(info.StartDate);
                this.dtPreEndDate.Value   = XHelper.GetDateTime(info.PreEndDate);
                this.txtShortDesc.Text    = info.ShortDesc;
                this.txtRequire.Text      = info.Require;
                this.txtContent.Text      = info.Content;
                this.txtRemark.Text       = info.Remark;

                if (selectedNode.Parent != null)
                {
                    XTaskInfo parentTaskInfo = selectedNode.Parent.Tag as XTaskInfo;
                    this.txtParentTask.Text       = parentTaskInfo.TaskName;
                    this.txtParentTaskNo.Text     = parentTaskInfo.TaskNo;
                    this.dtParentStartDate.Value  = XHelper.GetDateTime(parentTaskInfo.StartDate);
                    this.dtParentPreEndDate.Value = XHelper.GetDateTime(parentTaskInfo.PreEndDate);
                }
                else
                {
                    this.txtParentTask.Text   = string.Empty;
                    this.txtParentTaskNo.Text = string.Empty;
                    //this.dtParentStartDate.Value =
                    //this.dtParentPreEndDate.Value = XHelper.GetDateTime(parentTaskInfo.PreEndDate);
                }

                if (this.IsChildTaskNode(selectedNode))
                {
                    //如果选择的是子任务
                    this.FillFilesGrid(info.RID);
                }
                else
                {
                    //如果是根级节点
                    this.grdFiles.DataSource = this.m_TaskFilesBusiness.GetViewListByRootTaskId(info.RID);
                    this.grdFiles.AutoSizeColumns();
                }

                this.FillTaskAttachGrid(info.RID);
            }
            else
            {
                this.tabTask.SelectedIndex = 1;

                //文件节点
                XVTaskFilesInfo taskFileInfo = selectedNode.Tag as XVTaskFilesInfo;

                this.txtFileName.Text   = taskFileInfo.FileName;
                this.txtFileDesc.Text   = taskFileInfo.FileDesc;
                this.txtFileRemark.Text = taskFileInfo.Remark;
            }
        }