Пример #1
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txt_ordercode = GridView1.Rows[e.RowIndex].FindControl("txt_ordercode") as TextBox;
        TextBox txt_name      = GridView1.Rows[e.RowIndex].FindControl("txt_name") as TextBox;
        TextBox txt_account   = GridView1.Rows[e.RowIndex].FindControl("txt_account") as TextBox;
        TextBox txt_yuanyin   = GridView1.Rows[e.RowIndex].FindControl("txt_yuanyin") as TextBox;
        TextBox txt_kdcode    = GridView1.Rows[e.RowIndex].FindControl("txt_kdcode") as TextBox;

        int     id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values["shid"]);
        shouhou sh = BLL.shouhouManager.SearchByshid(id);

        sh.shordercode = txt_ordercode.Text.Trim();
        sh.shname      = txt_name.Text.Trim();
        sh.shaccount   = txt_account.Text.Trim();
        sh.shkdcode    = txt_kdcode.Text.Trim();
        sh.shyuanyin   = txt_yuanyin.Text.Trim();

        if (BLL.shouhouManager.Update(sh) != 1)
        {
            AJAXManager.Alert(this.UpdatePanel1, "修改失败");
        }
        else
        {
            GridView1.EditIndex = -1;
            bind_shouhou();
        }
    }
Пример #2
0
 void bind()
 {
     if (!string.IsNullOrEmpty(id))
     {
         int temp = 0;
         if (int.TryParse(id, out temp))
         {
             shouhou sh = shouhouManager.SearchByshid(temp);
             if (sh != null)
             {
                 try
                 {
                     txt_account.Text         = sh.shaccount;
                     txt_kdcode.Text          = sh.shkdcode;
                     txt_kdphone.Text         = sh.shytphone;
                     txt_name.Text            = sh.shname;
                     txt_ordercode.Text       = sh.shordercode;
                     txt_phone.Text           = sh.shphone;
                     txt_remark.Text          = sh.shremark;
                     txt_yuanyin.Text         = sh.shyuanyin;
                     lbl_date.Text            = sh.shdate.ToString();
                     ddl_dianpu.SelectedValue = sh.dpid.ToString();
                     ddl_state.SelectedValue  = sh.shstate;
                 }
                 catch { }
             }
         }
     }
 }
Пример #3
0
        /// <summary>
        /// 查询全部数据
        /// </summary>
        /// <returns>IList</returns>
        /*查看是否为视图*/
        public IList <shouhou> SearchAll()
        {
            DBHelper.sqlstr = "select * from shouhou  order by shdate desc ";
            List <shouhou>  list   = new List <shouhou>();
            MySqlDataReader reader = DBHelper.ExecuteReader();

            while (reader.Read())
            {
                shouhou Obj = GetByReader(reader);
                list.Add(Obj);
            }
            reader.Close();
            return(list);
        }
Пример #4
0
        /// <summary>
        /// 根据shid,查询一条数据
        /// </summary>
        /// <param name="shid"></param>
        /// <returns></returns>
        public shouhou SearchByshid(int shid)
        {
            DBHelper.sqlstr = "select * from shouhou where shid = @shid";
            MySqlParameter[] param = new MySqlParameter[] {
                new MySqlParameter("@shid", shid)
            };
            MySqlDataReader reader = DBHelper.ExecuteReader(param);
            shouhou         Obj    = null;

            if (reader.Read())
            {
                Obj = GetByReader(reader);
            }
            reader.Close();
            return(Obj);
        }
