示例#1
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txt_name = GridView1.Rows[e.RowIndex].FindControl("txt_name") as TextBox;
        TextBox txt_sort = GridView1.Rows[e.RowIndex].FindControl("txt_sort") as TextBox;

        int    id       = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values["hid"]);
        huashu dp       = BLL.huashuManager.SearchByID(id);
        int    sort     = 0;
        string str_sort = txt_sort.Text.Trim();

        if (string.IsNullOrEmpty(str_sort))
        {
            AJAXManager.Alert(this.UpdatePanel1, "请输入排序");
            return;
        }
        else if (!int.TryParse(str_sort, out sort))
        {
            AJAXManager.Alert(this.UpdatePanel1, "请输入正确的排序");
            return;
        }
        dp.htitle = string.IsNullOrEmpty(txt_name.Text) ? "" : txt_name.Text.Trim();
        dp.hsort  = sort;

        if (BLL.huashuManager.Update(dp) != 1)
        {
            AJAXManager.Alert(this.UpdatePanel1, "修改失败");
        }
        else
        {
            GridView1.EditIndex = -1;
            bind();
        }
    }
示例#2
0
文件: Form1.cs 项目: ourstoryzj/mumu
        /// <summary>
        /// 没有任何引用
        /// </summary>
        /// <returns></returns>
        List <huashu> tongbu_data()
        {
            List <huashu> list = new List <huashu>();
            huashu        hs   = new huashu();

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("db.xml");                                              //加载Xml文件
                XmlElement  rootElem    = doc.DocumentElement;                   //获取根节点
                XmlNodeList personNodes = rootElem.GetElementsByTagName("Node"); //获取person子节点集合
                foreach (XmlNode node in personNodes)
                {
                    hs = convert_xml(node);
                    update(hs);

                    //开始处理话术
                    XmlNodeList Nodes_hua = ((XmlElement)node).GetElementsByTagName("hua");  //获取hua子XmlElement集合
                    foreach (XmlNode hua_node in Nodes_hua)
                    {
                        hs = convert_xml(hua_node);
                        list.Add(hs);
                    }
                }
                foreach (huashu h in list)
                {
                    update(h);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            return(list);
        }
示例#3
0
文件: Form1.cs 项目: ourstoryzj/mumu
        /// <summary>
        /// 话术XML文件转化为List类
        /// </summary>
        /// <returns></returns>
        List <huashu> XmlToListHuaShu()
        {
            List <huashu> list = new List <huashu>();

            try
            {
                huashu hs = new huashu();

                XmlDocument doc = new XmlDocument();
                doc.Load("db.xml");                                              //加载Xml文件
                XmlElement  rootElem    = doc.DocumentElement;                   //获取根节点
                XmlNodeList personNodes = rootElem.GetElementsByTagName("Node"); //获取person子节点集合
                foreach (XmlNode node in personNodes)
                {
                    hs = convert_xml(node);
                    update(hs);

                    //开始处理话术
                    XmlNodeList Nodes_hua = ((XmlElement)node).GetElementsByTagName("hua");  //获取hua子XmlElement集合
                    foreach (XmlNode hua_node in Nodes_hua)
                    {
                        hs = convert_xml(hua_node);
                        list.Add(hs);
                    }
                }
            }
            catch { }
            return(list);
        }
示例#4
0
        /// <summary>
        /// 模糊搜索
        /// </summary>
        /// <param name="key">关键词</param>
        /// <param name="state">状态</param>
        /// <param name="id">int字段</param>
        /// <param name="startdate">起始时间</param>
        /// <param name="enddate">结束时间</param>
        /// <param name="orderby">排序</param>
        /// <returns>IList<huashu></returns>
        public IList <huashu> Search2(int s, int e, string key, string state, string _type, int sort, DateTime startdate, DateTime enddate, string orderby)
        {
            string sql1  = "select top " + (e - s + 1).ToString() + " * from huashu where ";
            string sql2  = string.IsNullOrEmpty(key) ? " 1=1 " : " ( hcontext like '%" + key + "%' or htitle like '%" + key + "%' or hstate like '%" + key + "%' or hsendemail like '%" + key + "%' or hremark like '%" + key + "%' )";//删除无用字段,删除最后一个or
            string sql3  = string.IsNullOrEmpty(state) ? "" : " and hstate= '" + state + "' ";
            string sql11 = string.IsNullOrEmpty(_type) ? " and hfid!= 0 " : " and hfid= " + _type + " ";

            string sql4 = sort == 0 ? "" : " and hcount = '" + sort.ToString() + "' and hcontext is null  ";//Int字段,无用删除
            string sql5 = startdate == new DateTime() ? "" : " and datediff('d','" + startdate.ToString() + "',hdate)>=0 ";
            string sql6 = enddate == new DateTime() ? "" : " and datediff('d','" + enddate.ToString() + "',hdate)<=0 ";

            string sql7 = string.IsNullOrEmpty(orderby) ? " order by hid desc " : " order by " + orderby;
            string sql8 = s == 1 ? "" : " and hid not in ( select top " + (s - 1).ToString() + " hid from huashu where " + sql2 + sql3 + sql4 + sql5 + sql6 + sql11 + sql7 + " ) ";

            DBHelper.sqlstr = sql1 + sql2 + sql3 + sql4 + sql5 + sql6 + sql11 + sql8 + sql7;
            List <huashu> list   = new List <huashu>();
            SqlDataReader reader = DBHelper.ExecuteReader();

            while (reader.Read())
            {
                huashu Obj = GetByReader(reader);
                list.Add(Obj);
            }
            reader.Close();
            return(list);
        }
示例#5
0
 void bind()
 {
     if (!string.IsNullOrEmpty(id))
     {
         int temp = 0;
         if (int.TryParse(id, out temp))
         {
             huashu sp = BLL.huashuManager.SearchByID(temp);
             if (sp != null)
             {
                 try
                 {
                     txt_context.Text        = sp.hcontext;
                     txt_count.Text          = sp.hcount.ToString();
                     txt_sort.Text           = sp.hsort.ToString();
                     txt_title.Text          = sp.htitle;
                     ddl_state.SelectedValue = sp.hstate;
                     ddl_type.SelectedValue  = sp.hfid.ToString();
                     liter_date.Text         = sp.hdate.ToString();
                 }
                 catch { }
             }
         }
     }
 }
示例#6
0
文件: HuaShu.cs 项目: ourstoryzj/mumu
 /// <summary>
 /// 自动保存 用户离开单元格时
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgv1_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
 {
     try
     {
         string colname = dgv1.Columns[dgv1.CurrentCell.ColumnIndex].Name;
         if (colname.Equals("col_title") || colname.Equals("col_sort") || colname.Equals("col_context"))
         {
             huashu hs = (huashu)dgv1.CurrentRow.DataBoundItem;
             if (hs != null)
             {
                 string htitle   = dgv1["col_title", e.RowIndex].EditedFormattedValue == null ? "" : dgv1["col_title", e.RowIndex].EditedFormattedValue.ToString();
                 string hcontext = dgv1["col_context", e.RowIndex].EditedFormattedValue == null ? "" : dgv1["col_context", e.RowIndex].EditedFormattedValue.ToString();
                 string hsort    = dgv1["col_sort", e.RowIndex].EditedFormattedValue == null ? "" : dgv1["col_sort", e.RowIndex].EditedFormattedValue.ToString();
                 hs.htitle   = htitle;
                 hs.hsort    = hsort.ToInt();
                 hs.hcontext = hcontext;
                 BLL.huashuManager.Update(hs);
                 //dgv_type.ToClearChecked();
             }
         }
     }
     catch (Exception ex)
     {
         ex.ToLog();
     }
 }
示例#7
0
        /// <summary>
        /// 根据条件查询全部数据
        /// </summary>
        /// <param name="s">起始位置</param>
        /// <param name="e">结束位置</param>
        /// <param name="key">关键词</param>
        /// <param name="state">状态</param>
        /// <param name="date1">起始时间</param>
        /// <param name="date2">结束时间</param>
        /// <returns>IList<huashu></returns>
        public IList <huashu> Search(int s, int e, string key, string state, string _type, DateTime date1, DateTime date2)
        {
            List <huashu> list = new List <huashu>();

            //string sql1 = "select top " + e.ToString() + " * from shuadan_pingjia where ";
            try
            {
                string sql2 = string.IsNullOrEmpty(key) ? " 1=1 " : " (  htitle like '%" + key + "%' or  hcontext like '%" + key + "%' or hremark like '%" + key + "%' ) ";
                string sql3 = string.IsNullOrEmpty(state) ? "" : " and hstate= '" + state + "' ";
                string sql4 = string.IsNullOrEmpty(_type) ? " and hfid!= 0 " : " and hfid= " + _type + " ";
                string sql5 = date1 == new DateTime() ? "" : " and datediff('d','" + date1.ToString() + "',hdate)>=0 ";
                string sql6 = date2 == new DateTime() ? "" : " and datediff('d','" + date2.ToString() + "',hdate)<=0 ";
                string sql1 = "select top " + e.ToString() + " * from   huashu where " + sql2 + sql3 + sql4 + sql5 + sql6;
                DBHelper.sqlstr = "select * from ( select top " + (e - s + 1).ToString() + " * from " + "( " + sql1 + " order by hsort asc,hcount desc,hid asc  ) as table1  order by hsort desc,hcount asc  ,hid desc )as table2  order by hsort asc,hcount desc,hid asc ";

                SqlDataReader reader = DBHelper.ExecuteReader();
                while (reader.Read())
                {
                    huashu Obj = GetByReader(reader);
                    list.Add(Obj);
                }
                reader.Close();
            }
            catch (Exception)
            {
                //throw;
            }
            return(list);
        }
示例#8
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txt_title   = GridView1.Rows[e.RowIndex].FindControl("txt_title") as TextBox;
        TextBox txt_context = GridView1.Rows[e.RowIndex].FindControl("txt_context") as TextBox;
        TextBox txt_sort    = GridView1.Rows[e.RowIndex].FindControl("txt_sort") as TextBox;
        int     _sort       = 0;

        if (!int.TryParse(txt_sort.Text.Trim(), out _sort))
        {
            AJAXManager.Alert(this.UpdatePanel1, "请输入正确的排序");
            return;
        }

        int    id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values["hid"]);
        huashu sa = BLL.huashuManager.SearchByID(id);

        sa.htitle   = txt_title.Text.Trim();
        sa.hcontext = txt_context.Text.Trim();
        sa.hsort    = _sort;
        if (BLL.huashuManager.Update(sa) != 1)
        {
            AJAXManager.Alert(this.UpdatePanel1, "修改失败");
        }
        else
        {
            GridView1.EditIndex = -1;
            bind();
        }
    }
