Example #1
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();
            }
        }
Example #2
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();
            }
        }
Example #3
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;
        }