Пример #5
0
        /// <summary>
        /// 从一个MySqlDataReader里读数据
        /// </summary>
        /// <param name="Reader">MySqlDataReader</param>
        /// <returns>shouhouExample</returns>
        public static shouhou GetByReader(MySqlDataReader Reader)
        {
            shouhou shouhouExample = new shouhou();

            shouhouExample.dpid        = Reader["dpid"] == DBNull.Value ? 0 : (int)Reader["dpid"];
            shouhouExample.shaccount   = Reader["shaccount"] == DBNull.Value ? null : Reader["shaccount"].ToString();
            shouhouExample.shdate      = Reader["shdate"] == DBNull.Value ? new DateTime() : Convert.ToDateTime(Reader["shdate"]);
            shouhouExample.shid        = Reader["shid"] == DBNull.Value ? 0 : (int)Reader["shid"];
            shouhouExample.shkdcode    = Reader["shkdcode"] == DBNull.Value ? null : Reader["shkdcode"].ToString();
            shouhouExample.shname      = Reader["shname"] == DBNull.Value ? null : Reader["shname"].ToString();
            shouhouExample.shordercode = Reader["shordercode"] == DBNull.Value ? null : Reader["shordercode"].ToString();
            shouhouExample.shphone     = Reader["shphone"] == DBNull.Value ? null : Reader["shphone"].ToString();
            shouhouExample.shremark    = Reader["shremark"] == DBNull.Value ? null : Reader["shremark"].ToString();
            shouhouExample.shstate     = Reader["shstate"] == DBNull.Value ? null : Reader["shstate"].ToString();
            shouhouExample.shytphone   = Reader["shytphone"] == DBNull.Value ? null : Reader["shytphone"].ToString();
            shouhouExample.shyuanyin   = Reader["shyuanyin"] == DBNull.Value ? null : Reader["shyuanyin"].ToString();
            return(shouhouExample);
        }
Пример #6
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["shid"].ToString());
            if (id != 0)
            {
                shouhou sh = BLL.shouhouManager.SearchByshid(id);
                sh.shstate = (sh.shstate == "1" ? "2" : (sh.shstate == "2" ? "3" : "1"));
                if (BLL.shouhouManager.Update(sh) != 1)
                {
                    AJAXManager.Alert(this.UpdatePanel1, "修改失败");
                }
                else
                {
                    GridView1.EditIndex = -1;
                    bind_shouhou();
                }
            }
        }
    }
Пример #7
0
        /// <summary>
        /// 模糊查询
        /// </summary>
        /// <param name="key">关键词</param>
        /// <param name="dpid">店铺ID</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="state">状态</param>
        /// <param name="orderby">排序</param>
        /// <returns></returns>
        public IList <shouhou> Search(int s, int e, string key, int dpid, DateTime start, DateTime end, string state, string orderby)
        {
            string sql  = "select  top " + (e - s + 1).ToString() + "  * from shouhou where ";
            string sql1 = string.IsNullOrEmpty(key) ? " 1=1 " : " ( shaccount like '%" + key + "%' or  shname like '%" + key + "%'  or  shordercode like '%" + key + "%'  or  shphone like '%" + key + "%'  or  shremark like '%" + key + "%'  or  shyuanyin like '%" + key + "%'  or  shytphone like '%" + key + "%'  or  shkdcode like '%" + key + "%' ) ";
            string sql2 = dpid == 0 ? "" : " and dpid=" + dpid.ToString() + " ";
            string sql3 = string.IsNullOrEmpty(state) ? "" : " and shstate= '" + state + "' ";
            string sql4 = start == (new DateTime()) ? "" : " and datediff(d,'" + start.ToString() + "',shdate)>=0 ";
            string sql5 = end == (new DateTime()) ? "" : " and datediff(d,'" + end.ToString() + "',shdate)<=0 ";
            string sql7 = string.IsNullOrEmpty(orderby) ? " order by shdate desc " : " order by  " + orderby;
            string sql6 = s == 1 ? "" : " and shid not in ( select top " + (s - 1).ToString() + " shid from shouhou where " + sql1 + sql2 + sql3 + sql4 + sql5 + sql7 + " ) ";

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

            while (reader.Read())
            {
                shouhou Obj = GetByReader(reader);
                list.Add(Obj);
            }
            reader.Close();
            return(list);
        }
