示例#1
0
        /// <summary>
        /// �ύһ��������
        /// </summary>
        /// <param name="functionNo">����</param>
        /// <param name="recordValue">����ֵ</param>
        /// <param name="recordTitle">����</param>
        /// <param name="submitEmpId">�ύ��id</param>
        /// <param name="stepNo">��ǰ������</param>
        /// <param name="type">0:��һ���ύ������1���Զ���ת��2:���</param>
        /// <param name="checkEmp">������ִ����</param>
        public void Submit(string functionNo, string recordValue, string recordTitle, int submitEmpId, int stepNo, int type, string checkEmp)
        {
            //�������״��ύ����ʱ���ȷ��͹�������Ϣ���ù����������µ�һ�����赱��
            //д�빤�����б�����
            vWFunctionData vfunctionData = new vWFunctionData();
            WFunctionBB functionBB = new WFunctionBB();
            HEemployeeBB userBB = new HEemployeeBB();
            WFunctionStepBB functionStepBB = new WFunctionStepBB();

            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSubmit");
                    this.runListBB.Transaction = trans;
                    this.commBB.Transaction = trans;
                }

                //ȡ�øù�����������ǰ�������������������
                //ѭ�����뵽��������¼��
                DataSet ds = new DataSet();
                ds = functionStepBB.GetStepList(functionNo, stepNo);

                //ȡ�ù���������������Ϣ
                vfunctionData = functionBB.GetVModel(functionNo);

                int runNo;
                //�Զ���תʱ����ȡ�������������
                if (type == 1)
                {
                    runNo = this.runListBB.GetLastRunNo(functionNo, recordValue, 0);
                }
                else
                {
                    runNo = this.runListBB.GetNewRunNo(functionNo, recordValue);
                }

                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        DataRow row = ds.Tables[0].Rows[i];
                        //ȡ��ԭʼ����������
                        string workTableNm;
                        string recordKeyField;
                        bool keyIsInt = false;
                        string condition = "";

                        workTableNm = vfunctionData.workTableNm;
                        recordKeyField = vfunctionData.recordKeyField;
                        keyIsInt = vfunctionData.keyIsInt;
                        condition = row["condition"].ToString();

                        //�жϵ�ǰ�������������������������Ƿ�����
                        string strSql = "select 1 from " + workTableNm;
                        if (keyIsInt)
                        {
                            strSql += " where " + recordKeyField + "=" + recordValue;
                        }
                        else
                        {
                            strSql += " where " + recordKeyField + "='" + recordValue + "'";
                        }
                        strSql += condition;
                        DataSet cds = new DataSet();
                        cds = this.commBB.Query(strSql);
                        if (cds.Tables[0].Rows.Count == 0)
                        {
                            continue;
                        }

                        WRunListData runListData = new WRunListData();

                        //д�빤������¼��
                        runListData.functionNo = functionNo;
                        runListData.runNo = runNo;
                        runListData.stepId = Convert.ToInt32(row["id"]);
                        runListData.isApplyChange = (type == 2 ? true : false);

                        if (checkEmp != "")
                        {
                            runListData.doEmp = checkEmp;
                        }
                        else
                        {
                            //ȡ��ÿһ����Ĺ�����ִ����
                            string useEmpId = "";

                            bool isUseEmpDo = false;
                            bool isUseEmpLeaderDo = false;
                            string doEmp;

                            if (row["isUseEmpDo"] != DBNull.Value)
                            {
                                isUseEmpDo = Convert.ToBoolean(row["isUseEmpDo"]);
                            }

                            if (row["isUseEmpLeaderDo"] != DBNull.Value)
                            {
                                isUseEmpLeaderDo = Convert.ToBoolean(row["isUseEmpLeaderDo"]);
                            }

                            doEmp = row["doEmp"].ToString();

                            //����ɼ�¼Я���߻��¼Я���ߵIJ��Ÿ�������������ȡ����¼Я����
                            if (isUseEmpDo || isUseEmpLeaderDo)
                            {
                                strSql = "select " + vfunctionData.useEmpField + " from " + workTableNm;
                                if (keyIsInt)
                                {
                                    strSql += " where " + recordKeyField + "=" + recordValue;
                                }
                                else
                                {
                                    strSql += " where " + recordKeyField + "='" + recordValue + "'";
                                }

                                DataSet dds = new DataSet();
                                dds = this.commBB.Query(strSql);
                                if (dds.Tables[0].Rows.Count == 0)
                                {
                                    throw new Exception("�������������ò���ȷ���޷�������");
                                }
                                useEmpId = Convert.ToString(dds.Tables[0].Rows[0][0]);
                            }

                            //����Ǽ�¼Я��������
                            if (isUseEmpDo)
                            {
                                runListData.doEmp += "p___" + useEmpId;
                            }
                            //����Ǽ�¼Я���ߵIJ��Ÿ���������
                            else if (isUseEmpLeaderDo)
                            {
                                //ȡ��ԭʼ���������˵IJ��Ÿ�����
                                DataSet dds = new DataSet();
                                dds = userBB.GetVList("empId=" + useEmpId);
                                if (dds.Tables[0].Rows.Count == 0)
                                {
                                    throw new Exception("��Ա�����쵼û�����ã��޷�������");
                                }

                                DataRow drow = dds.Tables[0].Rows[0];

                                //����н�ɫ���壬���ɾ��иý�ɫ�IJ��Ÿ����˽�������
                                if (doEmp != "")
                                {
                                    runListData.doEmp += doEmp.Replace("R_", "R_" + drow["nowDepartId"].ToString());
                                }
                                else
                                {
                                    runListData.doEmp += "p___" + drow["departLeader"].ToString();
                                }
                            }
                            //������ɫ����
                            else
                            {
                                runListData.doEmp += doEmp;
                            }
                        }

                        runListData.recordValue = recordValue;
                        runListData.recordTitle = recordTitle;
                        runListData.empId = submitEmpId;
                        runListData.creattime = DateTime.Now.ToString();
                        runListData.isRead = false;
                        runListData.isEnd = false;
                        runListData.workFlowState = WorkFlowState.WorkAuditing;

                        this.runListBB.AddRecord(runListData);
                    }
                    if (type == 0)
                    {
                        //����ԭʼ����״̬
                        this.SetWorkFlowState(functionNo, recordValue, WorkFlowState.WorkAuditing);
                    }
                }

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransSubmit");
                throw ex;
            }
            finally
            {
                userBB.Dispose();
                functionBB.Dispose();
                functionStepBB.Dispose();
            }
        }
