Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// �����ύһ���������������ύ��ָ���Ĺ�����ִ����
        /// </summary>
        /// <param name="functionNo">����</param>
        /// <param name="recordValue">����ֵ</param>
        /// <param name="recordTitle">����</param>
        /// <param name="submitEmpId">�ύ��id</param>
        /// <param name="checkEmp">������ִ����</param>
        /// <returns>�Ƿ��Զ�����</returns>
        public bool Submit(string functionNo, string recordValue, string recordTitle, int submitEmpId, string checkEmp)
        {
            WFunctionBB functionBB = new WFunctionBB();
            try
            {
                //�жϹ������Ƿ��Զ�����
                if (functionBB.IsAutoAudit(functionNo))
                {
                    //���µ���״̬
                    this.SetWorkFlowInfo(functionNo, recordValue, WorkFlowState.WorkAudited,
                        submitEmpId.ToString(), DateTime.Now.ToString());
                    return true;
                }
                else
                {

                    WFunctionStepBB functionStepBB = new WFunctionStepBB();
                    try
                    {
                        this.Submit(functionNo, recordValue, recordTitle, submitEmpId, functionStepBB.GetNextStep(functionNo, 0), 0, checkEmp);
                    }
                    finally
                    {
                        functionStepBB.Dispose();
                    }
                    return false;
                }
            }
            finally
            {
                functionBB.Dispose();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ��ȡ���ݹ�����״̬
        /// </summary>
        /// <param name="workTableNm">���ݱ�</param>
        /// <param name="recordKeyField">�����ֶ�</param>
        /// <param name="keyIsInt">��������</param>
        /// <param name="recordValue">����ֵ</param>
        /// <returns>������״̬</returns>
        public string GetWorkFlowState(string functionNo, string recordValue)
        {
            vWFunctionData vfunctionData = new vWFunctionData();
            WFunctionBB functionBB = new WFunctionBB();
            DataSet ds = new DataSet();
            string ret = "";
            try
            {
                //ȡ����������Ӧ���ݱ���Ϣ
                string workTableNm;
                string recordKeyField;
                string workFlowStateField;
                string workFlowSeqField;
                bool keyIsInt = false;

                vfunctionData = functionBB.GetVModel(functionNo);

                if (vfunctionData == null)
                {
                    throw new Exception("�Ҳ����������������ã��޷�������");
                }

                workTableNm = vfunctionData.workTableNm;
                recordKeyField = vfunctionData.recordKeyField;
                workFlowStateField = vfunctionData.workFlowStateField;
                workFlowSeqField = vfunctionData.workFlowSeqField;
                keyIsInt = vfunctionData.keyIsInt;

                //��ԭʼ����ȡ�ù�����״̬
                string strSql = "select " + workFlowStateField + " from " + workTableNm;
                if (keyIsInt)
                {
                    strSql += " where " + recordKeyField + "=" + recordValue;
                }
                else
                {
                    strSql += " where " + recordKeyField + "='" + recordValue + "'";
                }

                ds = this.commBB.Query(strSql);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("�Ҳ���ԭʼ���ݣ��޷�������");
                }
                ret = ds.Tables[0].Rows[0][0].ToString();
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                functionBB.Dispose();
            }

            return ret;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// �õ��ݹ�����״̬
        /// </summary>
        /// <param name="functionNo">����</param>
        /// <param name="recordValue">����ֵ</param>
        /// <param name="workFlowState">������״̬</param>
        /// <param name="auditEmpId">������</param>
        /// <param name="auditDt">����ʱ��</param>
        public void SetWorkFlowInfo(string functionNo, string recordValue, string workFlowState, string auditEmpId, string auditDt)
        {
            vWFunctionData vfunctionData = new vWFunctionData();
            WFunctionBB functionBB = new WFunctionBB();
            try
            {
                //ȡ����������Ӧ���ݱ���Ϣ
                string workTableNm;
                string recordKeyField;
                string auditEmpIdField;
                string auditDtField;
                string workFlowStateField;
                string workFlowSeqField;
                string auditDegreeField;
                bool keyIsInt = false;

                vfunctionData = functionBB.GetVModel(functionNo);

                if (vfunctionData == null)
                {
                    throw new Exception("�Ҳ����������������ã��޷�������");
                }

                workTableNm = vfunctionData.workTableNm;
                recordKeyField = vfunctionData.recordKeyField;
                auditEmpIdField = vfunctionData.auditEmpIdField;
                auditDtField = vfunctionData.auditDtField;
                workFlowStateField = vfunctionData.workFlowStateField;
                workFlowSeqField = vfunctionData.workFlowSeqField;
                auditDegreeField = vfunctionData.auditDegreeField;
                keyIsInt = vfunctionData.keyIsInt;

                //��ȡԭʼ���ݱ�Ĺ�����״̬����֤Ҫ�����״̬�Ƿ�Ϸ�
                string oldState = this.GetWorkFlowState(functionNo, recordValue);

                switch (workFlowState)
                {
                    //���µ���״̬Ϊ���ύ
                    case WorkFlowState.WorkSubmiting:
                        if (oldState != WorkFlowState.WorkAuditing && oldState != WorkFlowState.WorkAudited)
                        {
                            throw new Exception("ԭʼ����״̬�Ѿ��ı�Ϊ��" + WorkFlowState.GetWorkFlowStateDesc(oldState)
                                + "���޷�����������");
                        }
                        break;
                    //���µ���״̬Ϊ�ύ
                    case WorkFlowState.WorkAuditing:
                        if (oldState != WorkFlowState.WorkSubmiting && oldState != WorkFlowState.WorkUnAudited)
                        {
                            throw new Exception("ԭʼ����״̬�Ѿ��ı�Ϊ��" + WorkFlowState.GetWorkFlowStateDesc(oldState)
                                + "���޷��ύ������");
                        }
                        break;
                    //���µ���״̬Ϊ��׼
                    //�Զ�����״���µ��ݿ���ֱ���ɴ��ύ��Ϊ����׼
                    case WorkFlowState.WorkAudited:
                        if (oldState != WorkFlowState.WorkSubmiting && oldState != WorkFlowState.WorkAuditing)
                        {
                            throw new Exception("ԭʼ����״̬�Ѿ��ı�Ϊ��" + WorkFlowState.GetWorkFlowStateDesc(oldState)
                                + "���޷�����������");
                        }
                        break;
                    //���µ���״̬Ϊδ��׼
                    case WorkFlowState.WorkUnAudited:
                        if (oldState != WorkFlowState.WorkAuditing)
                        {
                            throw new Exception("ԭʼ����״̬�Ѿ��ı�Ϊ��" + WorkFlowState.GetWorkFlowStateDesc(oldState)
                                + "���޷��ύ������");
                        }
                        break;
                    default:
                        break;
                }

                string updateStr = "update " + workTableNm + " set " + workFlowStateField + "='" + workFlowState
                    + "'," + workFlowSeqField + "='" + WorkFlowState.GetWorkFlowStateDesc(workFlowState) + "'";
                if (auditEmpId != "")
                {
                    updateStr += "," + auditEmpIdField + "=" + auditEmpId;
                }
                if (auditDt != "")
                {
                    updateStr += "," + auditDtField + "='" + auditDt + "'";
                }
                //��������������������׼��δ��׼ʱ
                if (auditDegreeField != "" && (workFlowState == WorkFlowState.WorkAudited || workFlowState == WorkFlowState.WorkUnAudited))
                {
                    updateStr += "," + auditDegreeField + "=isnull(" + auditDegreeField + ",0)+1";
                }
                if (keyIsInt)
                {
                    updateStr += " where " + recordKeyField + "=" + recordValue;
                }
                else
                {
                    updateStr += " where " + recordKeyField + "='" + recordValue + "'";
                }

                //���¹�������¼������Ϣ
                this.commBB.ExecuteSql(updateStr);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                functionBB.Dispose();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// ������һ��������
        /// </summary>
        /// <param name="functionNo">����</param>
        /// <param name="recordValue">����ֵ</param>
        /// <param name="recordTitle">����</param>
        /// <param name="applyEmpId">������id</param>
        /// <param name="checkEmp">������ִ����</param>
        /// <returns>�Ƿ��Զ�����</returns>
        public bool ApplyChange(string functionNo, string recordValue, string recordTitle, int applyEmpId, string checkEmp)
        {
            WFunctionBB functionBB = new WFunctionBB();
            try
            {
                //�жϹ������Ƿ��Զ�����
                if (functionBB.IsAutoAudit(functionNo))
                {
                    //���µ���״̬
                    this.SetWorkFlowInfo(functionNo, recordValue, WorkFlowState.WorkSubmiting,
                        applyEmpId.ToString(), DateTime.Now.ToString());
                    return true;
                }
                else
                {
                    //�жϵ�ǰ������������������
                    //�����������û�н�����������ֱ�Ӹ��µ���״̬����ֹ������
                    //����Ѿ����������ͱ����Ϣ����ǰ������
                    SqlTransaction trans = null;
                    try
                    {
                        if (this.transaction == null)
                        {
                            trans = this.connection.BeginTransaction("TransUnSubmit");
                            this.runListBB.Transaction = trans;
                            this.commBB.Transaction = trans;
                        }

                        //ȡ�����һ����������
                        int runNo = this.runListBB.GetLastRunNo(functionNo, recordValue, 0);

                        //ȡ�������������ĵ�ǰ����
                        int stepNo = this.runListBB.GetLastStepNo(functionNo, recordValue, 0, runNo);

                        //�ж���û��������
                        bool isSubmited = this.runListBB.GetIsSubmited(functionNo, recordValue, 0, runNo);

                        if (!isSubmited)
                        {
                            //���µ���״̬
                            this.SetWorkFlowInfo(functionNo, recordValue, WorkFlowState.WorkSubmiting,
                                "", "");
                            //����һ��������������ϢΪ����
                            string strSql = "update WRunList set isEnd=1 from WRunList a inner join WFunctionStep b"
                                + " on a.stepId=b.id where a.functionNo='" + functionNo + "' and a.recordValue='"
                                + recordValue + "' and a.runNo=" + runNo.ToString() + " and b.stepNo="
                                + stepNo.ToString() + " and isApplyChange=0";

                            this.commBB.ExecuteSql(strSql);
                        }
                        else
                        {
                            //��������������������Ӧ������������
                            this.Submit(functionNo, recordValue, recordTitle, applyEmpId, stepNo, 2, checkEmp);
                        }

                        if (this.transaction == null) trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        if (this.transaction == null) trans.Rollback("TransUnSubmit");
                        throw ex;
                    }
                    return false;
                }
            }
            finally
            {
                functionBB.Dispose();
            }
        }