Пример #8
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                string   id      = lbl_id.Text.Trim();
                DateTime dt      = DateTime.Now;
                string   account = txt_account.Text.Trim();
                string   because = txt_because.Text.Trim();
                string   name    = txt_name.Text.Trim();
                string   phone   = txt_phone.Text.Trim();
                string   remark  = txt_remark.Text.Trim();
                string   state   = cb_state.Text == "未处理" ? "0" : (cb_state.Text == "已投诉" ? "2" : "1");
                string   dianpu  = cb_dianpu.SelectedValue != null?cb_dianpu.SelectedValue.ToString() : "";

                string code    = txt_code.Text.Trim();
                string ytphone = txt_ytphone.Text.Trim();
                string kdcode  = txt_kdcode.Text.Trim();

                shouhou sh = new shouhou();

                if (!string.IsNullOrEmpty(id))
                {
                    sh = BLL2.shouhouManager.SearchByshid(Convert.ToInt32(id));
                }

                if (string.IsNullOrEmpty(name))
                {
                    MessageBox.Show("请输入买家姓名");
                    txt_name.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(account))
                {
                    MessageBox.Show("请输入买家账号");
                    txt_account.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(phone))
                {
                    MessageBox.Show("请输入买家电话号码");
                    txt_phone.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(code))
                {
                    MessageBox.Show("请输入订单号码");
                    txt_code.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(dianpu))
                {
                    MessageBox.Show("请选择店铺");
                    cb_dianpu.Show();
                    return;
                }



                sh.shaccount   = account;
                sh.dpid        = Convert.ToInt32(dianpu);
                sh.shname      = name;
                sh.shordercode = code;
                sh.shphone     = phone;
                sh.shremark    = remark;
                sh.shstate     = state;
                sh.shyuanyin   = because;
                sh.shdate      = dt;
                sh.shytphone   = ytphone;
                sh.shkdcode    = kdcode;

                int res;
                if (string.IsNullOrEmpty(lbl_id.Text.Trim()))
                {
                    res = BLL2.shouhouManager.Insert(sh);
                    bind();
                }
                else
                {
                    res = BLL2.shouhouManager.Update(sh);
                    if (res == 1)
                    {
                        string rIndex = lbl_RowIndex.Text.Trim();
                        string cIndex = lbl_CellIndex.Text.Trim();
                        int    ci;
                        int    ri;
                        if (int.TryParse(cIndex, out ci) && int.TryParse(rIndex, out ri))
                        {
                            dataGridView1.Rows[ri].Cells[1].Value = sh.shordercode;
                            dataGridView1.Rows[ri].Cells[2].Value = sh.shaccount;
                            dataGridView1.Rows[ri].Cells[3].Value = sh.shname;
                            dataGridView1.Rows[ri].Cells[4].Value = sh.shphone;
                            dataGridView1.Rows[ri].Cells[5].Value = sh.shytphone;
                            dataGridView1.Rows[ri].Cells[6].Value = sh.shstate == "0" ? "未处理" : (sh.shstate == "1" ? "已处理" : "已投诉");
                            dataGridView1.Rows[ri].Cells[7].Value = sh.shyuanyin;
                            dataGridView1.Rows[ri].Cells[8].Value = sh.shdate.ToString();
                        }
                    }
                }
                if (res == 1)
                {
                    MessageBox.Show("保存成功");
                }
                else
                {
                    MessageBox.Show("保存失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            //bind();
            clears();
        }
Пример #9
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex != -1)
     {
         int    temp = e.ColumnIndex;
         string id   = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
         int    idid;
         if (temp == 7)
         {
             if (int.TryParse(id, out idid))
             {
                 shouhou sh = BLL2.shouhouManager.SearchByshid(idid);
                 sh.shstate = sh.shstate == "0" ? "2" : (sh.shstate == "2" ? "1" : "0");
                 if (BLL2.shouhouManager.Update(sh) == 1)
                 {
                     //bind();
                     if (sh.shstate == "0")
                     {
                         dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "未处理";
                     }
                     else if (sh.shstate == "1")
                     {
                         dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "已处理";
                     }
                     else if (sh.shstate == "2")
                     {
                         dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "已投诉";
                     }
                 }
                 else
                 {
                     MessageBox.Show("系统出错,请联系我");
                 }
             }
         }
         else if (temp == 6)
         {
             object kdcode = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
             if (kdcode != null)
             {
                 if (!string.IsNullOrEmpty(kdcode.ToString()))
                 {
                     System.Diagnostics.Process.Start("http://www.kiees.cn/yto.php?wen=" + kdcode);
                 }
             }
         }
         else
         {
             if (int.TryParse(id, out idid))
             {
                 Entity.shouhou sh = BLL2.shouhouManager.SearchByshid(idid);
                 txt_name.Text      = sh.shname;
                 txt_remark.Text    = sh.shremark;
                 lbl_id.Text        = sh.shid.ToString();
                 txt_account.Text   = sh.shaccount;
                 txt_because.Text   = sh.shyuanyin;
                 txt_code.Text      = sh.shordercode;
                 txt_phone.Text     = sh.shphone;
                 txt_remark.Text    = sh.shremark;
                 lbl_date.Text      = sh.shdate.ToString();
                 txt_ytphone.Text   = sh.shytphone;
                 lbl_CellIndex.Text = e.ColumnIndex.ToString();
                 lbl_RowIndex.Text  = e.RowIndex.ToString();
                 txt_kdcode.Text    = sh.shkdcode;
                 try
                 {
                     cb_dianpu.SelectedValue = sh.dpid;
                     cb_state.Text           = sh.shstate == "0" ? "未处理" : (sh.shstate == "1" ? "已处理" : "已投诉");
                 }
                 catch { }
             }
         }
     }
 }