示例#2
0
        /// <summary>
        /// ��������������
        /// </summary>
        /// <param name="runId">��������¼Id</param>
        /// <param name="auditEmpId">������</param>
        public void UnAgreeChange(int runId, int auditEmpId)
        {
            //���¹�������Ϣ״̬
            //����ͬ���蹤������ϢΪ����
            WRunListData model = new WRunListData();
            vWRunListData vmodel = new vWRunListData();
            SqlTransaction trans = null;

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransUnAgreeChange");
                    this.runListBB.Transaction = trans;
                    this.commBB.Transaction = trans;
                }

                //���¹�������¼״̬
                model = this.runListBB.GetModel(runId);
                vmodel = this.runListBB.GetVModel(runId);

                if (model.workFlowState != WorkFlowState.WorkAuditing || model.isEnd)
                {
                    throw new Exception("���������Ѿ��������޷�������");
                }

                model.auditEmpId = auditEmpId;
                model.auditDt = DateTime.Now.ToString();
                model.workFlowState = WorkFlowState.WorkUnAudited;
                model.workFlowSeq = WorkFlowState.GetWorkFlowStateDesc(WorkFlowState.WorkUnAudited);
                model.isEnd = true;
                this.runListBB.ModifyRecord(model);

                //����ͬ���蹤������ϢΪ����
                string strSql = "update WRunList set isEnd=1 from WRunList a inner join WFunctionStep b"
                    + " on a.stepId=b.id where a.functionNo='" + vmodel.functionNo + "' and a.recordValue='"
                    + vmodel.recordValue + "' and a.runNo=" + vmodel.runNo.ToString() + " and b.stepNo="
                    + vmodel.stepNo + " and isApplyChange=1";
                this.commBB.ExecuteSql(strSql);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransUnAgreeChange");
                throw ex;
            }
        }
