Beispiel #1
0
        protected void PrepareForm()
        {
            RSH_BaziLogicMod m_logic = RSH_BaziLogicBll.GetInstance().GetModel(sysno);

            txtTitle.Text         = m_logic.Name;
            txtDesc.Text          = m_logic.Description;
            drpType.SelectedIndex = drpType.Items.IndexOf(drpType.Items.FindByValue(m_logic.Type.ToString()));

            string[] logic = m_logic.Logic.Split(new char[] { '_' });
            ConditionList = RSH_BaziConditionBll.GetInstance().GetListByLogic(sysno);
            ConditionList.Columns.Add("sign1");
            ConditionList.Columns.Add("sign2");
            ConditionList.Columns.Add("sign");
            ConditionList.Columns.Add("logic");
            for (int i = 0; i < logic.Length / 4; i++)
            {
                if (logic[4 * i + 1].Contains("#"))
                {
                    DataRow m_dr = ConditionList.NewRow();
                    ConditionList.Rows.InsertAt(m_dr, i);
                    ConditionList.Rows[i]["logic"] = logic[4 * i + 1].Replace("#", "");
                }
                else
                {
                    ConditionList.Rows[i]["logic"] = "";
                }
                ConditionList.Rows[i]["sign1"] = logic[4 * i];
                ConditionList.Rows[i]["sign2"] = logic[4 * i + 2];
                ConditionList.Rows[i]["sign"]  = logic[4 * i + 3];
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(RSH_BaziLogicMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RSH_BaziLogic set ");
            SqlCommand cmd = new SqlCommand();

            if (model.SysNo != AppConst.IntNull)
            {
                SqlParameter param = new SqlParameter("@SysNo", SqlDbType.Int, 4);
                param.Value = model.SysNo;
                cmd.Parameters.Add(param);
            }
            if (model.Name != AppConst.StringNull)
            {
                strSql.Append("Name=@Name,");
                SqlParameter param = new SqlParameter("@Name", SqlDbType.NVarChar, 200);
                param.Value = model.Name;
                cmd.Parameters.Add(param);
            }
            if (model.Description != AppConst.StringNull)
            {
                strSql.Append("Description=@Description,");
                SqlParameter param = new SqlParameter("@Description", SqlDbType.NVarChar, 2000);
                param.Value = model.Description;
                cmd.Parameters.Add(param);
            }
            if (model.Logic != AppConst.StringNull)
            {
                strSql.Append("Logic=@Logic,");
                SqlParameter param = new SqlParameter("@Logic", SqlDbType.VarChar, 1000);
                param.Value = model.Logic;
                cmd.Parameters.Add(param);
            }
            if (model.Type != AppConst.IntNull)
            {
                strSql.Append("Type=@Type,");
                SqlParameter param = new SqlParameter("@Type", SqlDbType.Int, 4);
                param.Value = model.Type;
                cmd.Parameters.Add(param);
            }
            if (model.DR != AppConst.IntNull)
            {
                strSql.Append("DR=@DR,");
                SqlParameter param = new SqlParameter("@DR", SqlDbType.Int, 4);
                param.Value = model.DR;
                cmd.Parameters.Add(param);
            }
            strSql.Remove(strSql.Length - 1, 1);
            strSql.Append(" where SysNo=@SysNo ");
            cmd.CommandText = strSql.ToString();
            return(SqlHelper.ExecuteNonQuery(cmd, null));
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete()
        {
            try
            {
                RSH_BaziLogicMod m_logic = RSH_BaziLogicBll.GetInstance().GetModel(int.Parse(Request.QueryString["delete"]));
                m_logic.DR = (int)AppEnum.State.deleted;
                RSH_BaziLogicBll.GetInstance().Update(m_logic);

                ltrNotice.Text = "该记录已删除!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('noticediv').style.display='';", true);
            }
            catch
            {
                ltrError.Text = "系统错误,删除失败!";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';", true);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(RSH_BaziLogicMod model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into RSH_BaziLogic(");
            strSql.Append("Name,Description,Logic,Type,DR)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Description,@Logic,@Type,@DR)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());
            SqlParameter[] parameters = {
                 new SqlParameter("@Name",SqlDbType.NVarChar,200),
                 new SqlParameter("@Description",SqlDbType.NVarChar,2000),
                 new SqlParameter("@Logic",SqlDbType.VarChar,1000),
                 new SqlParameter("@Type",SqlDbType.Int,4),
                 new SqlParameter("@DR",SqlDbType.Int,4),
             };
            if (model.Name != AppConst.StringNull)
                parameters[0].Value = model.Name;
            else
                parameters[0].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[0]);
            if (model.Description != AppConst.StringNull)
                parameters[1].Value = model.Description;
            else
                parameters[1].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[1]);
            if (model.Logic != AppConst.StringNull)
                parameters[2].Value = model.Logic;
            else
                parameters[2].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[2]);
            if (model.Type != AppConst.IntNull)
                parameters[3].Value = model.Type;
            else
                parameters[3].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[3]);
            if (model.DR != AppConst.IntNull)
                parameters[4].Value = model.DR;
            else
                parameters[4].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[4]);

            return Convert.ToInt32(SqlHelper.ExecuteScalar(cmd, parameters));
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RSH_BaziLogicMod GetModel(int SysNo)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select SysNo, Name, Description, Logic, Type, DR from  dbo.RSH_BaziLogic");
            strSql.Append(" where SysNo=@SysNo ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SysNo", SqlDbType.Int, 4)
            };
            parameters[0].Value = SysNo;
            RSH_BaziLogicMod model = new RSH_BaziLogicMod();
            DataSet          ds    = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "")
                {
                    model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString());
                }
                model.Name        = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                model.Logic       = ds.Tables[0].Rows[0]["Logic"].ToString();
                if (ds.Tables[0].Rows[0]["Type"].ToString() != "")
                {
                    model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DR"].ToString() != "")
                {
                    model.DR = int.Parse(ds.Tables[0].Rows[0]["DR"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(RSH_BaziLogicMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RSH_BaziLogic(");
            strSql.Append("Name,Description,Logic,Type,DR)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Description,@Logic,@Type,@DR)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.NVarChar,  200),
                new SqlParameter("@Description", SqlDbType.NVarChar, 2000),
                new SqlParameter("@Logic",       SqlDbType.VarChar,  1000),
                new SqlParameter("@Type",        SqlDbType.Int,         4),
                new SqlParameter("@DR",          SqlDbType.Int,         4),
            };
            if (model.Name != AppConst.StringNull)
            {
                parameters[0].Value = model.Name;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.Description != AppConst.StringNull)
            {
                parameters[1].Value = model.Description;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.Logic != AppConst.StringNull)
            {
                parameters[2].Value = model.Logic;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.Type != AppConst.IntNull)
            {
                parameters[3].Value = model.Type;
            }
            else
            {
                parameters[3].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[3]);
            if (model.DR != AppConst.IntNull)
            {
                parameters[4].Value = model.DR;
            }
            else
            {
                parameters[4].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[4]);

            return(Convert.ToInt32(SqlHelper.ExecuteScalar(cmd, parameters)));
        }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(RSH_BaziLogicMod model)
 {
     return dal.Add(model);
 }
Beispiel #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(RSH_BaziLogicMod model)
 {
     dal.Update(model);
 }
Beispiel #9
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            #region 输入检查
            int count = 0;
            foreach (RepeaterItem item in Repeater1.Items)
            {
                if (item.ItemIndex > int.Parse(HiddenField1.Value))
                {
                    continue;
                }
                if (((TextBox)item.FindControl("txtSign1")).Text.Trim().Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "") != "")
                {
                    ltrError.Text = "输入框只可输入括号";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
                if (((TextBox)item.FindControl("txtSign2")).Text.Trim().Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "") != "")
                {
                    ltrError.Text = "输入框只可输入括号";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
                if (HiddenField2.Value.Contains("|" + item.ItemIndex + "|") && ((DropDownList)item.FindControl("drpLogic")).SelectedValue == "-1")
                {
                    ltrError.Text = "有逻辑选择框未选择";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
                if (!HiddenField2.Value.Contains("|" + item.ItemIndex + "|") && ((DropDownList)item.FindControl("drpItem")).SelectedValue == "-1")
                {
                    ltrError.Text = "有主语选择框未选择";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                    return;
                }
                string tmpstr = ((TextBox)item.FindControl("txtSign1")).Text.Trim() + ((TextBox)item.FindControl("txtSign2")).Text.Trim();
                foreach (char c in tmpstr)
                {
                    if (c == '(' || c == '(')
                    {
                        count++;
                    }
                    if (c == ')' || c == ')')
                    {
                        count--;
                    }
                }
            }
            if (count != 0)
            {
                ltrError.Text = "括号开闭数量不对称";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }

            if (drpType.SelectedValue == "-1")
            {
                ltrError.Text = "请选择类型";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }
            if (txtTitle.Text.Trim() == "")
            {
                ltrError.Text = "请输入标题";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }
            if (txtDesc.Text.Trim() == "")
            {
                ltrError.Text = "请输入注释";
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "document.getElementById('errordiv').style.display='';closeforseconds();", true);
                return;
            }
            #endregion


            RSH_BaziLogicMod m_logic = new RSH_BaziLogicMod();
            if (sysno == AppConst.IntNull)
            {
                m_logic.Description = txtDesc.Text.Trim();
                m_logic.DR          = (int)AppEnum.State.normal;
                m_logic.Name        = txtTitle.Text.Trim();
                m_logic.Type        = int.Parse(drpType.SelectedValue);
                m_logic.Logic       = "";
                m_logic.SysNo       = RSH_BaziLogicBll.GetInstance().Add(m_logic);
            }
            else
            {
                m_logic             = RSH_BaziLogicBll.GetInstance().GetModel(sysno);
                m_logic.Description = txtDesc.Text.Trim();
                m_logic.DR          = (int)AppEnum.State.normal;
                m_logic.Name        = txtTitle.Text.Trim();
                m_logic.Type        = int.Parse(drpType.SelectedValue);
                m_logic.Logic       = "";
                RSH_BaziConditionBll.GetInstance().DeleteConditionsByLogic(sysno);
            }
            //List<RSH_BaziConditionMod> m_condtions = new List<RSH_BaziConditionMod>();
            foreach (RepeaterItem item in Repeater1.Items)
            {
                if (item.ItemIndex > int.Parse(HiddenField1.Value))
                {
                    continue;
                }
                m_logic.Logic += ((TextBox)item.FindControl("txtSign1")).Text + "_";
                if (HiddenField2.Value.Contains("|" + item.ItemIndex + "|"))
                {
                    m_logic.Logic += "#" + ((DropDownList)item.FindControl("drpLogic")).SelectedValue + "_";
                }
                else if (((DropDownList)item.FindControl("drpItem")).Style["display"] != "none")
                {
                    RSH_BaziConditionMod tmp_c = new RSH_BaziConditionMod();
                    tmp_c.Item       = int.Parse(((DropDownList)item.FindControl("drpItem")).SelectedValue);
                    tmp_c.LogicSysNo = m_logic.SysNo;
                    tmp_c.Type       = int.Parse(((DropDownList)item.FindControl("drpType")).SelectedValue);
                    tmp_c.Condition  = int.Parse(((DropDownList)item.FindControl("drpCondition")).SelectedValue);
                    tmp_c.Target     = int.Parse(((DropDownList)item.FindControl("drpTarget")).SelectedValue);
                    tmp_c.Negative   = int.Parse(((DropDownList)item.FindControl("drpNegative")).SelectedValue);

                    tmp_c.SysNo    = RSH_BaziConditionBll.GetInstance().Add(tmp_c);
                    m_logic.Logic += "@" + tmp_c.SysNo + "_";
                }
                m_logic.Logic += ((TextBox)item.FindControl("txtSign2")).Text + "_";
                m_logic.Logic += ((DropDownList)item.FindControl("drpSign")).SelectedValue + "_";
            }
            m_logic.Logic = m_logic.Logic.Substring(0, m_logic.Logic.Length - 1);
            RSH_BaziLogicBll.GetInstance().Update(m_logic);
        }
Beispiel #10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(RSH_BaziLogicMod model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("update RSH_BaziLogic set ");
     SqlCommand cmd = new SqlCommand();
     if (model.SysNo != AppConst.IntNull)
     {
         SqlParameter param = new SqlParameter("@SysNo", SqlDbType.Int, 4);
         param.Value = model.SysNo;
         cmd.Parameters.Add(param);
     }
     if (model.Name != AppConst.StringNull)
     {
         strSql.Append("Name=@Name,");
         SqlParameter param = new SqlParameter("@Name", SqlDbType.NVarChar, 200);
         param.Value = model.Name;
         cmd.Parameters.Add(param);
     }
     if (model.Description != AppConst.StringNull)
     {
         strSql.Append("Description=@Description,");
         SqlParameter param = new SqlParameter("@Description", SqlDbType.NVarChar, 2000);
         param.Value = model.Description;
         cmd.Parameters.Add(param);
     }
     if (model.Logic != AppConst.StringNull)
     {
         strSql.Append("Logic=@Logic,");
         SqlParameter param = new SqlParameter("@Logic", SqlDbType.VarChar, 1000);
         param.Value = model.Logic;
         cmd.Parameters.Add(param);
     }
     if (model.Type != AppConst.IntNull)
     {
         strSql.Append("Type=@Type,");
         SqlParameter param = new SqlParameter("@Type", SqlDbType.Int, 4);
         param.Value = model.Type;
         cmd.Parameters.Add(param);
     }
     if (model.DR != AppConst.IntNull)
     {
         strSql.Append("DR=@DR,");
         SqlParameter param = new SqlParameter("@DR", SqlDbType.Int, 4);
         param.Value = model.DR;
         cmd.Parameters.Add(param);
     }
     strSql.Remove(strSql.Length - 1, 1);
     strSql.Append(" where SysNo=@SysNo ");
     cmd.CommandText = strSql.ToString();
     return SqlHelper.ExecuteNonQuery(cmd, null);
 }
Beispiel #11
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public RSH_BaziLogicMod GetModel(int SysNo)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select SysNo, Name, Description, Logic, Type, DR from  dbo.RSH_BaziLogic");
     strSql.Append(" where SysNo=@SysNo ");
     SqlParameter[] parameters = {
     new SqlParameter("@SysNo", SqlDbType.Int,4 )
      		};
     parameters[0].Value = SysNo;
     RSH_BaziLogicMod model = new RSH_BaziLogicMod();
     DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);
     if (ds.Tables[0].Rows.Count > 0)
     {
         if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "")
         {
             model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString());
         }
         model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
         model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
         model.Logic = ds.Tables[0].Rows[0]["Logic"].ToString();
         if (ds.Tables[0].Rows[0]["Type"].ToString() != "")
         {
             model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString());
         }
         if (ds.Tables[0].Rows[0]["DR"].ToString() != "")
         {
             model.DR = int.Parse(ds.Tables[0].Rows[0]["DR"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public void Update(RSH_BaziLogicMod model)
        {
            dal.Update(model);
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(RSH_BaziLogicMod model)
        {
            return(dal.Add(model));
        }