Пример #10
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="shouhou">shouhou表实例</param>
 /// <returns>int</returns>
 public static int Update(shouhou shouhouExample)
 {
     return(Service.Update(shouhouExample));
 }
Пример #11
0
 /// <summary>
 /// 插入方法
 /// </summary>
 /// <param name="shouhou">shouhou表实例</param>
 /// <returns>int</returns>
 public static int Insert(shouhou shouhouExample)
 {
     return(Service.Insert(shouhouExample));
 }
Пример #12
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="shouhou">shouhou表实例</param>
 /// <returns>int</returns>
 public int Update(shouhou shouhouExample)
 {
     DBHelper.sqlstr = "update shouhou set dpid=@dpid,shaccount=@shaccount,shdate='" + shouhouExample.shdate.ToString() + "',shkdcode=@shkdcode,shname=@shname,shordercode=@shordercode,shphone=@shphone,shremark=@shremark,shstate=@shstate,shytphone=@shytphone,shyuanyin=@shyuanyin where shid=" + shouhouExample.shid;
     return(DBHelper.ExecuteNonQuery(GetSqlParameter(shouhouExample)));
 }
Пример #13
0
 /// <summary>
 /// 插入方法
 /// </summary>
 /// <param name="shouhou">shouhou表实例</param>
 /// <returns>int</returns>
 public int Insert(shouhou shouhouExample)
 {
     DBHelper.sqlstr = "insert into  shouhou (dpid,shaccount,shdate,shkdcode,shname,shordercode,shphone,shremark,shstate,shytphone,shyuanyin)values(@dpid,@shaccount,'" + shouhouExample.shdate.ToString() + "',@shkdcode,@shname,@shordercode,@shphone,@shremark,@shstate,@shytphone,@shyuanyin)";
     return(DBHelper.ExecuteNonQuery(GetSqlParameter(shouhouExample)));
 }