示例#9
0
    protected void btn_save_Click(object sender, EventArgs e)
    {
        try
        {
            string name     = txt_name.Text.Trim();
            string state    = ddl_state.SelectedValue.ToString();
            string sort     = txt_sort.Text.Trim();
            int    int_sort = 0;
            if (!int.TryParse(sort, out int_sort))
            {
                Manager.Alert("请输入正确的排序", Page);
                Manager.TextBox_Select(txt_sort);
                return;
            }
            huashu dp = new huashu();


            if (!string.IsNullOrEmpty(id))
            {
                dp = BLL.huashuManager.SearchByID(Convert.ToInt32(id));
            }
            else
            {
                dp.hdate  = DateTime.Now;
                dp.hcount = 0;
            }

            dp.htitle = name;
            dp.hsort  = int_sort;
            dp.hstate = state;
            dp.hfid   = 0;
            int res;
            if (string.IsNullOrEmpty(id))
            {
                res = BLL.huashuManager.Insert(dp);
            }
            else
            {
                res = BLL.huashuManager.Update(dp);
            }
            if (res == 1)
            {
                Manager.Alert("保存成功", Page);
            }
            else
            {
                Manager.Alert("保存失败", Page);
            }
        }
        catch (Exception ex)
        {
            Manager.Alert(ex.ToString(), Page);
            return;
        }
        Manager.page_href_reload(Page);
    }
