示例#1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string[] RuleDetail = GetRuleDetail();
            if (rblFieldType.SelectedValue == "0")
                {
                try
                    {
                    DbHelper.GetInstance().ExecSqlText(string.Format(" select {0} from Workflow_Form where RequestID=0", RuleDetail[0]));
                    }
                catch
                    {
                    BindGridView();
                    ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "add", "alert('赋值表达式不正确,无法添加');", true);
                    return;
                    }
                }
            else
                {
                try
                    {
                    DbHelper.GetInstance().ExecSqlText(string.Format(" select {0} from Workflow_FormDetail where RequestID=0", RuleDetail[0]));
                    }
                catch
                    {
                    BindGridView();
                    ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "add", "alert('赋值表达式不正确,无法添加');", true);
                    return;
                    }
                }

            DataTable dtExpression = (DataTable)ViewState["dtExpression"];
            Workflow_TriggerWFFieldMappingDetailEntity _TFM = new Workflow_TriggerWFFieldMappingDetailEntity();
            _TFM.MappingID = Convert.ToInt32(DNTRequest.GetString("MappingID"));
            _TFM.TriggerID = Convert.ToInt32(txtTriggerID.Value  );
            _TFM.TargetGroupID = Int32.Parse(rblGroupTo.SelectedValue);
            _TFM.TargetFieldID = Int32.Parse(ddlFieldIDTo.SelectedValue);
            _TFM.SourceGroupID = Int32.Parse(rblFieldType.SelectedValue);
            _TFM.SourceFieldTypeID = Convert.ToByte ((rblFieldType.SelectedValue == "0") ?"1" : "2");
            _TFM.SourceFieldName = RuleDetail[0];

            DbHelper.GetInstance().AddWorkflow_TriggerWFFieldMappingDetail(_TFM, dtExpression);

            dtExpression.Rows.Clear();
            ViewState["dtExpression"] = dtExpression;
            lblExpression.Text = "";
            BindGridView();
            System.Web.UI.ScriptManager.RegisterStartupScript(btnAdd, this.GetType(), "ButtonHideScript", strButtonHideScript, false);
        }
示例#2
0
        /// <summary>
        /// 新增信息
        /// </summary>
        /// <param name="_Workflow_TriggerWFFieldMappingDetailEntity"></param>
        /// <param name="dtTriggerExpression"></param>
        /// <returns>返回string "-1"表示该已经存在,否则成功 </returns>
        public string AddWorkflow_TriggerWFFieldMappingDetail(Workflow_TriggerWFFieldMappingDetailEntity _Workflow_TriggerWFFieldMappingDetailEntity, DataTable dtTriggerExpression)
        {
            //判断该记录是否已经存在

            DbParameter[] prams = {   MakeInParam("@MappingID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.MappingID ),
                                       MakeInParam("@TriggerID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.TriggerID ),
                                       MakeInParam("@TargetGroupID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.TargetGroupID ),
                                       MakeInParam("@TargetFieldID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.TargetFieldID )

                                     };
            string sql = "select SubMappingID  from  Workflow_TriggerWFFieldMappingDetail where MappingID=@MappingID and TriggerID=@TriggerID and TargetGroupID=@TargetGroupID and TargetFieldID=@TargetFieldID";
            DataTable dt = ExecuteDataset(CommandType.Text, sql, prams).Tables[0];

            try
            {

                if (dt.Rows.Count > 0)
                {
                    // //该记录已经存在,删除
                    DeleteWorkflow_TriggerWFFieldMappingDetail(dt.Rows[0][0].ToString());

                }

                DbParameter[] pramsInsert = {
                                       MakeInParam("@MappingID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.MappingID ),
                                       MakeInParam("@TriggerID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.TriggerID ),
                                       MakeInParam("@TargetGroupID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.TargetGroupID ),
                                       MakeInParam("@TargetFieldID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.TargetFieldID ),
                                       MakeInParam("@SourceGroupID",(DbType)SqlDbType.Int,4,_Workflow_TriggerWFFieldMappingDetailEntity.SourceGroupID ),
                                       MakeInParam("@SourceFieldName",(DbType)SqlDbType.VarChar,2000,_Workflow_TriggerWFFieldMappingDetailEntity.SourceFieldName ),
                                       MakeInParam("@SourceFieldTypeID",(DbType)SqlDbType.TinyInt,1,_Workflow_TriggerWFFieldMappingDetailEntity.SourceFieldTypeID )
                                             };
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO [dbo].Workflow_TriggerWFFieldMappingDetail");
                sb.Append("(");
                sb.Append("MappingID");
                sb.Append(",TriggerID");
                sb.Append(",TargetGroupID");
                sb.Append(",TargetFieldID");
                sb.Append(",SourceGroupID");
                sb.Append(",SourceFieldName");
                sb.Append(",SourceFieldTypeID");
                sb.Append(") ");
                sb.Append(" VALUES (");
                sb.Append("@MappingID,");
                sb.Append("@TriggerID,");
                sb.Append("@TargetGroupID,");
                sb.Append("@TargetFieldID,");
                sb.Append("@SourceGroupID,");
                sb.Append("@SourceFieldName,");
                sb.Append("@SourceFieldTypeID);");
                sb.Append("select @@identity;");
                int SubMappingID = Convert.ToInt32(ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString());

                for (int i = 0; i < dtTriggerExpression.Rows.Count; i++)
                {
                    DbParameter[] pramsExprInsert = {
                                       MakeInParam("@MappingID",(DbType)SqlDbType.Int,4,SubMappingID  ),
                                //       MakeInParam("@SourceFieldID",(DbType)SqlDbType.Int,4,dtTriggerExpression.Rows[i]["SourceFieldID"]   ),
                                       MakeInParam("@ComputeType",(DbType)SqlDbType.Int,4,dtTriggerExpression.Rows[i]["ComputeType"] ),
                                       MakeInParam("@ExpressionValue",(DbType)SqlDbType.VarChar,500,dtTriggerExpression.Rows[i]["ExpressionValue"] ),
                                       MakeInParam("@ExpressionOrder",(DbType)SqlDbType.TinyInt ,1,dtTriggerExpression.Rows[i]["ExpressionOrder"] ),
                                                  };
                    string sqlInsert = @" insert into Workflow_NodeTriggerExpression(MappingID,ComputeType,ExpressionValue,ExpressionOrder) values(@MappingID,@ComputeType,@ExpressionValue,@ExpressionOrder) ";
                    ExecuteScalar(CommandType.Text, sqlInsert, pramsExprInsert);
                }
                return "1";
            }
            catch
            {
                return "0";
            }
            finally
            {

            }
        }