Пример #14
0
        /// <summary>
        /// 根据表,获取一个MySqlParameter数组
        /// </summary>
        /// <returns>MySqlParameter[]</returns>
        public static MySqlParameter[] GetSqlParameter(shouhou shouhouExample)
        {
            List <MySqlParameter> list_param = new List <MySqlParameter>();

            if (shouhouExample.dpid != 0)
            {
                list_param.Add(new MySqlParameter("@dpid", shouhouExample.dpid));
            }
            else
            {
                list_param.Add(new MySqlParameter("@dpid", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shaccount))
            {
                list_param.Add(new MySqlParameter("@shaccount", shouhouExample.shaccount));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shaccount", DBNull.Value));
            }
            if (shouhouExample.shdate != new DateTime() && shouhouExample.shdate != null)
            {
                list_param.Add(new MySqlParameter("@shdate", shouhouExample.shdate.ToString("yyyy-MM-dd")));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shdate", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shkdcode))
            {
                list_param.Add(new MySqlParameter("@shkdcode", shouhouExample.shkdcode));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shkdcode", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shname))
            {
                list_param.Add(new MySqlParameter("@shname", shouhouExample.shname));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shname", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shordercode))
            {
                list_param.Add(new MySqlParameter("@shordercode", shouhouExample.shordercode));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shordercode", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shphone))
            {
                list_param.Add(new MySqlParameter("@shphone", shouhouExample.shphone));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shphone", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shremark))
            {
                list_param.Add(new MySqlParameter("@shremark", shouhouExample.shremark));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shremark", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shstate))
            {
                list_param.Add(new MySqlParameter("@shstate", shouhouExample.shstate));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shstate", DBNull.Value));
            }

            if (!string.IsNullOrEmpty(shouhouExample.shytphone))
            {
                list_param.Add(new MySqlParameter("@shytphone", shouhouExample.shytphone));
            }
            else
            {
                list_param.Add(new MySqlParameter("@shytphone", DBNull.Value));
            }

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

            foreach (MySqlParameter p in list_param)
            {
                param[index] = p;
                index++;
            }
            return(param);
        }
Пример #15
0
    protected void btn_save_Click(object sender, EventArgs e)
    {
        try
        {
            DateTime dt      = DateTime.Now;
            string   account = txt_account.Text.Trim();
            string   because = txt_yuanyin.Text.Trim();
            string   name    = txt_name.Text.Trim();
            string   phone   = txt_phone.Text.Trim();
            string   remark  = txt_remark.Text.Trim();
            string   state   = ddl_state.SelectedValue.ToString();
            string   dianpu  = ddl_dianpu.SelectedValue != null?ddl_dianpu.SelectedValue.ToString() : "";

            string code    = txt_ordercode.Text.Trim();
            string ytphone = txt_kdphone.Text.Trim();
            string kdcode  = txt_kdcode.Text.Trim();


            shouhou sh = new shouhou();

            if (!string.IsNullOrEmpty(id))
            {
                sh = BLL.shouhouManager.SearchByshid(Convert.ToInt32(id));
            }

            //if (string.IsNullOrEmpty(name))
            //{
            //    Manager.Alert("请输入买家姓名");
            //    Manager.TextBox_Select(txt_name);
            //    return;
            //}
            if (string.IsNullOrEmpty(account))
            {
                AJAXManager.Alert(UpdatePanel1, "请输入买家账号");
                Manager.TextBox_Select(txt_account);
                return;
            }
            //if (string.IsNullOrEmpty(phone))
            //{
            //    Manager.Alert("请输入买家电话号码");
            //    Manager.TextBox_Select(txt_phone);
            //    return;
            //}
            //if (string.IsNullOrEmpty(code))
            //{
            //    Manager.Alert("请输入订单号码");
            //    Manager.TextBox_Select(txt_ordercode);
            //    return;
            //}
            if (string.IsNullOrEmpty(dianpu))
            {
                AJAXManager.Alert(UpdatePanel1, "请选择店铺");
                ddl_dianpu.Focus();
                return;
            }



            sh.shaccount   = account;
            sh.dpid        = Convert.ToInt32(dianpu);
            sh.shname      = name;
            sh.shordercode = code;
            sh.shphone     = phone;
            sh.shremark    = remark;
            sh.shstate     = state;
            sh.shyuanyin   = because;
            sh.shdate      = dt;
            sh.shytphone   = ytphone;
            sh.shkdcode    = kdcode;

            int res;
            if (string.IsNullOrEmpty(id))
            {
                res = BLL.shouhouManager.Insert(sh);
                bind();
            }
            else
            {
                res = BLL.shouhouManager.Update(sh);
            }
            if (res == 1)
            {
                AJAXManager.Alert(UpdatePanel1, "保存成功");
                if (string.IsNullOrEmpty(id))
                {
                    clear();
                }
            }
            else
            {
                AJAXManager.Alert(UpdatePanel1, "保存失败");
            }
        }
        catch (Exception ex)
        {
            AJAXManager.Alert(UpdatePanel1, ex.ToString());
        }
    }