/// <summary>
        ///流程信息插入
        /// </summary>
        /// <param name="model">流程信息</param>
        /// <returns>插入成功与否</returns>
       public static bool InsertFlowInfo(FlowModel model, string StepNo,string StepName,string StepActor)
        {
            if (model == null)
                return false ;
            if (model.FlowNo=="")
            {
                return false;
            }
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            try
            {
                bool succ = false;
                string loginUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID;

                LogInfoModel logModel = InitLogInfo(model.FlowNo);
                logModel.Element = ConstUtil.LOG_PROCESS_INSERT;

                succ = ApprovalFlowSetDBHelper.InsertFlowInfo(model,StepNo,StepName,StepActor);
                if (!succ)
                    logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                else
                    logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                LogDBHelper.InsertLog(logModel);
                return succ;
            }
            catch (Exception ex)
            {
                WriteSystemLog(userInfo, ex);
                return false;
            }





            //try
            //{
            //    StringBuilder sqlflow = new StringBuilder();
            //    sqlflow.AppendLine("INSERT INTO officedba.Flow");
            //    sqlflow.AppendLine("		(CompanyCD      ");
            //    sqlflow.AppendLine("		,DeptID         ");
            //    sqlflow.AppendLine("		,FlowNo         ");
            //    sqlflow.AppendLine("		,FlowName         ");
            //    sqlflow.AppendLine("		,BillTypeFlag         ");
            //    sqlflow.AppendLine("		,BillTypeCode         ");
            //    sqlflow.AppendLine("		,UsedStatus         ");
            //    sqlflow.AppendLine("		,ModifiedDate         ");
            //    sqlflow.AppendLine("		,ModifiedUserID)        ");
            //    sqlflow.AppendLine("VALUES                  ");
            //    sqlflow.AppendLine("		('"+model.CompanyCD+"',     ");
            //    sqlflow.AppendLine("		'" + model.DeptID + "',     ");
            //    sqlflow.AppendLine("		'" + model.FlowNo + "',     ");
            //    sqlflow.AppendLine("		'" + model.FlowName + "',     ");
            //    sqlflow.AppendLine("		'" + model.BillTypeFlag + "',     ");
            //    sqlflow.AppendLine("		'" + model.BillTypeCode + "',     ");
            //    sqlflow.AppendLine("		'" + model.UsedStatus + "'     ");
            //    sqlflow.AppendLine("		,getdate()     ");
            //    sqlflow.AppendLine("		,'" +model.ModifiedUserID+ "' )       ");
            //    #region 流程步骤SQL语句拼写
            //    string[] sql = null;
            //    try
            //    {
            //        #region 工艺明细添加SQL语句
            //        if (!string.IsNullOrEmpty(StepName))
            //        {
            //            int sql_index = 0;
            //            string[] Stepno = StepNo.Split(',');
            //            string[] Stepname = StepName.Split(',');
            //            string[] Stepactor = StepActor.Split(',');
            //            sql = new string[Stepname.Length + 1];

            //            if (Stepname.Length >= 1)
            //            {
            //                for (int i = 0; i < Stepname.Length; i++)
            //                {
            //                    System.Text.StringBuilder cmdsql = new System.Text.StringBuilder();
            //                    cmdsql.AppendLine(" Insert into  officedba.FlowStepActor(CompanyCD,FlowNo,StepNo,StepName,Actor,ModifiedDate,ModifiedUserID )");
            //                    cmdsql.AppendLine(" Values('" + model.CompanyCD + "','" + model.FlowNo + "'," + Stepno[i] + ",'" + Stepname[i].ToString() + "','" + Stepactor[i].ToString() + "','" + System.DateTime.Now + "','" + model.ModifiedUserID + "')");
            //                    sql[sql_index] = cmdsql.ToString();
            //                    sql_index++;
            //                }
            //            }

            //            sql[Stepname.Length] = sqlflow.ToString();
            //        #endregion

            //            if (ApprovalFlowSetDBHelper.InsertFlow(sql))
            //            {
            //                result = true;
            //            }
            //        }
            //        else
            //        {
            //            sql = new string[1];
            //            sql[0] = sqlflow.ToString();
            //            if (ApprovalFlowSetDBHelper.InsertFlow(sql))
            //            {
            //                result = true;
            //            }
            //        }
            //        return result;
            //    }
            //    catch (Exception ex)
            //    {
            //        throw ex;
            //    }
            //    #endregion
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
           
        }
      /// <summary>
      /// 修改流程
      /// </summary>
      /// <param name="model"></param>
      /// <returns></returns>
      public static bool UpdateFlowInfo(FlowModel model)
      {
          //SQL拼写
          StringBuilder sql = new StringBuilder();
          sql.AppendLine("UPDATE officedba.Flow			     ");
          sql.AppendLine("SET                                      ");
          sql.AppendLine("		DeptID = @DeptID,             ");
          sql.AppendLine("		FlowName = @FlowName ,            ");
          sql.AppendLine("		BillTypeFlag = @BillTypeFlag ,            ");
          sql.AppendLine("		BillTypeCode = @BillTypeCode ,            ");
          sql.AppendLine("		ModifiedDate = @ModifiedDate ,            ");
          sql.AppendLine("		ModifiedUserID = @ModifiedUserID                ");
          sql.AppendLine("WHERE                                    ");
          sql.AppendLine("		FlowNo =@FlowNo  AND CompanyCD = @CompanyCD and UsedStatus='0'   ");


          //设置参数
          SqlParameter[] param = new SqlParameter[8];
          param[0] = SqlHelper.GetParameter("@CompanyCD", model.CompanyCD);
          param[1] = SqlHelper.GetParameter("@DeptID", model.DeptID);
          param[2] = SqlHelper.GetParameter("@FlowNo", model.FlowNo);
          param[3] = SqlHelper.GetParameter("@FlowName", model.FlowName);
          param[4] = SqlHelper.GetParameter("@BillTypeFlag", model.BillTypeFlag);
          param[5] = SqlHelper.GetParameter("@BillTypeCode", model.BillTypeCode);
          param[6] = SqlHelper.GetParameter("@ModifiedDate", System.DateTime.Now);
          param[7] = SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID);
          SqlHelper.ExecuteTransSql(sql.ToString(), param);
          return SqlHelper.Result.OprateCount > 0 ? true : false;

      }
       /// <summary>
       /// 修改审批流程
       /// </summary>
       /// <param name="model"></param>
       /// <returns></returns>
       public static bool UpdateFlowInfo(FlowModel model, string StepNo, string StepName, string StepActor)
       {
           if (model == null)
               return false;
           if (model.FlowNo == "")
           {
               return false;
           }
           //try
           //{
           //    ApprovalFlowSetDBHelper.DelFlow(model.CompanyCD, Convert.ToString(model.FlowNo));
           //    ApprovalFlowSetDBHelper.DelFlowstep(model.CompanyCD, Convert.ToString(model.FlowNo));
           //    return ApprovalFlowSetDBHelper.InsertFlowInfo(model, StepNo, StepName, StepActor);
           //}
           //catch (Exception)
           //{
           //    return false;
           //}



           UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
           //登陆日志
           try
           {
               bool succ = false;
               LogInfoModel logModel = InitLogInfo(model.FlowNo);
               logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;
               ApprovalFlowSetDBHelper.DelFlow(model.CompanyCD, Convert.ToString(model.FlowNo));
               ApprovalFlowSetDBHelper.DelFlowstep(model.CompanyCD, Convert.ToString(model.FlowNo));
               succ = ApprovalFlowSetDBHelper.InsertFlowInfo(model, StepNo, StepName, StepActor);
               if (!succ)
                   logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
               else
                   logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
               LogDBHelper.InsertLog(logModel);
               return succ;
           }
           catch (Exception ex)
           {
               WriteSystemLog(userInfo, ex);
               throw;
           }


       }
      public static bool InsertFlowInfo(FlowModel model, string StepNo, string StepName, string StepActor)
      {
          ArrayList listADD = new ArrayList();
          bool result = false;
          try
          {
              #region  增加SQL语句
              StringBuilder sqlflow = new StringBuilder();
              sqlflow.AppendLine("INSERT INTO officedba.Flow");
              sqlflow.AppendLine("		(CompanyCD      ");
              sqlflow.AppendLine("		,DeptID         ");
              sqlflow.AppendLine("		,FlowNo         ");
              sqlflow.AppendLine("		,FlowName         ");
              sqlflow.AppendLine("		,BillTypeFlag         ");
              sqlflow.AppendLine("		,BillTypeCode         ");
              sqlflow.AppendLine("		,UsedStatus         ");
              sqlflow.AppendLine("		,IsMobileNotice     ");
              sqlflow.AppendLine("		,ModifiedDate         ");
              sqlflow.AppendLine("		,ModifiedUserID)        ");
              sqlflow.AppendLine("VALUES                  ");
              sqlflow.AppendLine("		(@CompanyCD,     ");
              sqlflow.AppendLine("		@DeptID ,     ");
              sqlflow.AppendLine("		@FlowNo ,     ");
              sqlflow.AppendLine("		@FlowName ,     ");
              sqlflow.AppendLine("		@BillTypeFlag,     ");
              sqlflow.AppendLine("		@BillTypeCode,     ");
              sqlflow.AppendLine("		@UsedStatus,     ");
              sqlflow.AppendLine("		@IsMobileNotice     ");
              sqlflow.AppendLine("		,@ModifiedDate     ");
              sqlflow.AppendLine("		,@ModifiedUserID)       ");
              SqlCommand comm = new SqlCommand();
              comm.CommandText = sqlflow.ToString();
              comm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
              comm.Parameters.Add(SqlHelper.GetParameter("@DeptID", model.DeptID));
              comm.Parameters.Add(SqlHelper.GetParameter("@FlowNo", model.FlowNo));
              comm.Parameters.Add(SqlHelper.GetParameter("@FlowName", model.FlowName));
              comm.Parameters.Add(SqlHelper.GetParameter("@BillTypeFlag", model.BillTypeFlag));
              comm.Parameters.Add(SqlHelper.GetParameter("@BillTypeCode", model.BillTypeCode));
              comm.Parameters.Add(SqlHelper.GetParameter("@UsedStatus", model.UsedStatus));
              comm.Parameters.Add(SqlHelper.GetParameter("@IsMobileNotice", model.IsMobileNotice));
              comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
              comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
              listADD.Add(comm);
              #endregion

              #region 流程步骤添加SQL语句
              if (!String.IsNullOrEmpty(StepNo) && !String.IsNullOrEmpty(StepName) && !String.IsNullOrEmpty(StepActor))
              {
                  string[] dStepNo = StepNo.Split(',');
                  string[] dStepName = StepName.Split(',');
                  string[] dStepActor = StepActor.Split(',');
                  //页面上这些字段都是必填,数组的长度必须是相同的
                  if (dStepNo.Length >= 1)
                  {
                      for (int i = 0; i < dStepNo.Length; i++)
                      {
                          System.Text.StringBuilder cmdsql = new System.Text.StringBuilder();
                          cmdsql.AppendLine("INSERT INTO officedba.FlowStepActor");
                          cmdsql.AppendLine("           (CompanyCD");
                          cmdsql.AppendLine("           ,FlowNo");
                          cmdsql.AppendLine("           ,StepNo");
                          cmdsql.AppendLine("           ,StepName");
                          cmdsql.AppendLine("           ,Actor");
                          cmdsql.AppendLine("           ,ModifiedDate");
                          cmdsql.AppendLine("           ,ModifiedUserID)");
                          cmdsql.AppendLine("     VALUES");
                          cmdsql.AppendLine("           (@CompanyCD");
                          cmdsql.AppendLine("           ,@FlowNo");
                          cmdsql.AppendLine("           ,@StepNo");
                          cmdsql.AppendLine("           ,@StepName");
                          cmdsql.AppendLine("           ,@Actor");
                          cmdsql.AppendLine("           ,@ModifiedDate");
                          cmdsql.AppendLine("           ,@ModifiedUserID)");
                          SqlCommand comms = new SqlCommand();
                          comms.CommandText = cmdsql.ToString();
                          comms.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                          comms.Parameters.Add(SqlHelper.GetParameter("@FlowNo", model.FlowNo));
                          if (dStepNo[i].ToString().Length > 0)
                          {
                              if (!string.IsNullOrEmpty(dStepNo[i].ToString().Trim()))
                              {
                                  comms.Parameters.Add(SqlHelper.GetParameter("@StepNo", dStepNo[i].ToString()));
                              }
                          }
                          if (dStepName[i].ToString().Length > 0)
                          {
                              if (!string.IsNullOrEmpty(dStepName[i].ToString().Trim()))
                              {
                                  comms.Parameters.Add(SqlHelper.GetParameter("@StepName", dStepName[i].ToString()));
                              }
                          }
                          if (dStepActor[i].ToString().Length > 0)
                          {
                              if (!string.IsNullOrEmpty(dStepActor[i].ToString().Trim()))
                              {
                                  comms.Parameters.Add(SqlHelper.GetParameter("@Actor", dStepActor[i].ToString()));
                              }
                          }
                          comms.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
                          comms.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));

                          listADD.Add(comms);
                      }
                  }
              }
              #endregion
              if (SqlHelper.ExecuteTransWithArrayList(listADD))
              {
                  result = true;
              }
              return result;
          }

          catch (Exception ex)
          {
              throw ex;
          }


      }