示例#10
0
        /// <summary>
        /// 搜索全部父类
        /// </summary>
        /// <returns></returns>
        public IList <huashu> SearchAll(string state)
        {
            DBHelper.sqlstr = "select * from huashu where hfid=0 " + (string.IsNullOrEmpty(state) ? "" : " and hstate='" + state + "' ") + " order by hsort asc,hcount desc,hid asc ";
            List <huashu> list   = new List <huashu>();
            SqlDataReader reader = DBHelper.ExecuteReader();

            while (reader.Read())
            {
                huashu Obj = GetByReader(reader);
                list.Add(Obj);
            }
            reader.Close();
            return(list);
        }
示例#11
0
        /// <summary>
        /// 根据hid,查询一条数据
        /// </summary>
        /// <param name="hid"></param>
        /// <returns></returns>
        /*查看是否为视图*/

        public huashu SearchByID(int hid)
        {
            DBHelper.sqlstr = "select * from huashu where hid = @hid";
            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@hid", hid)
            };
            SqlDataReader reader = DBHelper.ExecuteReader(param);
            huashu        Obj    = null;

            if (reader.Read())
            {
                Obj = GetByReader(reader);
            }
            reader.Close();
            return(Obj);
        }
示例#12
0
        /// <summary>
        /// 从一个SqlDataReader里读数据
        /// </summary>
        /// <param name="Reader">SqlDataReader</param>
        /// <returns>huashuExample</returns>
        public static huashu GetByReader(SqlDataReader Reader)
        {
            huashu huashuExample = new huashu();

            huashuExample.hid        = Reader["hid"] == DBNull.Value ? 0 : (int)Reader["hid"];
            huashuExample.hfid       = Reader["hfid"] == DBNull.Value ? 0 : (int)Reader["hfid"];
            huashuExample.hcontext   = Reader["hcontext"] == DBNull.Value ? null : Reader["hcontext"].ToString();
            huashuExample.hsort      = Reader["hsort"] == DBNull.Value ? 0 : (int)Reader["hsort"];
            huashuExample.hcount     = Reader["hcount"] == DBNull.Value ? 0 : (int)Reader["hcount"];
            huashuExample.hdate      = Reader["hdate"] == DBNull.Value ? new DateTime() : Convert.ToDateTime(Reader["hdate"]);
            huashuExample.htitle     = Reader["htitle"] == DBNull.Value ? null : Reader["htitle"].ToString();
            huashuExample.hstate     = Reader["hstate"] == DBNull.Value ? null : Reader["hstate"].ToString();
            huashuExample.hsendemail = Reader["hsendemail"] == DBNull.Value ? null : Reader["hsendemail"].ToString();
            huashuExample.hremark    = Reader["hremark"] == DBNull.Value ? null : Reader["hremark"].ToString();
            return(huashuExample);
        }