示例#3
0
        /// <summary>
        /// ���¹�������¼�����������
        /// </summary>
        /// <param name="runId">��������¼Id</param>
        /// <param name="auditMark">�������</param>
        /// <param name="fileId">����</param>
        public void SetAuditMark(int runId, string auditMark, string fileId)
        {
            WRunListData model = new WRunListData();
            SqlTransaction trans = null;

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSetAuditMark");
                    this.runListBB.Transaction = trans;
                    this.commBB.Transaction = trans;
                }

                //���¹�������ע
                model = this.runListBB.GetModel(runId);
                model.auditMark = auditMark;
                model.fileId = fileId;
                this.runListBB.ModifyRecord(model);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransSetAuditMark");
                throw ex;
            }
        }
示例#4
0
 /// <summary>
 /// ���¹������Ѷ�״̬
 /// </summary>
 /// <param name="runId">��������¼Id</param>
 public void SetReaded(int runId)
 {
     WRunListData model = new WRunListData();
     //���¹�������¼״̬
     model = this.runListBB.GetModel(runId);
     model.isRead = true;
     this.runListBB.ModifyRecord(model);
 }
示例#5
0
 /// <summary>
 /// ��ֹ������
 /// </summary>
 /// <param name="runId">��������¼Id</param>
 public void EndRun(int runId)
 {
     WRunListBB runListBB = new WRunListBB();
     WRunListData model = new WRunListData();
     try
     {
         //���¹�������¼״̬
         model = this.runListBB.GetModel(runId);
         model.isEnd = true;
         runListBB.ModifyRecord(model);
     }
     finally
     {
         runListBB.Dispose();
     }
 }
示例#6
0
        /// <summary>
        /// ������������׼
        /// </summary>
        /// <param name="runId">��������¼Id</param>
        /// <param name="auditEmpId">������</param>
        /// <returns>������������־</returns>
        public bool Agree(int runId, int auditEmpId)
        {
            //������������׼ʱ�����¹�������Ϣ״̬
            //�����������������ȫ���������ж��������һ�����������һ���蹤����
            //��������������ɣ�����ԭʼ����״̬
            bool ret = false;
            WRunListData model = new WRunListData();
            vWRunListData vmodel = new vWRunListData();
            WFunctionStepBB functionStepBB = new WFunctionStepBB();

            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAgree");
                    this.runListBB.Transaction = trans;
                    this.commBB.Transaction = trans;
                }

                //���¹�������¼״̬
                model = this.runListBB.GetModel(runId);
                vmodel = this.runListBB.GetVModel(runId);

                if (model.workFlowState != WorkFlowState.WorkAuditing || model.isEnd)
                {
                    throw new Exception("ԭʼ����״̬�Ѿ��ı���������Ѿ��������޷�������");
                }

                model.auditEmpId = auditEmpId;
                model.auditDt = DateTime.Now.ToString();
                model.workFlowState = WorkFlowState.WorkAudited;
                model.workFlowSeq = WorkFlowState.GetWorkFlowStateDesc(WorkFlowState.WorkAudited);
                model.isEnd = true;
                this.runListBB.ModifyRecord(model);

                //�жϱ����蹤�����Ƿ���ȫ������
                DataSet ds = new DataSet();
                ds = this.runListBB.GetVList("functionNo='" + vmodel.functionNo + "' and recordValue='"
                    + vmodel.recordValue + "' and runNo=" + vmodel.runNo.ToString() + " and stepNo="
                    + vmodel.stepNo.ToString() + " and isApplyChange=0 and isEnd=0");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    //�ж��Ƿ�����һ����������
                    ds.Clear();
                    ds = functionStepBB.GetNextStepList(vmodel.functionNo, vmodel.stepNo);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        //���͹���������һ����
                        this.Submit(vmodel.functionNo, vmodel.recordValue, vmodel.recordTitle, vmodel.empId,
                            functionStepBB.GetNextStep(vmodel.functionNo, vmodel.stepNo), 1, "");
                    }
                    else
                    {
                        //���µ���״̬
                        this.SetWorkFlowInfo(vmodel.functionNo, vmodel.recordValue, WorkFlowState.WorkAudited,
                            auditEmpId.ToString(), DateTime.Now.ToString());
                        ret = true;
                    }
                }

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAgree");
                throw ex;
            }
            finally
            {
                functionStepBB.Dispose();
            }
            return ret;
        }
