Example #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();
            }
        }
Example #2
0
        /// <summary>
        /// ������Ϣ��
        /// </summary>
        /// <param name="functionNo">��Ϣ���</param>
        /// <param name="recordValue">����ֵ</param>
        /// <param name="recordTitle">����</param>
        /// <param name="useEmpId">������id</param>
        /// <param name="acceptEmpId">������id</param>
        public void Send(string functionNo, string recordValue, string recordTitle, int empId, int acceptEmpId)
        {
            //д����Ϣ���б�����
            MBusinessFunctionBB businessFunctionBB = new MBusinessFunctionBB();
            HEemployeeBB userBB = new HEemployeeBB();
            MBusinessData businessData = new MBusinessData();
            MBusinessFunctionData businessFunctionData = new MBusinessFunctionData();

            try
            {
                businessData.functionNo = functionNo;
                businessData.recordValue = recordValue;
                businessData.messageTitle = recordTitle;
                businessData.empId = empId;
                businessData.sendTime = DateTime.Now.ToString();
                businessData.isRead = false;

                //�ж���Ϣ��ִ����
                if (acceptEmpId != 0)
                {
                    businessData.acceptEmp = "p___" + acceptEmpId.ToString();
                }
                else
                {
                    businessFunctionData = businessFunctionBB.GetModel(functionNo);
                    string useEmpId = "";
                    if (businessFunctionData.isUseEmpAccept || businessFunctionData.isUseEmpLeaderAccept)
                    {
                        //ȡ��ԭʼ����������
                        string workTableNm;
                        string recordKeyField;
                        bool keyIsInt = false;
                        DataSet ds = new DataSet();

                        ds = businessFunctionBB.GetVList("functionNo='" + functionNo + "'");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            throw new Exception("�Ҳ�����Ϣ��������¼���޷�������Ϣ��");
                        }
                        DataRow row = ds.Tables[0].Rows[0];

                        workTableNm = Convert.ToString(row["tableNm"]);
                        recordKeyField = Convert.ToString(row["recordKeyField"]);
                        if (row["keyIsInt"] != DBNull.Value)
                        {
                            keyIsInt = Convert.ToBoolean(row["keyIsInt"]);
                        }

                        string strSql = "select " + businessFunctionData.useEmpField + " from " + workTableNm;
                        if (keyIsInt)
                        {
                            strSql += " where " + recordKeyField + "=" + recordValue;
                        }
                        else
                        {
                            strSql += " where " + recordKeyField + "='" + recordValue + "'";
                        }

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

                    if (businessFunctionData.isUseEmpAccept)
                    {
                        businessData.acceptEmp = "p___" + useEmpId;
                    }
                    else if (businessFunctionData.isUseEmpLeaderAccept)
                    {
                        //ȡ��ԭʼ���������˵IJ��Ÿ�����
                        DataSet ds = new DataSet();
                        ds = userBB.GetList("empId=" + useEmpId);
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            throw new Exception("��Ա�����쵼û�����ã��޷�������Ϣ��");
                        }
                        DataRow row = ds.Tables[0].Rows[0];

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

                this.businessBB.AddRecord(businessData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                businessFunctionBB.Dispose();
                userBB.Dispose();
            }
        }