示例#13
0
文件: HuaShu.cs 项目: ourstoryzj/mumu
        private void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string fid = cb_huashutype.SelectedValue != null?cb_huashutype.SelectedValue.ToString() : "";

                if (string.IsNullOrEmpty(fid))
                {
                    "请选择类型".ToShow();
                    return;
                }
                string context = txt_context.Text.Trim();
                string title   = txt_name.Text.Trim();
                string sort    = txt_sort.Text.Trim();
                string email   = cb_email.Text == "是" ? "1" : "2";
                string state   = cb_state.Text == "启用" ? "1" : "2";

                huashu hs = new huashu();
                if (hid != 0)
                {
                    hs = BLL.huashuManager.SearchByID(hid);
                }

                hs.hcontext   = context;
                hs.hcount     = 0;
                hs.hdate      = DateTime.Now;
                hs.hfid       = fid.ToInt();
                hs.hsendemail = email;
                hs.hsort      = sort.ToInt();
                hs.hstate     = state;
                hs.htitle     = title;
                if (hid == 0)
                {
                    BLL.huashuManager.Insert(hs);
                }
                else
                {
                    BLL.huashuManager.Update(hs);
                }
                "保存成功".ToShow();
                bind();
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存错误" + ex.ToString());
            }
        }
示例#14
0
文件: HuaShu.cs 项目: ourstoryzj/mumu
 private void dgv1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         //如果不是首行
         if (e.RowIndex > -1)
         {
             huashu sr = (huashu)dgv1.CurrentRow.DataBoundItem;
             tabControl1.SelectedTab = tabPage3;
             bindedit(sr);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#15
0
文件: HuaShu.cs 项目: ourstoryzj/mumu
        void bindedit(huashu hs)
        {
            tabControl1.SelectedTab = tabPage3;
            if (hs != null)
            {
                cb_huashutype.ToSelectComboBoxItem(BLL.huashuManager.SearchByID(hs.hfid).htitle);

                txt_context.Text = hs.hcontext;
                txt_name.Text    = hs.htitle;
                txt_sort.Text    = hs.hsort.ToString();
                cb_email.Text    = hs.hsendemail == "1" ? "是" : "否";
                cb_state.Text    = hs.hstate == "1" ? "启用" : "禁用";
                lbl_count.Text   = hs.hcount.ToString();
                lbl_date.Text    = hs.hdate.ToString();

                hid = hs.hid;
            }
        }
示例#16
0
文件: HuaShu.cs 项目: ourstoryzj/mumu
        private void btn_delete_Click(object sender, EventArgs e)
        {
            List <int> list = dgv1.GetDeleteCheckedIndex();

            if (list.Count > 0)
            {
                foreach (int i in list)
                {
                    huashu hs = (huashu)dgv1.Rows[i].DataBoundItem;
                    BLL.huashuManager.Delete(hs.hid);
                    dgv1.ToAfterDelete(i);
                }
                "删除成功".ToShow();
            }
            else
            {
                "请选择需要删除的信息".ToShow();
            }
        }
示例#17
0
文件: Form1.cs 项目: ourstoryzj/mumu
        /// <summary>
        /// 从XML转换到huashu实例
        /// </summary>
        /// <param name="xn"></param>
        /// <returns></returns>
        huashu convert_xml(XmlNode xn)
        {
            huashu hs = new huashu();

            try
            {
                string hid      = ((XmlElement)xn).GetAttribute("hid");      //获取title属性值
                string hfid     = ((XmlElement)xn).GetAttribute("hfid");     //获取title属性值
                string htitle   = ((XmlElement)xn).GetAttribute("htitle");   //获取title属性值
                string hcontext = ((XmlElement)xn).GetAttribute("hcontext"); //获取title属性值
                string hsort    = ((XmlElement)xn).GetAttribute("hsort");    //获取title属性值
                string hcount   = ((XmlElement)xn).GetAttribute("hcount");   //获取title属性值
                string hdate    = ((XmlElement)xn).GetAttribute("hdate");    //获取title属性值
                string hstate   = ((XmlElement)xn).GetAttribute("hstate");   //获取title属性值

                int      _hid    = 0;
                int      _hfid   = 0;
                int      _hsort  = 0;
                int      _hcount = 0;
                DateTime _hdate  = new DateTime();

                int.TryParse(hid, out _hid);
                int.TryParse(hfid, out _hfid);
                int.TryParse(hsort, out _hsort);
                int.TryParse(hcount, out _hcount);
                DateTime.TryParse(hdate, out _hdate);


                hs.hcontext = hcontext;
                hs.hcount   = _hcount;
                hs.hdate    = _hdate;
                hs.hfid     = _hfid;
                hs.hid      = _hid;
                hs.hsort    = _hsort;
                hs.hstate   = hstate;
                hs.htitle   = htitle;
            }
            catch
            {
                Debug.WriteLine(xn.ToString());
            }
            return(hs);
        }
示例#18
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string state = e.CommandName;

        if (state == "state")
        {
            int id = Convert.ToInt32(GridView1.DataKeys[((e.CommandSource as LinkButton).NamingContainer as GridViewRow).RowIndex].Values["hid"].ToString());
            if (id != 0)
            {
                huashu sa = BLL.huashuManager.SearchByID(id);
                sa.hstate = sa.hstate == "1" ? "2" : "1";
                if (BLL.huashuManager.Update(sa) != 1)
                {
                    AJAXManager.Alert(this.UpdatePanel1, "修改失败");
                }
                else
                {
                    GridView1.EditIndex = -1;
                    bind();
                }
            }
        }
        else if (state == "email")
        {
            int id = Convert.ToInt32(GridView1.DataKeys[((e.CommandSource as LinkButton).NamingContainer as GridViewRow).RowIndex].Values["hid"].ToString());
            if (id != 0)
            {
                huashu sa = BLL.huashuManager.SearchByID(id);
                sa.hsendemail = sa.hsendemail == "1" ? "2" : "1";
                if (BLL.huashuManager.Update(sa) != 1)
                {
                    AJAXManager.Alert(this.UpdatePanel1, "修改失败");
                }
                else
                {
                    GridView1.EditIndex = -1;
                    bind();
                }
            }
        }
    }
