Пример #1
0
        /// <summary>
        /// 创建/发启一个审批流,审批流程改变
        /// </summary>
        /// <param name="FID">厂别</param>
        /// <param name="FILE_POINTER">外键指针</param>
        /// <param name="SOURCE_TYPE">类型</param>
        /// <param name="APPROVAL_ROUTE_PTR">流程指针</param>
        /// <param name="IsSend">true发启,false不发启</param>
        /// <param name="note">审批备注</param>
        /// <param name="UserAd">域帐户(yangwm)</param>
        public static void StartApprovalFlow(int FID, int FILE_POINTER, int SOURCE_TYPE, int APPROVAL_ROUTE_PTR, bool IsSend, string note, string UserAd)
        {
            DBHelper               dbhelper = new DBHelper(FID);
            Approval_Mode_1BLL     bll1     = new Approval_Mode_1BLL(FID);
            Approval_Mode_2BLL     bll2     = new Approval_Mode_2BLL(FID);
            Approval_Mode_3BLL     bll3     = new Approval_Mode_3BLL(FID);
            Approval_Mode_4BLL     bll4     = new Approval_Mode_4BLL(FID);
            Approval_Mode_NoteBLL  notebll  = new Approval_Mode_NoteBLL(FID);
            DATA0498BLL            d498bll  = new DATA0498BLL(FID);
            DATA0499BLL            d499bll  = new DATA0499BLL(FID);
            Approval_Mode_1Info    info1    = new Approval_Mode_1Info();
            Approval_Mode_2Info    info2    = new Approval_Mode_2Info();
            Approval_Mode_3Info    info3    = new Approval_Mode_3Info();
            Approval_Mode_4Info    info4    = new Approval_Mode_4Info();
            IList <DATA0498>       d498list = new List <DATA0498>();
            IList <DATA0499>       d499list = new List <DATA0499>();
            Approval_Mode_NoteInfo noteinfo = new Approval_Mode_NoteInfo();

            int    data0073rkey;
            string sql_data0073 = @"select data0073.rkey from data0073 with(nolock)  
                                   left outer join data0005 with(nolock)  on data0005.rkey=data0073.EMPLOYEE_PTR 
                                   where rtrim(data0005.address_line_1)='KB\";

            sql_data0073 += UserAd + "'";
            object obj = dbhelper.GetSingle(sql_data0073).ToString();

            try
            {
                data0073rkey = int.Parse(obj.ToString());
            }
            catch
            {
                data0073rkey = 0;
            }

            info1.FILE_POINTER      = FILE_POINTER;
            info1.SOURCE_TYPE       = SOURCE_TYPE;
            info1.FROM_STEP_NO      = 0;
            info1.TO_STEP_NO        = 0;
            info1.TRANS_TYPE        = 1;
            info1.TRANS_DESCRIPTION = "生成";
            info1.TRANS_DATE_TIME   = DateTime.Now;
            info1.USER_PTR          = data0073rkey;

            info2.FILE_POINTER       = FILE_POINTER;
            info2.SOURCE_TYPE        = SOURCE_TYPE;
            info2.APPROVAL_ROUTE_PTR = APPROVAL_ROUTE_PTR;
            info2.APPROVAL_STATUS    = IsSend ? 1 : 0;
            info2.APPROVAL_STEP_NO   = 1;
            info2.TOTAL_STEPS        = GetTotalSteps(APPROVAL_ROUTE_PTR, FID);

            d498list = d498bll.FindBySql("APPROVAL_ROUTE_PTR=" + APPROVAL_ROUTE_PTR);

            string delapp4 = @"delete from Approval_Mode_4 where Approval_Mode_4.ROUTE_STEP_PTR in (
select RKEY from Approval_Mode_3 where FILE_POINTER={0} and SOURCE_TYPE={1})";
            string delapp3 = @"delete from Approval_Mode_3 where  FILE_POINTER={0} and SOURCE_TYPE={1}";

            if (note.Length > 0)
            {
                noteinfo.SOURCE_TYPE = 1;
                noteinfo.NOTES       = note;
            }


            using (SqlConnection conn = new SqlConnection(GlobalVal.ConnectionString(GlobalVal.UserInfo.FactoryID)))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandTimeout = 120;
                    try
                    {
                        IList <Approval_Mode_1Info> app1list = bll1.GetModelList("FILE_POINTER=" + FILE_POINTER
                                                                                 + " and SOURCE_TYPE=" + SOURCE_TYPE + " and TRANS_DESCRIPTION = '生成'");
                        if (app1list.Count == 0)
                        {
                            info1.RKEY = bll1.Add(cmd, conn, trans, info1);
                        }
                        if (IsSend)
                        {
                            info2.APPROVAL_STATUS   = 1;
                            info2.APPROVAL_STEP_NO  = 1;
                            info1.TO_STEP_NO        = 1;
                            info1.TRANS_TYPE        = 1;
                            info1.TRANS_DESCRIPTION = "提交审批";
                            bll1.Add(cmd, conn, trans, info1);
                        }
                        List <Approval_Mode_2Info> app2list = bll2.GetModelList("FILE_POINTER=" + FILE_POINTER
                                                                                + " and SOURCE_TYPE=" + SOURCE_TYPE);
                        if (app2list.Count > 0)
                        {
                            if (app2list[0].APPROVAL_ROUTE_PTR != APPROVAL_ROUTE_PTR)
                            {
                                //审批流程改变
                                info1.TO_STEP_NO        = 1;
                                info1.TRANS_TYPE        = 1;
                                info1.TRANS_DESCRIPTION = "审批流程改变";
                                bll1.Add(cmd, conn, trans, info1);
                            }
                            if (IsSend)
                            {
                                app2list[0].APPROVAL_STATUS  = 1;
                                app2list[0].APPROVAL_STEP_NO = 1;
                            }
                            app2list[0].APPROVAL_ROUTE_PTR = APPROVAL_ROUTE_PTR;
                            bll2.Update(cmd, conn, trans, app2list[0]);
                        }
                        else
                        {
                            bll2.Add(cmd, conn, trans, info2);
                        }

                        dbhelper.ExecuteSqlTran(cmd, conn, trans, string.Format(delapp4, FILE_POINTER, SOURCE_TYPE));
                        dbhelper.ExecuteSqlTran(cmd, conn, trans, string.Format(delapp3, FILE_POINTER, SOURCE_TYPE));


                        foreach (DATA0498 d498info in d498list)
                        {
                            info3 = new Approval_Mode_3Info();
                            info3.FILE_POINTER       = FILE_POINTER;
                            info3.SOURCE_TYPE        = SOURCE_TYPE;
                            info3.APPROVAL_STEP_NO   = (int)d498info.APPROVAL_STEP_NO;
                            info3.APPROVAL_STEP_DESC = d498info.APPROVAL_STEP_DESC;
                            info3.RKEY = bll3.Add(cmd, conn, trans, info3);

                            d499list = d499bll.FindBySql("APPROVAL_ROUTE_STEP_PTR=" + d498info.RKEY);
                            foreach (DATA0499 d499info in d499list)
                            {
                                info4.ROUTE_STEP_PTR = info3.RKEY;
                                info4.USER_PTR       = (int)d499info.USER_PTR;
                                bll4.Add(cmd, conn, trans, info4);
                            }
                        }

                        if (note.Length > 0)
                        {
                            noteinfo.FILE_POINTER = info1.RKEY;
                            notebll.Add(cmd, conn, trans, noteinfo);
                        }
                        trans.Commit();
                    }
                    catch (Exception ee)
                    {
                        trans.Rollback();//异常回滚
                        throw ee;
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 审批拒绝 RunApprovalRefuse
        /// </summary>
        /// <param name="FID">厂别</param>
        /// <param name="FILE_POINTER">外键指针</param>
        /// <param name="SOURCE_TYPE">类型</param>
        /// <param name="note">备注</param>
        /// <param name="UserAd">域帐户(yangwm)</param>
        public static void RunApprovalRefuse(int FID, int FILE_POINTER, int SOURCE_TYPE, string note, string UserAd)
        {
            DBHelper               dbhelper = new DBHelper(FID);
            Approval_Mode_1BLL     bll1     = new Approval_Mode_1BLL(FID);
            Approval_Mode_2BLL     bll2     = new Approval_Mode_2BLL(FID);
            Approval_Mode_NoteBLL  notebll  = new Approval_Mode_NoteBLL(FID);
            Approval_Mode_1Info    info1    = new Approval_Mode_1Info();
            Approval_Mode_NoteInfo noteinfo = new Approval_Mode_NoteInfo();
            int    data0073rkey;
            string sql_data0073 = @"select data0073.rkey from data0073 with(nolock)  
                                   left outer join data0005 with(nolock)  on data0005.rkey=data0073.EMPLOYEE_PTR 
                                   where rtrim(data0005.address_line_1)='KB\";

            sql_data0073 += UserAd + "'";
            object obj = dbhelper.GetSingle(sql_data0073).ToString();

            try
            {
                data0073rkey = int.Parse(obj.ToString());
            }
            catch
            {
                data0073rkey = 0;
            }

            List <Approval_Mode_2Info> list2 = bll2.GetModelList("FILE_POINTER=" + FILE_POINTER + " and SOURCE_TYPE=" + SOURCE_TYPE);

            if (list2.Count > 0)
            {
                info1.FILE_POINTER        = FILE_POINTER;
                info1.SOURCE_TYPE         = SOURCE_TYPE;
                info1.FROM_STEP_NO        = list2[0].APPROVAL_STEP_NO;
                info1.TO_STEP_NO          = 0;
                info1.TRANS_TYPE          = 7;
                info1.USER_PTR            = data0073rkey;
                info1.TRANS_DESCRIPTION   = "报废";
                info1.TRANS_DATE_TIME     = DateTime.Now;
                list2[0].APPROVAL_STATUS  = 3;
                list2[0].APPROVAL_STEP_NO = 0;

                if (note.Length > 0)
                {
                    noteinfo.SOURCE_TYPE = 1;
                    noteinfo.NOTES       = note;
                }

                using (SqlConnection conn = new SqlConnection(GlobalVal.ConnectionString(GlobalVal.UserInfo.FactoryID)))
                {
                    conn.Open();
                    using (SqlTransaction trans = conn.BeginTransaction())
                    {
                        SqlCommand cmd = new SqlCommand();
                        cmd.CommandTimeout = 120;
                        try
                        {
                            info1.RKEY = bll1.Add(cmd, conn, trans, info1);
                            bll2.Update(cmd, conn, trans, list2[0]);
                            if (note.Length > 0)
                            {
                                noteinfo.FILE_POINTER = info1.RKEY;
                                notebll.Add(cmd, conn, trans, noteinfo);
                            }
                            trans.Commit();
                        }
                        catch (Exception ee)
                        {
                            trans.Rollback();//异常回滚
                            throw ee;
                        }
                    }
                }
            }
        }