コード例 #1
0
ファイル: GG30ColRule.aspx.cs プロジェクト: pcstx/OA
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string[] RuleDetail = GetRuleDetail();
            try
            {
                DbHelper.GetInstance().ExecSqlText(string.Format(" select {0} from Workflow_FormDetail where RequestID=0", RuleDetail[0]));
            }
            catch
            {
                ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "add", "alert('赋值表达式不正确,无法添加');", true);
                return;
            }

            Workflow_FormDetailRuleEntity _FormDetailRuleEntity = new Workflow_FormDetailRuleEntity();
            _FormDetailRuleEntity.FormID = DNTRequest.GetInt("fid", 0);
            _FormDetailRuleEntity.GroupID = DNTRequest.GetInt("gid", 0);
            _FormDetailRuleEntity.RuleType = 2;
            _FormDetailRuleEntity.FiledIDTo = Convert.ToInt32(ddlFieldIDTo.SelectedValue);
            _FormDetailRuleEntity.RuleDetail = RuleDetail[0];
            DataTable dtComputeRoute = (DataTable)ViewState["dtComputeRoute"];
            DbHelper.GetInstance().AddWorkflow_FormDetailRule(_FormDetailRuleEntity, dtComputeRoute);
            dtComputeRoute.Rows.Clear();
            lblExpression.Text = "";
            BindGridView();
            System.Web.UI.ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "ButtonHideScript", strButtonHideScript, false);
        }
コード例 #2
0
ファイル: DbHelperWorkflow.cs プロジェクト: pcstx/OA
        /// <summary>
        /// 新增信息
        /// </summary>
        /// <param name="_Workflow_FormDetailRuleEntity"></param>
        /// <param name="dtComputeRoute"></param>
        /// <returns>返回string "-1"表示该已经存在,否则成功 </returns>
        public string AddWorkflow_FormDetailRule(Workflow_FormDetailRuleEntity _Workflow_FormDetailRuleEntity, DataTable dtComputeRoute)
        {
            //判断该记录是否已经存在

            DbParameter[] prams = {
                                       MakeInParam("@FormID",(DbType)SqlDbType.Int,4,_Workflow_FormDetailRuleEntity.FormID ),
                                       MakeInParam("@GroupID",(DbType)SqlDbType.Int,4,_Workflow_FormDetailRuleEntity.GroupID ),
                                       MakeInParam("@FieldIDTo",(DbType)SqlDbType.Int,4,_Workflow_FormDetailRuleEntity.FiledIDTo ),
                                   };
            string sql = " select * from [dbo].[Workflow_FormDetailRule] where FormID=@FormID and GroupID=@GroupID and FieldIDTo=@FieldIDTo ";
            if (ExecuteDataset(CommandType.Text, sql, prams).Tables[0].Rows.Count > 0)
            {
                return "-1";//该记录已经存在

            }
            else
            {
                DbParameter[] pramsInsert = {
                                       MakeInParam("@FormID",(DbType)SqlDbType.Int,4,_Workflow_FormDetailRuleEntity.FormID ),
                                       MakeInParam("@GroupID",(DbType)SqlDbType.Int,4,_Workflow_FormDetailRuleEntity.GroupID ),
                                       MakeInParam("@FieldIDTo",(DbType)SqlDbType.Int,4,_Workflow_FormDetailRuleEntity.FiledIDTo ),
                                       MakeInParam("@RuleDetail",(DbType)SqlDbType.VarChar,2000,_Workflow_FormDetailRuleEntity.RuleDetail ),
                                       MakeInParam("@RuleType",(DbType)SqlDbType.Int,4,_Workflow_FormDetailRuleEntity.RuleType ),
                                             };
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO [dbo].[Workflow_FormDetailRule]");
                sb.Append("(");
                sb.Append(" [FormID]");
                sb.Append(",[GroupID]");
                sb.Append(",[FieldIDTo]");
                sb.Append(",[RuleDetail]");
                sb.Append(",[RuleType]");
                sb.Append(") ");
                sb.Append(" VALUES (");
                sb.Append("@FormID,");
                sb.Append("@GroupID,");
                sb.Append("@FieldIDTo,");
                sb.Append("@RuleDetail,");
                sb.Append("@RuleType ) ");
                sb.Append("select @@identity;");
                string RuleID = ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString();
                for (int i = 0; i < dtComputeRoute.Rows.Count; i++)
                {
                    DbParameter[] pramsRouteInsert = {
                                       MakeInParam("@RuleID",(DbType)SqlDbType.Int,4,RuleID ),
                                       MakeInParam("@ComputeType",(DbType)SqlDbType.Int,4,dtComputeRoute.Rows[i]["ComputeType"] ),
                                       MakeInParam("@RouteValue",(DbType)SqlDbType.VarChar,50,dtComputeRoute.Rows[i]["RouteValue"] ),
                                       MakeInParam("@RouteOrder",(DbType)SqlDbType.Int,4,dtComputeRoute.Rows[i]["RouteOrder"] ),
                                             };
                    string sqlInsert = @" insert into Workflow_ComputeRoute(RuleID,ComputeType,RouteValue,RouteOrder) values (@RuleID,@ComputeType,@RouteValue,@RouteOrder) ";
                    ExecuteScalar(CommandType.Text, sqlInsert, pramsRouteInsert);
                }

                UpdateWorkflow_FormDetailRule4Calculate(RuleID);
                return "0";
            }
        }