示例#19
0
 void bind()
 {
     if (!string.IsNullOrEmpty(id))
     {
         int temp = 0;
         if (int.TryParse(id, out temp))
         {
             huashu dp = huashuManager.SearchByID(temp);
             if (dp != null)
             {
                 try
                 {
                     txt_name.Text           = dp.htitle;
                     txt_sort.Text           = dp.hsort.ToString();
                     ddl_state.SelectedValue = dp.hstate;
                 }
                 catch { }
             }
         }
     }
 }
示例#20
0
文件: Form1.cs 项目: ourstoryzj/mumu
 /// <summary>
 /// 同步数据
 /// </summary>
 /// <param name="h"></param>
 void update(huashu h)
 {
     if (h.hid == 0)
     {
         if ((!string.IsNullOrEmpty(h.htitle)) && (!string.IsNullOrEmpty(h.hcontext)))
         {
             BLL.huashuManager.Insert(h);
         }
     }
     else
     {
         if (h.hcount != 0)
         {
             huashu hh = BLL.huashuManager.SearchByID(h.hid);
             if (hh != null)
             {
                 hh.hcount = hh.hcount + h.hcount;
                 BLL.huashuManager.Update(hh);
             }
         }
     }
 }
示例#21
0
文件: HuaShu.cs 项目: ourstoryzj/mumu
 private void dgv_type_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         //DataGridView dgv_type = (DataGridView)sender;
         Common.DataGridViewHelper dgv_type = (Common.DataGridViewHelper)sender;
         //如果不是首行
         if (e.RowIndex > -1)
         {
             string colname = dgv_type.Columns[e.ColumnIndex].Name;
             huashu hs      = (huashu)dgv_type.CurrentRow.DataBoundItem;
             if (colname == "col_typestate")
             {
                 #region 修改状态
                 hs.hstate = hs.hstate == "1" ? "2" : "1";
                 BLL.huashuManager.Update(hs);
                 dgv_type.ToClearChecked();
                 bind_cb();
                 #endregion
             }
             else if (colname == "col_del")
             {
                 #region 修改状态
                 if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                 {
                     BLL.huashuManager.Delete(hs.hid);
                     dgv_type.ToAfterDelete(e.RowIndex);
                     bind_cb();
                 }
                 #endregion
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#22
0
        /// <summary>
        /// 模糊搜索
        /// </summary>
        /// <param name="startindex">开始查询位置</param>
        /// <param name="searchnum">需要查询的条数</param>
        /// <param name="key">关键词</param>
        /// <param name="state">状态</param>
        /// <param name="id">int字段</param>
        /// <param name="startdate">起始时间</param>
        /// <param name="enddate">结束时间</param>
        /// <param name="orderby">排序</param>
        /// <returns>IList<huashu></returns>
        public IList <huashu> Search(int startindex, int searchnum, string key, string state, string _type, DateTime startdate, DateTime enddate, string orderby)
        {
            string sql1 = "select * from huashu where ";
            string sql2 = string.IsNullOrEmpty(key) ? " 1=1 " : " ( hcontext like '%" + key + "%' or htitle like '%" + key + "%' or hstate like '%" + key + "%' or hsendemail like '%" + key + "%' or hremark like '%" + key + "%' )"; //删除无用字段,删除最后一个or
            string sql3 = string.IsNullOrEmpty(state) ? "" : " and hstate= '" + state + "' ";                                                                                                                                          //状态字段,无用删除
            string sql4 = string.IsNullOrEmpty(_type) ? " and hfid!= 0 " : " and hfid= " + _type + " ";
            string sql5 = startdate == new DateTime() ? "" : " and DATEDIFF('" + startdate.ToString("yyyy-MM-dd") + "',hdate)>=0 ";                                                                                                    //时间字段,无用删除
            string sql6 = enddate == new DateTime() ? "" : " and DATEDIFF('" + enddate.ToString("yyyy-MM-dd") + "',hdate)<=0 ";                                                                                                        //时间字段,无用删除
            string sql7 = string.IsNullOrEmpty(orderby) ? " order by hid desc " : " order by " + orderby;
            string sql8 = searchnum == 0 ? " " : " limit " + startindex + "," + searchnum;

            DBHelper.sqlstr = sql1 + sql2 + sql3 + sql4 + sql5 + sql6 + sql7 + sql8;
            List <huashu>   list   = new List <huashu>();
            MySqlDataReader reader = DBHelper.ExecuteReader();

            while (reader.Read())
            {
                huashu Obj = GetByReader(reader);
                list.Add(Obj);
            }
            reader.Close();
            return(list);
        }
示例#23
0
文件: HuaShu.cs 项目: ourstoryzj/mumu
        /*2020年4月14日 17:33:05新加*/

        #region 添加话术类型

        private void btn_typesave_Click(object sender, EventArgs e)
        {
            string name      = txt_typename.Text.Trim();
            string temp_sort = txt_typesort.Text.Trim();
            int    sort      = temp_sort.ToInt();
            string state     = cb_typestate.Text == "启用" ? "1" : "2";
            huashu hs        = new huashu();

            hs.hfid   = 0;
            hs.hdate  = DateTime.Now;
            hs.hsort  = sort;
            hs.hstate = state;
            hs.htitle = name;
            hs.hcount = 1;

            BLL.huashuManager.Insert(hs);
            "保存成功".ToShow();
            txt_typename.Text = "";
            txt_typesort.Text = "1000";
            cb_typestate.Text = "启用";
            bind_typelist();
            bind_cb();
        }
示例#24
0
        /// <summary>
        /// 根据表,获取一个SqlParameter数组
        /// </summary>
        /// <returns>SqlParameter[]</returns>
        public static SqlParameter[] GetSqlParameters(huashu huashuExample)
        {
            List <SqlParameter> list_param = new List <SqlParameter>();

            //if (huashuExample.hfid != 0)
            //{
            list_param.Add(new SqlParameter("@hfid", huashuExample.hfid));
            //}
            //else
            //{
            //list_param.Add(new SqlParameter("@hfid", DBNull.Value));
            //}

            if (!string.IsNullOrEmpty(huashuExample.hcontext))
            {
                list_param.Add(new SqlParameter("@hcontext", huashuExample.hcontext));
            }
            else
            {
                list_param.Add(new SqlParameter("@hcontext", DBNull.Value));
            }
            if (huashuExample.hsort != 0)
            {
                list_param.Add(new SqlParameter("@hsort", huashuExample.hsort));
            }
            else
            {
                list_param.Add(new SqlParameter("@hsort", DBNull.Value));
            }
            if (huashuExample.hcount != 0)
            {
                list_param.Add(new SqlParameter("@hcount", huashuExample.hcount));
            }
            else
            {
                list_param.Add(new SqlParameter("@hcount", DBNull.Value));
            }
            if (huashuExample.hdate != new DateTime() && huashuExample.hdate != null)
            {
                list_param.Add(new SqlParameter("@hdate", huashuExample.hdate.ToString("yyyy-MM-dd")));
            }
            else
            {
                list_param.Add(new SqlParameter("@hdate", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(huashuExample.htitle))
            {
                list_param.Add(new SqlParameter("@htitle", huashuExample.htitle));
            }
            else
            {
                list_param.Add(new SqlParameter("@htitle", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(huashuExample.hstate))
            {
                list_param.Add(new SqlParameter("@hstate", huashuExample.hstate));
            }
            else
            {
                list_param.Add(new SqlParameter("@hstate", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(huashuExample.hsendemail))
            {
                list_param.Add(new SqlParameter("@hsendemail", huashuExample.hsendemail));
            }
            else
            {
                list_param.Add(new SqlParameter("@hsendemail", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(huashuExample.hremark))
            {
                list_param.Add(new SqlParameter("@hremark", huashuExample.hremark));
            }
            else
            {
                list_param.Add(new SqlParameter("@hremark", DBNull.Value));
            }
            SqlParameter[] param = new SqlParameter[list_param.Count];
            int            index = 0;

            foreach (SqlParameter p in list_param)
            {
                param[index] = p;
                index++;
            }
            return(param);
        }
示例#25
0
 /// <summary>
 /// 插入方法
 /// </summary>
 /// <param name="huashu">huashu表实例</param>
 /// <returns>int</returns>
 public int Insert(huashu huashuExample)
 {
     DBHelper.sqlstr = "insert into  huashu (hfid,hcontext,hsort,hcount,hdate,htitle,hstate,hsendemail,hremark)values(@hfid,@hcontext,@hsort,@hcount,@hdate,@htitle,@hstate,@hsendemail,@hremark)";
     return(DBHelper.ExecuteNonQuery(GetSqlParameters(huashuExample)));
 }
示例#26
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="huashu">huashu表实例</param>
 /// <returns>int</returns>
 public int Update(huashu huashuExample)
 {
     DBHelper.sqlstr = "update huashu set hfid=@hfid,hcontext=@hcontext,hsort=@hsort,hcount=@hcount,hdate=@hdate,htitle=@htitle,hstate=@hstate,hsendemail=@hsendemail,hremark=@hremark where hid=" + huashuExample.hid;
     return(DBHelper.ExecuteNonQuery(GetSqlParameters(huashuExample)));
 }
示例#27
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="huashu">huashu表实例</param>
 /// <returns>int</returns>
 public static int Update(huashu huashuExample)
 {
     huashuExample.hdate = DateTime.Now;
     return(Service.Update(huashuExample));
 }
示例#28
0
文件: PDD.cs 项目: ourstoryzj/mumu
        string ToDo_AutoContent(string ask)
        {
            string answer = "";



            //获取拼多多自动回复话术id
            IList <huashu> list = BLL.huashuManager.Search(1, 100, "拼多多自动回复", "", "0", new DateTime(), new DateTime());
            huashu         fu   = new huashu();

            if (list.Count == 0)
            {
                return(answer);
            }
            fu = list[0];
            //根据id获取所有话术
            IList <huashu> list2 = BLL.huashuManager.Search(1, 100, "", "", fu.hid.ToString(), new DateTime(), new DateTime());

            //用于检查是否已经有该问题
            //bool isok = false;
            //判断问题中是否有答案
            foreach (huashu hs in list2)
            {
                //if (isok)
                //{
                //    break;
                //}
                //多个标题用同一个答案时,标题可以用|隔开
                string[] titles = hs.htitle.Split('|');
                foreach (string str in titles)
                {
                    if (ask.IndexOf(str) > -1)
                    {
                        //如果有答案则返回答案,如果没有就过掉,因为会有自动登记的问题
                        if (!string.IsNullOrEmpty(hs.hcontext))
                        {
                            answer = hs.hcontext;
                        }
                        //如果有问题,没有答案,设置不用再次登记,然后问题的次数+1,更新数据
                        //isok = true;
                        hs.hcount = hs.hcount + 1;
                        BLL.huashuManager.Update(hs);
                        if (hs.hsendemail == "1")
                        {
                            Manager.EmailSend("*****@*****.**", "拼多多客服:" + ask, ask);
                        }
                        //break;
                        return(answer);
                    }
                }
            }
            //如果没有答案则登记
            //如果没有答案,则记录在txt文本中,返回默认通用答案
            //if (!isok)
            //{
            int count = BLL.huashuManager.SearchNum(ask, "", fu.hid.ToString(), new DateTime(), new DateTime());

            if (count == 0)
            {
                huashu hss = new huashu();
                hss.htitle     = ask;
                hss.hcount     = 1;
                hss.hdate      = DateTime.Now;
                hss.hfid       = fu.hid;
                hss.hsort      = 10000;
                hss.hstate     = "2";
                hss.hsendemail = "2";
                BLL.huashuManager.Insert(hss);
            }

            return(answer);
        }
示例#29
0
 /// <summary>
 /// 插入方法
 /// </summary>
 /// <param name="huashu">huashu表实例</param>
 /// <returns>int</returns>
 public static int Insert(huashu huashuExample)
 {
     return(Service.Insert(huashuExample));
 }
示例#30
0
    protected void btn_save_Click(object sender, EventArgs e)
    {
        try
        {
            string _context = txt_context.Text.Trim();
            string state    = ddl_state.SelectedValue.ToString();
            string _type    = ddl_type.SelectedValue.ToString();
            string title    = txt_title.Text.Trim();
            string count    = txt_count.Text.Trim();
            string sort     = txt_sort.Text.Trim();
            int    _count   = 0;
            int    _sort    = 0;
            if (string.IsNullOrEmpty(_type))
            {
                Manager.Alert("请选择话术分类", Page);
                return;
            }
            if (!int.TryParse(count, out _count))
            {
                Manager.Alert("请输入正确的点击次数", Page);
                Manager.TextBox_Select(txt_count);
                return;
            }
            if (!int.TryParse(sort, out _sort))
            {
                Manager.Alert("请输入正确的排序", Page);
                Manager.TextBox_Select(txt_count);
                return;
            }


            huashu sp = new huashu();
            if (!string.IsNullOrEmpty(id))
            {
                sp = BLL.huashuManager.SearchByID(Convert.ToInt32(id));
            }
            else
            {
                sp.hdate = DateTime.Now;
            }
            sp.hcontext = _context;
            sp.htitle   = title;
            sp.hstate   = state;
            sp.hfid     = Convert.ToInt32(_type);
            sp.hcount   = _count;
            sp.hsort    = _sort;

            int res = 0;
            if (string.IsNullOrEmpty(id))
            {
                res = BLL.huashuManager.Insert(sp);
            }
            else
            {
                res = BLL.huashuManager.Update(sp);
            }
            if (res == 1)
            {
                Manager.Alert("保存成功", Page);
            }
            else
            {
                Manager.Alert("保存失败", Page);
            }
        }
        catch (Exception ex)
        {
            Manager.Alert(ex.ToString(), Page);
        }
        Manager.page_href_reload(Page);
    }