示例#7
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(WRunListData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into WRunList(");
            strSql.Append("functionNo,runNo,stepId,isApplyChange,empId,recordValue,recordTitle,doEmp,creattime,isRead,readTime,auditEmpId,auditDt,workFlowState,workFlowSeq,auditMark,isEnd,fileId)");
            strSql.Append(" values (");
            strSql.Append("@functionNo,@runNo,@stepId,@isApplyChange,@empId,@recordValue,@recordTitle,@doEmp,@creattime,@isRead,@readTime,@auditEmpId,@auditDt,@workFlowState,@workFlowSeq,@auditMark,@isEnd,@fileId)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@functionNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@runNo", SqlDbType.Int),
                    new SqlParameter("@stepId", SqlDbType.Int),
                    new SqlParameter("@isApplyChange", SqlDbType.Bit),
                    new SqlParameter("@empId", SqlDbType.Int),
                    new SqlParameter("@recordValue", SqlDbType.NVarChar,50),
                    new SqlParameter("@recordTitle", SqlDbType.NVarChar,100),
                    new SqlParameter("@doEmp", SqlDbType.NVarChar,200),
                    new SqlParameter("@creattime", SqlDbType.DateTime),
                    new SqlParameter("@isRead", SqlDbType.Bit),
                    new SqlParameter("@readTime", SqlDbType.DateTime),
                    new SqlParameter("@auditEmpId", SqlDbType.Int),
                    new SqlParameter("@auditDt", SqlDbType.DateTime),
                    new SqlParameter("@workFlowState", SqlDbType.NVarChar,2),
                    new SqlParameter("@workFlowSeq", SqlDbType.NVarChar,20),
                    new SqlParameter("@auditMark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isEnd", SqlDbType.Bit),
                    new SqlParameter("@fileId", SqlDbType.NVarChar,100)
                };
            parameters[0].Value = model.functionNo;
            parameters[1].Value = model.runNo;
            parameters[2].Value = model.stepId;
            parameters[3].Value = model.isApplyChange;
            parameters[4].Value = model.empId;
            parameters[5].Value = model.recordValue;
            parameters[6].Value = model.recordTitle;
            parameters[7].Value = model.doEmp;
            parameters[8].Value = model.creattime == string.Empty ? null : model.creattime;
            parameters[9].Value = model.isRead;
            parameters[10].Value = model.readTime == string.Empty ? null : model.readTime;
            parameters[11].Value = model.auditEmpId;
            parameters[12].Value = model.auditDt == string.Empty ? null : model.auditDt;
            parameters[13].Value = model.workFlowState;
            parameters[14].Value = model.workFlowSeq;
            parameters[15].Value = model.auditMark;
            parameters[16].Value = model.isEnd;
            parameters[17].Value = model.fileId;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
示例#8
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(WRunListData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update WRunList set ");
            strSql.Append("functionNo=@functionNo,");
            strSql.Append("runNo=@runNo,");
            strSql.Append("stepId=@stepId,");
            strSql.Append("isApplyChange=@isApplyChange,");
            strSql.Append("empId=@empId,");
            strSql.Append("recordValue=@recordValue,");
            strSql.Append("recordTitle=@recordTitle,");
            strSql.Append("doEmp=@doEmp,");
            strSql.Append("creattime=@creattime,");
            strSql.Append("isRead=@isRead,");
            strSql.Append("readTime=@readTime,");
            strSql.Append("auditEmpId=@auditEmpId,");
            strSql.Append("auditDt=@auditDt,");
            strSql.Append("workFlowState=@workFlowState,");
            strSql.Append("workFlowSeq=@workFlowSeq,");
            strSql.Append("auditMark=@auditMark,");
            strSql.Append("isEnd=@isEnd,");
            strSql.Append("fileId=@fileId");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@functionNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@runNo", SqlDbType.Int),
                    new SqlParameter("@stepId", SqlDbType.Int),
                    new SqlParameter("@isApplyChange", SqlDbType.Bit),
                    new SqlParameter("@empId", SqlDbType.Int),
                    new SqlParameter("@recordValue", SqlDbType.NVarChar,50),
                    new SqlParameter("@recordTitle", SqlDbType.NVarChar,100),
                    new SqlParameter("@doEmp", SqlDbType.NVarChar,200),
                    new SqlParameter("@creattime", SqlDbType.DateTime),
                    new SqlParameter("@isRead", SqlDbType.Bit),
                    new SqlParameter("@readTime", SqlDbType.DateTime),
                    new SqlParameter("@auditEmpId", SqlDbType.Int),
                    new SqlParameter("@auditDt", SqlDbType.DateTime),
                    new SqlParameter("@workFlowState", SqlDbType.NVarChar,2),
                    new SqlParameter("@workFlowSeq", SqlDbType.NVarChar,20),
                    new SqlParameter("@auditMark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isEnd", SqlDbType.Bit),
                    new SqlParameter("@fileId", SqlDbType.NVarChar,100)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.functionNo;
            parameters[2].Value = model.runNo;
            parameters[3].Value = model.stepId;
            parameters[4].Value = model.isApplyChange;
            parameters[5].Value = model.empId;
            parameters[6].Value = model.recordValue;
            parameters[7].Value = model.recordTitle;
            parameters[8].Value = model.doEmp;
            parameters[9].Value = model.creattime == string.Empty ? null : model.creattime;
            parameters[10].Value = model.isRead;
            parameters[11].Value = model.readTime == string.Empty ? null : model.readTime;
            parameters[12].Value = model.auditEmpId;
            parameters[13].Value = model.auditDt == string.Empty ? null : model.auditDt;
            parameters[14].Value = model.workFlowState;
            parameters[15].Value = model.workFlowSeq;
            parameters[16].Value = model.auditMark;
            parameters[17].Value = model.isEnd;
            parameters[18].Value = model.fileId;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
示例#9
0
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="id">����ֵ</param>
        /// <returns>model</returns>
        public WRunListData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from WRunList");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            WRunListData model = new WRunListData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["functionNo"] != DBNull.Value)
                {
                    model.functionNo = Convert.ToString(row["functionNo"]);
                }
                if (row["runNo"] != DBNull.Value)
                {
                    model.runNo = Convert.ToInt32(row["runNo"]);
                }
                if (row["stepId"] != DBNull.Value)
                {
                    model.stepId = Convert.ToInt32(row["stepId"]);
                }
                if (row["isApplyChange"] != DBNull.Value)
                {
                    model.isApplyChange = Convert.ToBoolean(row["isApplyChange"]);
                }
                if (row["empId"] != DBNull.Value)
                {
                    model.empId = Convert.ToInt32(row["empId"]);
                }
                if (row["recordValue"] != DBNull.Value)
                {
                    model.recordValue = Convert.ToString(row["recordValue"]);
                }
                if (row["recordTitle"] != DBNull.Value)
                {
                    model.recordTitle = Convert.ToString(row["recordTitle"]);
                }
                if (row["doEmp"] != DBNull.Value)
                {
                    model.doEmp = Convert.ToString(row["doEmp"]);
                }
                if (row["creattime"] != DBNull.Value)
                {
                    model.creattime = Convert.ToString(row["creattime"]);
                }
                if (row["isRead"] != DBNull.Value)
                {
                    model.isRead = Convert.ToBoolean(row["isRead"]);
                }
                if (row["readTime"] != DBNull.Value)
                {
                    model.readTime = Convert.ToString(row["readTime"]);
                }
                if (row["auditEmpId"] != DBNull.Value)
                {
                    model.auditEmpId = Convert.ToInt32(row["auditEmpId"]);
                }
                if (row["auditDt"] != DBNull.Value)
                {
                    model.auditDt = Convert.ToString(row["auditDt"]);
                }
                if (row["workFlowState"] != DBNull.Value)
                {
                    model.workFlowState = Convert.ToString(row["workFlowState"]);
                }
                if (row["workFlowSeq"] != DBNull.Value)
                {
                    model.workFlowSeq = Convert.ToString(row["workFlowSeq"]);
                }
                if (row["auditMark"] != DBNull.Value)
                {
                    model.auditMark = Convert.ToString(row["auditMark"]);
                }
                if (row["isEnd"] != DBNull.Value)
                {
                    model.isEnd = Convert.ToBoolean(row["isEnd"]);
                }
                if (row["fileId"] != DBNull.Value)
                {
                    model.fileId = Convert.ToString(row["fileId"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }