Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string ruleid = Request.Form["ruleid"];

                    //Get Rule
                    eChartProject.Model.eChart.server_contents_rule modelans = new eChartProject.Model.eChart.server_contents_rule();
                    DataSet ds = RuleBll.GetList(" ID=" + int.Parse(ruleid));

                    if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        string   strRule = ds.Tables[0].Rows[0]["Rule1"].ToString();
                        TableEnt te      = new TableEnt();
                        te = XmlSerialization <TableEnt> .DeSerialize(strRule);

                        strRule = te.TableInfo.Name + "&" + te.FieldInfo.Name;
                        Response.Write(strRule);
                        Response.End();
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(eChartProject.Model.eChart.server_contents_rule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into server_contents_rule(");
            strSql.Append("MessageID,Rule1,Rule2,Rule3,Rule4,Rule5,Rule6)");
            strSql.Append(" values (");
            strSql.Append("@MessageID,@Rule1,@Rule2,@Rule3,@Rule4,@Rule5,@Rule6)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@MessageID", MySqlDbType.Int32,     11),
                new MySqlParameter("@Rule1",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule2",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule3",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule4",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule5",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule6",     MySqlDbType.VarChar, 4000)
            };
            parameters[0].Value = model.MessageID;
            parameters[1].Value = model.Rule1;
            parameters[2].Value = model.Rule2;
            parameters[3].Value = model.Rule3;
            parameters[4].Value = model.Rule4;
            parameters[5].Value = model.Rule5;
            parameters[6].Value = model.Rule6;

            DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public eChartProject.Model.eChart.server_contents_rule GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,MessageID,Rule1,Rule2,Rule3,Rule4,Rule5,Rule6 from server_contents_rule ");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.Int32)
            };
            parameters[0].Value = ID;

            eChartProject.Model.eChart.server_contents_rule model = new eChartProject.Model.eChart.server_contents_rule();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MessageID"] != null && ds.Tables[0].Rows[0]["MessageID"].ToString() != "")
                {
                    model.MessageID = int.Parse(ds.Tables[0].Rows[0]["MessageID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Rule1"] != null && ds.Tables[0].Rows[0]["Rule1"].ToString() != "")
                {
                    model.Rule1 = ds.Tables[0].Rows[0]["Rule1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Rule2"] != null && ds.Tables[0].Rows[0]["Rule2"].ToString() != "")
                {
                    model.Rule2 = ds.Tables[0].Rows[0]["Rule2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Rule3"] != null && ds.Tables[0].Rows[0]["Rule3"].ToString() != "")
                {
                    model.Rule3 = ds.Tables[0].Rows[0]["Rule3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Rule4"] != null && ds.Tables[0].Rows[0]["Rule4"].ToString() != "")
                {
                    model.Rule4 = ds.Tables[0].Rows[0]["Rule4"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Rule5"] != null && ds.Tables[0].Rows[0]["Rule5"].ToString() != "")
                {
                    model.Rule5 = ds.Tables[0].Rows[0]["Rule5"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Rule6"] != null && ds.Tables[0].Rows[0]["Rule6"].ToString() != "")
                {
                    model.Rule6 = ds.Tables[0].Rows[0]["Rule6"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string ruleid = Request.Form["ruleid"];
                    RuleBll.Delete(int.Parse(ruleid));

                    string selectid = Request.Form["selectid"];
                    string answer   = Request.Form["answer"];

                    selectid = selectid.Remove(0, Nodetype.message.ToString().Length);

                    eChartProject.Model.eChart.server_contents_answers modelans = new eChartProject.Model.eChart.server_contents_answers();
                    DataSet ds = abll.GetList(" messageID=" + int.Parse(selectid));
                    //update the answer of message
                    if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        string ID = ds.Tables[0].Rows[0]["ID"].ToString();
                        modelans.ID        = int.Parse(ID);
                        modelans.Answer    = answer.Trim();
                        modelans.MessageID = int.Parse(selectid);
                        modelans.isDeleted = 0;

                        abll.Update(modelans);
                    }
                    //if all rule deleted, update the message ispublic tag to true
                    eChartProject.Model.eChart.server_contents_rule modelrule = new eChartProject.Model.eChart.server_contents_rule();
                    DataSet dsRule = RuleBll.GetList(" messageID=" + int.Parse(selectid));

                    if (dsRule != null && dsRule.Tables != null && dsRule.Tables.Count > 0 && dsRule.Tables[0].Rows.Count == 0)
                    {
                        eChartProject.Model.eChart.server_contents_message model = new eChartProject.Model.eChart.server_contents_message();
                        model.isPublic = 1;
                        model.ID       = int.Parse(selectid);
                        bll.UpdateByIsPublic(model);
                    }

                    Response.Write("success");
                    Response.End();
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(eChartProject.Model.eChart.server_contents_rule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update server_contents_rule set ");
            strSql.Append("MessageID=@MessageID,");
            strSql.Append("Rule1=@Rule1,");
            strSql.Append("Rule2=@Rule2,");
            strSql.Append("Rule3=@Rule3,");
            strSql.Append("Rule4=@Rule4,");
            strSql.Append("Rule5=@Rule5,");
            strSql.Append("Rule6=@Rule6");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@MessageID", MySqlDbType.Int32,     11),
                new MySqlParameter("@Rule1",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule2",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule3",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule4",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule5",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@Rule6",     MySqlDbType.VarChar, 4000),
                new MySqlParameter("@ID",        MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.MessageID;
            parameters[1].Value = model.Rule1;
            parameters[2].Value = model.Rule2;
            parameters[3].Value = model.Rule3;
            parameters[4].Value = model.Rule4;
            parameters[5].Value = model.Rule5;
            parameters[6].Value = model.Rule6;
            parameters[7].Value = model.ID;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string fieldname = Request.Form["fieldname"];
                    string selectid  = Request.Form["selectid"];
                    string tablename = Request.Form["tablename"];

                    if (selectid.Contains(Nodetype.message.ToString()))
                    {
                        selectid = selectid.Remove(0, Nodetype.message.ToString().Length);
                        TableEnt  te = new TableEnt();
                        TableInfo ti = new TableInfo();
                        FieldInfo fi = new FieldInfo();
                        ti.Name      = tablename;
                        fi.Name      = fieldname;
                        te.TableInfo = ti;
                        te.FieldInfo = fi;

                        string result = "";
                        result = XmlSerialization <TableEnt> .Serialize(te);

                        eChartProject.Model.eChart.server_contents_rule scr = new eChartProject.Model.eChart.server_contents_rule();
                        scr.MessageID = int.Parse(selectid);
                        scr.Rule1     = result;
                        RuleBll.Add(scr);

                        int i = RuleBll.GetMaxId() - 1;

                        Response.Write("success" + i.ToString());
                        Response.End();
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 7
0
            public void PasteFromCut()
            {
                if (toID.Contains(Nodetype.message.ToString()))
                {
                    int iMsgID      = int.Parse(toID.Remove(0, Nodetype.message.ToString().Length));
                    int iToFolderID = int.Parse(ID.Remove(0, Nodetype.folder.ToString().Length));
                    eChartProject.Model.eChart.server_contents_message model = new eChartProject.Model.eChart.server_contents_message();
                    model           = bll.GetModel(iMsgID);
                    model.FolderID  = iToFolderID;
                    model.sortOrder = SortOrderHelper.GetSortOrder(iToFolderID);

                    bll.Add(model);

                    int newID = bll.GetMaxId() - 1;
                    //add variation
                    DataSet ds = bll.GetList(" relatedid = " + iMsgID);
                    if (ds != null & ds.Tables != null & ds.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            model.ID           = int.Parse(dr["ID"].ToString());
                            model.RelatedID    = newID;
                            model.Question     = dr["Question"].ToString();
                            model.isOffLine    = 0;
                            model.isPublic     = 1;
                            model.isVariations = 1;//设置成true
                            model.isDeleted    = 1;
                            model.FolderID     = null;
                            model.sortOrder    = null;
                            bll.Add(model);
                        }
                    }
                    eChartProject.Model.eChart.server_contents_answers ansmodel = new eChartProject.Model.eChart.server_contents_answers();
                    //if answer exist, update answer ,else if answer not exist,add answer
                    string ans = string.Empty;
                    ds = abll.GetList(" messageid = " + iMsgID);
                    if (ds != null & ds.Tables != null & ds.Tables[0].Rows.Count > 0)
                    {
                        //insert answer with answer content
                        ans                = ds.Tables[0].Rows[0]["answer"].ToString();
                        ansmodel.Answer    = ds.Tables[0].Rows[0]["answer"].ToString();
                        ansmodel.MessageID = newID;
                        ansmodel.isDeleted = 0;
                        abll.Add(ansmodel);
                    }
                    else
                    {
                        //insert answer
                        ansmodel.Answer    = "";
                        ansmodel.MessageID = newID;
                        ansmodel.isDeleted = 0;
                        abll.Add(ansmodel);
                    }
                    int newAnsID = abll.GetMaxId() - 1;
                    //if rule exist, update rule
                    eChartProject.Model.eChart.server_contents_rule rulemodel = new eChartProject.Model.eChart.server_contents_rule();
                    ds = RuleBll.GetList(" messageid = " + iMsgID);
                    if (ds != null & ds.Tables != null & ds.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            //insert rule
                            rulemodel.MessageID = newID;
                            rulemodel.Rule1     = dr["Rule1"].ToString();
                            RuleBll.Add(rulemodel);
                            int newRuleID = RuleBll.GetMaxId() - 1;

                            //update answer
                            ansmodel.ID        = newAnsID;
                            ansmodel.Answer    = ans.Replace("<img id=\"" + dr["ID"].ToString() + "\" img=\"\" src=\"../App_Themes/DefaultTheme/images/database_add.png\" />", "<img id=\"" + newRuleID + "\" img=\"\" src=\"../App_Themes/DefaultTheme/images/database_add.png\" />");
                            ansmodel.MessageID = newID;
                            ansmodel.isDeleted = 0;
                            abll.Update(ansmodel);
                            ans = ansmodel.Answer;
                        }
                    }
                    bll.Delete(iMsgID);
                }
            }