예제 #1
0
        /// <summary>
        /// 查询的方法
        /// </summary>
        private void Query(string bmid)
        {
            try
            {
                //一页显示几行数据
                string rows = HttpContext.Current.Request["rows"];
                //当前页
                string page = HttpContext.Current.Request["page"];

                string strWhere = GetWhere();
                if (bmid == "1" || string.IsNullOrEmpty(bmid))
                {
                    bmid = "1";
                }

                //使用存储过程及临时表实现递归方式列表
                SqlParameter[] parms =
                {
                    new SqlParameter("@id", bmid)
                };
                SqlHelper.ExeNonQuery("get_bmzl2", CommandType.StoredProcedure, parms);

                DataSet   duser = SqlHelper.GetList("v_ygzl", "*", "id", int.Parse(rows), int.Parse(page), false, false, strWhere);
                DataTable dt1   = duser.Tables[0];
                //获取数据源
                DataTable dt  = SqlHelper.GetTable("select * from v_ygzl where " + strWhere + " order by cygbh asc");
                string    str = string.Empty;
                //将数据转换成json格式
                str = JSonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
                //str = JSonHelper.SerializeObject(dt1);
                //str ="{ " + "\"total\":" + dt.Rows.Count + "," + "\"rows\":" + str + "}";
                HttpContext.Current.Response.Write(str);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                StringBuilder sb = new StringBuilder("");
                DataTable     dt = new DataTable();
                dt = SqlHelper.GetTable("select * from dwb");

                if (dt.Rows.Count > 0)
                {
                    DataRow[] CRow = dt.Select("1=1");

                    if (CRow.Length > 0)
                    {
                        sb.Append("[");

                        for (int i = 0; i < CRow.Length; i++)
                        {
                            sb.Append("{\"id\":\"" + CRow[i]["id"].ToString() + "\",\"text\":\"" + CRow[i]["cdw"].ToString() + "\"},");
                        }

                        sb.Replace(',', ' ', sb.Length - 1, 1);

                        sb.Append("]},");

                        sb = sb.Remove(sb.Length - 2, 2);
                    }


                    context.Response.Write(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                string sbid = context.Request["sbid"];

                //一页显示几行数据
                string rows = HttpContext.Current.Request["rows"];
                //当前页
                string page = HttpContext.Current.Request["page"];

                string strWhere = "";

                if (string.IsNullOrEmpty(sbid))
                {
                    strWhere = " 1=1";
                }
                else
                {
                    strWhere = " isbid=" + sbid;
                }

                DataSet   duser = SqlHelper.GetList("v_sbzl_dj", "*", "id", int.Parse(rows), int.Parse(page), false, false, strWhere);
                DataTable dt1   = duser.Tables[0];
                //获取数据源
                DataTable dt  = SqlHelper.GetTable("select * from v_sbzl_dj where " + strWhere);
                string    str = string.Empty;
                //将数据转换成json格式
                str = JSonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
                HttpContext.Current.Response.Write(str);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #4
0
        private void search()
        {
            try
            {
                //一页显示几行数据
                string rows = HttpContext.Current.Request["rows"];
                //当前页
                string page = HttpContext.Current.Request["page"];

                string strWhere = "";

                string rq1     = HttpContext.Current.Request["rq1"];
                string rq2     = HttpContext.Current.Request["rq2"];
                string proline = HttpContext.Current.Request["proline"];
                string txt     = HttpContext.Current.Request["txt"];

                strWhere = " drq>='" + rq1 + "' and drq<='" + rq2 + "'  and csxnr like '%" + txt + "%'";

                if (proline != "")
                {
                    strWhere = strWhere + " and cscx='" + proline + "'";
                }

                DataSet   duser = SqlHelper.GetList("v_zxdbsx", "*", "id", int.Parse(rows), int.Parse(page), false, true, strWhere);
                DataTable dt1   = duser.Tables[0];
                //获取数据源
                DataTable dt  = SqlHelper.GetTable("select * from v_zxdbsx where " + strWhere);
                string    str = string.Empty;
                //将数据转换成json格式
                str = JSonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
                HttpContext.Current.Response.Write(str);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #5
0
 /// <summary>
 /// 选择站板名称
 /// </summary>
 private void Select()
 {
     try
     {
         string    bid = HttpContext.Current.Request["data"];
         DataTable dt  = new DataTable();
         dt = SqlHelper.GetTable("select * from v_zbsz where bid=" + bid);
         if (dt.Rows.Count > 0)
         {
             string cData = dt.Rows[0]["czdz"] + "&" + dt.Rows[0]["czmc"] + "*" + dt.Rows[0]["cbdz"] + "," + dt.Rows[0]["cbmc"];
             HttpContext.Current.Response.Write(cData);
         }
         else
         {
             HttpContext.Current.Response.Write("null");
         }
     }
     catch (Exception ex)
     {
         sys e = new sys();
         e.GetLog(ex);
     }
 }
예제 #6
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         context.Response.ContentType = "text/plain";
         string sbbh  = context.Request["data"];
         string value = "";
         if (!string.IsNullOrEmpty(sbbh))
         {
             DataTable dt = SqlHelper.GetTable("select * from v_sbzl where csbbh='" + sbbh + "'");
             if (dt.Rows.Count > 0)
             {
                 value = dt.Rows[0]["csbmc"].ToString() + "&" + dt.Rows[0]["cscx"].ToString() + "," + dt.Rows[0]["csszy"].ToString();
             }
         }
         context.Response.Write(value);
     }
     catch (Exception ex)
     {
         sys e = new sys();
         e.GetLog(ex);
     }
 }
예제 #7
0
 //删除的方法
 private void Del()
 {
     try
     {
         //获取到选中行的id
         string id    = HttpContext.Current.Request["id"];
         int    count = 0;
         count = SqlHelper.DelData("dbsxb", id);
         if (count > 0)
         {
             HttpContext.Current.Response.Write("共删除了" + count + "条数据");
         }
         else
         {
             HttpContext.Current.Response.Write("error");
         }
     }
     catch (Exception ex)
     {
         sys e = new sys();
         e.GetLog(ex);
     }
 }
예제 #8
0
        private void stop()
        {
            try
            {
                DataTable dt = SqlHelper.GetTable("select * from scszb");
                if (dt.Rows.Count > 0)
                {
                    RunBat(dt.Rows[0]["clj"].ToString() + "\\stop.bat");
                    HttpContext.Current.Response.Write("停止服务成功!");
                }
                else
                {
                    HttpContext.Current.Response.Write("停止服务失败!");
                }

                dt = null;
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #9
0
        //初始化
        private void query()
        {
            try
            {
                DataTable dt        = SqlHelper.GetTable("select * from wxgzh");
                string    appid     = "";
                string    appsecret = "";

                if (dt.Rows.Count > 0)
                {
                    appid     = dt.Rows[0]["appid"].ToString();
                    appsecret = dt.Rows[0]["appsecret"].ToString();
                }
                dt = null;

                HttpContext.Current.Response.Write(appid + "&" + appsecret);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                StringBuilder sb  = new StringBuilder("");
                DataTable     dt  = new DataTable();
                string        zid = context.Request ["zid"];
                dt = SqlHelper.GetTable("select * from bszb where izid=" + zid + " order by cbdz");

                if (dt.Rows.Count > 0)
                {
                    DataRow[] CRow = dt.Select("1=1");

                    if (CRow.Length > 0)
                    {
                        sb.Append("[");

                        for (int j = 0; j < CRow.Length; j++)
                        {
                            sb.Append("{\"id\":\"" + CRow[j]["id"].ToString() + "\",\"text\":\"" + CRow[j]["cbdz"].ToString() + "~~" + CRow[j]["cbmc"].ToString() + "\",\"state\":\"open\"},");
                        }

                        sb.Replace(',', ' ', sb.Length - 1, 1);

                        sb.Append("]");
                    }

                    context.Response.Write(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #11
0
        /// <summary>
        /// 载入数据
        /// </summary>
        private void Load_Wx(string strId)
        {
            try
            {
                if (string.IsNullOrEmpty(strId))
                {
                    return;
                }

                DataTable dt = SqlHelper.GetTable("select * from v_wxjl where id=" + strId);
                if (dt.Rows.Count > 0)
                {
                    string str = "";
                    str = dt.Rows[0]["cgdh"].ToString();
                    str = str + "&" + dt.Rows[0]["drq"].ToString();
                    str = str + "&" + dt.Rows[0]["csbbh"].ToString();
                    str = str + "&" + dt.Rows[0]["csbmc"].ToString();
                    str = str + "&" + dt.Rows[0]["cscx"].ToString();
                    str = str + "&" + dt.Rows[0]["czy"].ToString();
                    str = str + "&" + dt.Rows[0]["dgzsj"].ToString();
                    str = str + "&" + dt.Rows[0]["cgzlx"].ToString();
                    str = str + "&" + dt.Rows[0]["cgzxx"].ToString();
                    str = str + "&" + dt.Rows[0]["cclfs"].ToString();
                    str = str + "&" + dt.Rows[0]["cwxr"].ToString();
                    str = str + "&" + dt.Rows[0]["cwxnr"].ToString();
                    str = str + "&" + dt.Rows[0]["dwxkssj"].ToString();
                    str = str + "&" + dt.Rows[0]["dwcsj"].ToString();
                    str = str + "&" + dt.Rows[0]["cbz"].ToString();
                    HttpContext.Current.Response.Write(str);
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #12
0
//        调用方法
// List<Person> appResult = JSONToObject<List<Person>>(@"[{""id"":0,""email"":""*****@*****.**"",""age"":0},{""id"":1,""email"":""*****@*****.**"",""age"":2},{""id"":2,""email"":""*****@*****.**"",""age"":4},{""id"":3,""email"":""*****@*****.**"",""age"":6},{""id"":4,""email"":""*****@*****.**"",""age"":8}]");

//     for(int i = 0;i<appResult.Count;i++)
//      输出(appResult[i].id);

////定义
//   public class Person
//   {
//     public int id { set; get; }
//     public String email { set; get; }
//     public int age { set; get; }
//   }
//   public static T JSONToObject<T>(string jsonText)
//   {
//     System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
//     try
//     {
//       return jss.Deserialize<T>(jsonText);
//     }
//     catch (Exception ex)
//     {
//       throw new Exception("JSONHelper.JSONToObject(): " + ex.Message);
//     }
//   }



        /// <summary>
        /// 获取企业号的accessToken
        /// </summary>
        /// <param name="corpid">企业号ID</param>
        /// <param name="corpsecret">管理组密钥</param>
        /// <returns></returns>
        public string GetQYAccessToken(string corpid, string corpsecret)
        {
            string accessToken = "";

            string getAccessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";

            string respText = "";

            //获取josn数据
            string url = string.Format(getAccessTokenUrl, corpid, corpsecret);

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (Stream resStream = response.GetResponseStream())
            {
                StreamReader reader = new StreamReader(resStream, Encoding.Default);
                respText = reader.ReadToEnd();
                resStream.Close();
            }

            try
            {
                JavaScriptSerializer        Jss     = new JavaScriptSerializer();
                Dictionary <string, object> respDic = (Dictionary <string, object>)Jss.DeserializeObject(respText);

                //通过键access_token获取值
                accessToken = respDic["access_token"].ToString();
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }

            return(accessToken);
        }
예제 #13
0
        /// <summary>
        /// 载入数据
        /// </summary>
        private void Load_Tj(string strId)
        {
            try
            {
                if (string.IsNullOrEmpty(strId))
                {
                    return;
                }

                DataTable dt = SqlHelper.GetTable("select * from v_tjjl where id=" + strId);
                if (dt.Rows.Count > 0)
                {
                    string str = "";
                    str = dt.Rows[0]["cdh"].ToString();
                    str = str + "&" + dt.Rows[0]["dtxrq"].ToString();
                    str = str + "&" + dt.Rows[0]["csbbh"].ToString();
                    str = str + "&" + dt.Rows[0]["csbmc"].ToString();
                    str = str + "&" + dt.Rows[0]["cscx"].ToString();
                    str = str + "&" + dt.Rows[0]["csszy"].ToString();
                    str = str + "&" + dt.Rows[0]["dkjrq"].ToString();
                    str = str + "&" + dt.Rows[0]["dtjrq"].ToString();
                    str = str + "&" + dt.Rows[0]["ctjzl"].ToString();
                    str = str + "&" + dt.Rows[0]["cxxms"].ToString();
                    str = str + "&" + dt.Rows[0]["cjjfa"].ToString();
                    str = str + "&" + dt.Rows[0]["cyyfx"].ToString();
                    str = str + "&" + dt.Rows[0]["cgsdc"].ToString();
                    str = str + "&" + dt.Rows[0]["ctjr"].ToString();
                    str = str + "&" + dt.Rows[0]["cbz"].ToString();
                    HttpContext.Current.Response.Write(str);
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #14
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                StringBuilder sb = new StringBuilder("");
                DataTable     dt = new DataTable();
                dt = SqlHelper.GetTable("select * from gzxxb order by pid");

                if (dt.Rows.Count > 0)
                {
                    sb.Append(GetDataString(dt, "0"));

                    sb = sb.Remove(sb.Length - 2, 2);
                }

                context.Response.Write(sb.ToString());
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #15
0
        /// <summary>
        /// 查询的方法
        /// </summary>
        private void Query(string ygid)
        {
            try
            {
                string    userid = HttpContext.Current.Request.Form["userid"];
                DataTable dt     = new DataTable();
                dt = SqlHelper.GetTable("select depid from DataAuthority where userid='" + userid + "'");
                string depid = "";
                if (dt.Rows.Count > 0)
                {
                    depid = dt.Rows[0][0].ToString();
                }

                //string str = string.Empty;
                ////将数据转换成json格式
                //str = JSonHelper.CreateJsonParameters(dt, true, dt.Rows.Count);
                HttpContext.Current.Response.Write(depid);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #16
0
        //删除的方法
        private void Del()
        {
            try
            {
                //获取到选中行的id
                string id = HttpContext.Current.Request["id"];

                string    sSql = "";
                DataTable dt   = new DataTable();

                //判断处理方式中是否存在
                sSql = "select * from wxjlb where iclfs=" + id;
                dt   = SqlHelper.GetTable(sSql);
                if (dt.Rows.Count > 0)
                {
                    HttpContext.Current.Response.Write("1");
                    return;
                }

                int count = 0;
                count = SqlHelper.DelData("clfsb", id);
                if (count > 0)
                {
                    HttpContext.Current.Response.Write("共删除了" + count + "条数据");
                }
                else
                {
                    HttpContext.Current.Response.Write("error");
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                StringBuilder sb = new StringBuilder("");
                DataTable     dt = new DataTable();
                dt = SqlHelper.GetTable("select * from zszb order by czdz");

                if (dt.Rows.Count > 0)
                {
                    DataRow[] CRow = dt.Select("1=1");

                    if (CRow.Length > 0)
                    {
                        sb.Append("[{\"id\":\"\",\"text\":\"站信息\",\"children\":[");

                        for (int i = 0; i < CRow.Length; i++)
                        {
                            sb.Append("{\"id\":\"" + CRow[i]["id"].ToString() + "\",\"text\":\"" + CRow[i]["czdz"].ToString() + "~~" + CRow[i]["czmc"].ToString() + "\",\"state\":\"closed\"},");
                        }

                        sb.Replace(',', ' ', sb.Length - 1, 1);

                        sb.Append("]}]");
                    }

                    context.Response.Write(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #18
0
        public void Backup()
        {
            try
            {
                //根据连接字符串获取数据库名称
                string strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString;
                string db      = strConn.Split(';')[1];
                string dbname  = db.Split('=')[1];
                string bkpath  = HttpContext.Current.Request["data"];      //使用单个符号“\”提示常量中有换行符

                //自动创建文件夹
                FileInfo fi = new FileInfo(bkpath);
                var      di = fi.Directory;
                if (!di.Exists)
                {
                    di.Create();
                }

                SqlConnection con = new SqlConnection(SqlHelper.conString);
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = "exec p_backupdb '" + dbname + "','" + bkpath + "'";
                cmd.ExecuteNonQuery();
                con.Close();
                con.Dispose();

                HttpContext.Current.Response.Write("数据备份成功!");
            }

            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #19
0
        //初始化
        private void query()
        {
            try
            {
                DataTable dt      = SqlHelper.GetTable("select * from scszb");
                string    cscsjjg = "";
                string    cscqssj = "";
                string    cscjssj = "";
                if (dt.Rows.Count > 0)
                {
                    cscsjjg = dt.Rows[0]["cscsjjg"].ToString();
                    cscqssj = dt.Rows[0]["cscqssj"].ToString();
                    cscjssj = dt.Rows[0]["cscjssj"].ToString();
                }
                dt = null;

                HttpContext.Current.Response.Write(cscsjjg + "&" + cscqssj + "," + cscjssj);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #20
0
        private void Edit()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                //遍历获取传递过来的字符串
                foreach (string s in HttpContext.Current.Request.Form.AllKeys)
                {
                    sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]);
                }
                string   ss  = sb.ToString();
                string[] str = ss.Split('&');
                int      id  = int.Parse(str[0].Split('=')[1]);

                string csbbh = str[1].Split('=')[1];

                if (string.IsNullOrEmpty(csbbh) || csbbh == "")
                {
                    HttpContext.Current.Response.Write("1");
                    return;
                }
                DataTable dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "' and id<>" + id);
                if (dt.Rows.Count == 0)
                {
                    HttpContext.Current.Response.Write("2");
                    return;
                }

                string rq = "";
                sys    ex = new sys();
                if (ex.isDate(str[5].Split('=')[1]) == true)
                {
                    rq = str[5].Split('=')[1];
                }

                string csxlx = str[6].Split('=')[1];
                string cczy  = str[9].Split('=')[1];
                string csxnr = str[10].Split('=')[1];
                string cclfs = str[11].Split('=')[1];
                string cdbr  = str[7].Split('=')[1];
                string czt   = str[8].Split('=')[1];

                SqlParameter[] parms =
                {
                    new SqlParameter("@rq",   rq),
                    new SqlParameter("@sbbh", csbbh),
                    new SqlParameter("@sxlx", csxlx),
                    new SqlParameter("@sxnr", csxnr),
                    new SqlParameter("@clfs", cclfs),
                    new SqlParameter("@dbr",  cdbr),
                    new SqlParameter("@czy",  cczy),
                    new SqlParameter("@zt",   czt),
                    new SqlParameter("@id",   id)
                };
                bool flag = SqlHelper.ExeNonQuery("update_dbsx", CommandType.StoredProcedure, parms);
                if (flag)
                {
                    HttpContext.Current.Response.Write("修改成功!");
                }
                else
                {
                    HttpContext.Current.Response.Write("修改失败!");
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #21
0
        /// <summary>
        /// 高级查询
        /// </summary>
        /// <returns></returns>
        public void Search()
        {
            try
            {
                //一页显示几行数据
                string rows = HttpContext.Current.Request["rows"];
                //当前页
                string page = HttpContext.Current.Request["page"];

                string   value = HttpContext.Current.Request["data"];
                string[] strr  = value.Split('&');

                string s_where = "1=1";
                string s_csbbh = strr[0].Split('=')[1];
                if (s_csbbh.Trim().Length > 0)
                {
                    s_where = s_where + " and csbbh  like '%" + s_csbbh + "%'";
                }

                string s_csbmc = strr[1].Split('=')[1];
                if (s_csbmc.Trim().Length > 0)
                {
                    s_where = s_where + " and csbmc like '%" + s_csbmc + "%'";
                }

                string s_csszy = strr[2].Split('=')[1];
                if (s_csszy.Trim().Length > 0)
                {
                    s_where = s_where + " and izyid='" + s_csszy + "'";
                }

                string s_cscx = strr[3].Split('=')[1];
                if (s_cscx.Trim().Length > 0)
                {
                    s_where = s_where + " and iscxid = '" + s_cscx + "'";
                }

                string s_cjllx = strr[4].Split('=')[1];
                if (s_cjllx.Trim().Length > 0)
                {
                    s_where = s_where + " and typename like '%" + s_cjllx + "%'";
                }

                string s_cdjr = strr[5].Split('=')[1];
                if (s_cdjr.Trim().Length > 0)
                {
                    s_where = s_where + " and cdjr like '%" + s_cdjr + "%'";
                }


                sys ex = new sys();

                string s_dtp1 = strr[6].Split('=')[1];
                if (ex.isDate(s_dtp1) == true)
                {
                    s_dtp1 = s_dtp1.Replace("+", " ");          //替换+为空,日期提交后格式为:2016-05-30+10:00:00

                    if (s_dtp1.Trim().Length > 0)
                    {
                        s_where = s_where + " and drq>= '" + s_dtp1 + "'";
                    }
                }

                string s_dtp2 = strr[7].Split('=')[1];
                if (ex.isDate(s_dtp2) == true)
                {
                    s_dtp2 = s_dtp2.Replace("+", " ");

                    if (s_dtp2.Trim().Length > 0)
                    {
                        s_where = s_where + " and drq<= '" + s_dtp2 + "'";
                    }
                }

                DataSet   duser = SqlHelper.GetList("v_djjl", "*", "id", int.Parse(rows), int.Parse(page), false, true, s_where);
                DataTable dt1   = duser.Tables[0];
                //获取数据源
                DataTable dt  = SqlHelper.GetTable("select * from v_djjl where " + s_where + " order by drq desc");
                string    str = string.Empty;
                //将数据转换成json格式
                str = JSonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
                HttpContext.Current.Response.Write(str);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #22
0
        private void Edit()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                //遍历获取传递过来的字符串
                foreach (string s in HttpContext.Current.Request.Form.AllKeys)
                {
                    sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]);
                }
                string   ss  = sb.ToString();
                string[] str = ss.Split('&');
                int      id  = int.Parse(str[0].Split('=')[1]);
                sys      ex  = new sys();
                string   drq = "";
                if (ex.isDate(str[1].Split('=')[1]) == true)
                {
                    drq = str[1].Split('=')[1];
                }
                string dx    = str[2].Split('=')[1];
                string cdxmc = "";
                if (str[3].Split('=')[1].Trim().Length > 0)
                {
                    cdxmc = str[3].Split('=')[1];
                }
                if (str[4].Split('=')[1].Trim().Length > 0)
                {
                    cdxmc = str[4].Split('=')[1];
                }
                string cjl  = str[5].Split('=')[1];
                string cczy = str[6].Split('=')[1];


                string        strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString;
                SqlConnection con     = new SqlConnection(strConn);
                con.Open();

                SqlTransaction sqltra = con.BeginTransaction(); //开始事务
                SqlCommand     cmd    = new SqlCommand();
                cmd.Connection  = con;                          //获取数据连接
                cmd.Transaction = sqltra;                       //,在执行SQL时

                SqlParameter[] parm =
                {
                    new SqlParameter("@rq",   drq),
                    new SqlParameter("@dx",   dx),
                    new SqlParameter("@dxmc", cdxmc),
                    new SqlParameter("@jl",   cjl),
                    new SqlParameter("@czy",  cczy),
                    new SqlParameter("@id",   id)
                };

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "update_gcstz";
                foreach (SqlParameter p in parm)
                {
                    cmd.Parameters.Add(p);
                }
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                //临时工程师通知
                string sql = "delete from tmp_gcstzb where id=" + id;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;
                cmd.ExecuteNonQuery();

                //临时表
                string[] strr  = cdxmc.Split(',');
                int      len   = strr.Length;
                string   value = "";

                if (len > 0)
                {
                    //员工分割
                    for (int i = 0; i < len; i++)
                    {
                        value = strr[i].Split('-')[0];

                        SqlParameter[] parms =
                        {
                            new SqlParameter("@id",   id),
                            new SqlParameter("@rq",   drq),
                            new SqlParameter("@dx",   dx),
                            new SqlParameter("@dxmc", value),
                            new SqlParameter("@jl",   cjl),
                            new SqlParameter("@czy",  cczy)
                        };

                        SqlCommand cmds = new SqlCommand();
                        cmds.Connection  = con;    //获取数据连接
                        cmds.Transaction = sqltra; //,在执行SQL时
                        cmds.CommandType = CommandType.StoredProcedure;
                        cmds.CommandText = "insert_tmp_gcstz";
                        foreach (SqlParameter p in parms)
                        {
                            cmds.Parameters.Add(p);
                        }
                        cmds.ExecuteNonQuery();
                        cmds.Dispose();
                    }
                }

                sqltra.Commit();        //提交事务

                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                con.Dispose();

                HttpContext.Current.Response.Write("修改成功!");
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #23
0
        //添加
        private void Add()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                //遍历获取传递过来的字符串
                foreach (string s in HttpContext.Current.Request.Form.AllKeys)
                {
                    sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]);
                }
                string   ss  = sb.ToString();
                string[] str = ss.Split('&');
                sys      ex  = new sys();
                string   drq = "";

                //查找id最大值
                Int64     id = 0;
                DataTable dt = new DataTable();
                dt = SqlHelper.GetTable("select max(id) as maxid from gcstzb");
                if (dt.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(dt.Rows[0]["maxid"].ToString()))
                    {
                        id = Int64.Parse(dt.Rows[0]["maxid"].ToString()) + 1;
                    }
                    else
                    {
                        id = 1;
                    }
                }
                else
                {
                    id = 1;
                }
                dt = null;

                if (ex.isDate(str[1].Split('=')[1]) == true)
                {
                    drq = str[1].Split('=')[1];
                }
                string dx    = str[2].Split('=')[1];
                string cdxmc = "";
                if (str[3].Split('=')[1].Trim().Length > 0)
                {
                    cdxmc = str[3].Split('=')[1];
                }
                if (str[4].Split('=')[1].Trim().Length > 0)
                {
                    cdxmc = str[4].Split('=')[1];
                }
                string cjl  = str[5].Split('=')[1];
                string cczy = str[6].Split('=')[1];

                string        strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString;
                SqlConnection con     = new SqlConnection(strConn);
                con.Open();

                SqlTransaction sqltra = con.BeginTransaction(); //开始事务
                SqlCommand     cmd    = new SqlCommand();
                cmd.Connection  = con;                          //获取数据连接
                cmd.Transaction = sqltra;                       //,在执行SQL时

                SqlParameter[] parm =
                {
                    new SqlParameter("@id",   id),
                    new SqlParameter("@rq",   drq),
                    new SqlParameter("@dx",   dx),
                    new SqlParameter("@dxmc", cdxmc),
                    new SqlParameter("@jl",   cjl),
                    new SqlParameter("@czy",  cczy)
                };

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "insert_gcstz";
                foreach (SqlParameter p in parm)
                {
                    cmd.Parameters.Add(p);
                }
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                //临时表
                string[] strr  = cdxmc.Split(',');
                int      len   = strr.Length;
                string   value = "";

                if (len > 0)
                {
                    //员工分割
                    for (int i = 0; i < len; i++)
                    {
                        value = strr[i].Split('-')[0];

                        SqlParameter[] parms =
                        {
                            new SqlParameter("@id",   id),
                            new SqlParameter("@rq",   drq),
                            new SqlParameter("@dx",   dx),
                            new SqlParameter("@dxmc", value),
                            new SqlParameter("@jl",   cjl),
                            new SqlParameter("@czy",  cczy)
                        };

                        SqlCommand cmds = new SqlCommand();
                        cmds.Connection  = con;    //获取数据连接
                        cmds.Transaction = sqltra; //,在执行SQL时
                        cmds.CommandType = CommandType.StoredProcedure;
                        cmds.CommandText = "insert_tmp_gcstz";
                        foreach (SqlParameter p in parms)
                        {
                            cmds.Parameters.Add(p);
                        }
                        cmds.ExecuteNonQuery();
                        cmds.Dispose();
                    }
                }

                sqltra.Commit();        //提交事务

                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                con.Dispose();

                HttpContext.Current.Response.Write("添加成功!");
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #24
0
        /// <summary>
        /// 查询的方法
        /// </summary>
        private void Query()
        {
            try
            {
                //一页显示几行数据
                string rows = HttpContext.Current.Request["rows"];
                //当前页
                string page = HttpContext.Current.Request["page"];

                string state = HttpContext.Current.Request["state"];
                if (string.IsNullOrEmpty(state))
                {
                    HttpContext.Current.Response.Write("{ \"total\":0,\"rows\":[]");
                    return;
                }

                string strWhere = "1=1";

                string qsrq = HttpContext.Current.Request["qsrq"];
                if (!string.IsNullOrEmpty(qsrq))
                {
                    strWhere = strWhere + " and drq>='" + qsrq + "'";
                }

                string jzrq = HttpContext.Current.Request["jzrq"];
                if (!string.IsNullOrEmpty(jzrq))
                {
                    strWhere = strWhere + " and drq<='" + jzrq + "'";
                }

                string ckey  = HttpContext.Current.Request["ckey"];
                string ctext = HttpContext.Current.Request["cmemo"];

                if (!string.IsNullOrEmpty(ckey))
                {
                    switch (ckey)
                    {
                    case "对象":
                        strWhere = strWhere + " and cdx like '%" + ctext + "%'";
                        break;

                    case "对象名称":
                        strWhere = strWhere + " and cdxmc like '%" + ctext + "%'";
                        break;

                    case "记录":
                        strWhere = strWhere + " and cjl like '%" + ctext + "%'";
                        break;

                    case "制单人":
                        strWhere = strWhere + " and cczy like '%" + ctext + "%'";
                        break;
                    }
                }

                DataSet   duser = SqlHelper.GetList("v_gcstz", "*", "id", int.Parse(rows), int.Parse(page), false, true, strWhere);
                DataTable dt1   = duser.Tables[0];
                //获取数据源
                DataTable dt  = SqlHelper.GetTable("select * from v_gcstz where " + strWhere + " order by drq desc");
                string    str = string.Empty;
                //将数据转换成json格式
                str = JSonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
                HttpContext.Current.Response.Write(str);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #25
0
        private void Edit()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                //遍历获取传递过来的字符串
                foreach (string s in HttpContext.Current.Request.Form.AllKeys)
                {
                    sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]);
                }
                string    ss  = sb.ToString();
                string[]  str = ss.Split('&');
                int       id  = int.Parse(str[0].Split('=')[1]);
                DataTable dt  = new DataTable();

                string csbbh = str[2].Split('=')[1];  //设备编号

                if (string.IsNullOrEmpty(csbbh))
                {
                    HttpContext.Current.Response.Write("1");
                    return;
                }

                string isbid = "";
                dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "' and id<>" + id);
                if (dt.Rows.Count == 0)
                {
                    HttpContext.Current.Response.Write("2");
                    return;
                }
                else
                {
                    isbid = dt.Rows[0]["id"].ToString();
                }

                string cnr = str[1].Split('=')[1];  //内容

                if (cnr == "")
                {
                    HttpContext.Current.Response.Write("3");
                    return;
                }

                SqlParameter[] parms =
                {
                    new SqlParameter("@sbid", isbid),
                    new SqlParameter("@nr",   cnr),
                    new SqlParameter("@id",   id)
                };
                bool flag = SqlHelper.ExeNonQuery("update_wdgl", CommandType.StoredProcedure, parms);
                if (flag)
                {
                    HttpContext.Current.Response.Write("修改成功!");
                }
                else
                {
                    HttpContext.Current.Response.Write("修改失败!");
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #26
0
        private void Edit()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                //遍历获取传递过来的字符串
                foreach (string s in HttpContext.Current.Request.Form.AllKeys)
                {
                    sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]);
                }
                string   ss  = sb.ToString();
                string[] str = ss.Split('&');
                int      id  = int.Parse(str[0].Split('=')[1]);
                string   cdh = str[1].Split('=')[1];
                if (string.IsNullOrEmpty(cdh))
                {
                    HttpContext.Current.Response.Write("1");
                    return;
                }

                DataTable dt = new DataTable();
                dt = SqlHelper.GetTable("select * from xhqzb where cdh='" + cdh + "'");
                if (dt.Rows.Count == 0)
                {
                    HttpContext.Current.Response.Write("2");
                    return;
                }

                string dsj = "";
                sys    ex  = new sys();
                if (ex.isDate(str[2].Split('=')[1]) == true)
                {
                    dsj = str[2].Split('=')[1].Replace("+", " ");
                }

                string csbbh = str[3].Split('=')[1];
                if (string.IsNullOrEmpty(csbbh))
                {
                    HttpContext.Current.Response.Write("3");
                    return;
                }

                string isbid = "";
                dt = SqlHelper.GetTable("select * from sbzlb where deviceid='" + csbbh + "'");
                if (dt.Rows.Count == 0)
                {
                    HttpContext.Current.Response.Write("4");
                    return;
                }
                else
                {
                    isbid = dt.Rows[0]["id"].ToString();
                }

                string csbmc = str[4].Split('=')[1];

                if (string.IsNullOrEmpty(csbmc))
                {
                    HttpContext.Current.Response.Write("5");
                    return;
                }
                string cscx = str[5].Split('=')[1];
                string iyz  = str[6].Split('=')[1];
                string iqzz = str[7].Split('=')[1];
                string cyy  = str[8].Split('=')[1];
                string czt  = str[9].Split('=')[1];
                string czdr = str[10].Split('=')[1];
                if (string.IsNullOrEmpty(czdr) || czdr.Trim() == "")
                {
                    HttpContext.Current.Response.Write("9");
                    return;
                }
                string cczy  = str[11].Split('=')[1];
                string cfzry = str[12].Split('=')[1];
                string cbz   = str[13].Split('=')[1];

                string        strConn = ConfigurationManager.ConnectionStrings["sqlCon"].ConnectionString;
                SqlConnection con     = new SqlConnection(strConn);
                con.Open();

                SqlTransaction sqltra = con.BeginTransaction(); //开始事务
                SqlCommand     cmd    = new SqlCommand();
                cmd.Connection  = con;                          //获取数据连接
                cmd.Transaction = sqltra;                       //,在执行SQL时

                SqlParameter[] parms =
                {
                    new SqlParameter("@dh",   cdh),
                    new SqlParameter("@sj",   dsj),
                    new SqlParameter("@sbid", isbid),
                    new SqlParameter("@yz",   iyz),
                    new SqlParameter("@qzz",  iqzz),
                    new SqlParameter("@yy",   cyy),
                    new SqlParameter("@zt",   czt),
                    new SqlParameter("@zdr",  czdr),
                    new SqlParameter("@bz",   cbz),
                    new SqlParameter("@fzry", cfzry),
                    new SqlParameter("@czy",  cczy),
                    new SqlParameter("@id",   id)
                };
                cmd.CommandText = "update_xhqz";
                cmd.CommandType = CommandType.StoredProcedure;
                foreach (SqlParameter p in parms)
                {
                    cmd.Parameters.Add(p);
                }
                cmd.ExecuteNonQuery();


                //履历表
                SqlParameter[] parm_llb =
                {
                    new SqlParameter("@xmid", id),
                    new SqlParameter("@sbid", isbid),
                    new SqlParameter("@zysj", dsj),
                    new SqlParameter("@zyxm", "强制"),
                    new SqlParameter("@zyry", czdr),
                    new SqlParameter("@czy",  cczy),
                    new SqlParameter("@zynr", cyy)
                };

                SqlCommand com = new SqlCommand();
                com.Connection  = con;    //获取数据连接
                com.Transaction = sqltra; //,在执行SQL时
                com.CommandText = "update_llb";
                com.CommandType = CommandType.StoredProcedure;
                foreach (SqlParameter p in parm_llb)
                {
                    com.Parameters.Add(p);
                }
                com.ExecuteNonQuery();

                sqltra.Commit();        //提交事务

                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                con.Dispose();

                HttpContext.Current.Response.Write("修改成功!");
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #27
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                string        sbid = context.Request["sbid"];
                StringBuilder sb   = new StringBuilder("");
                if (!string.IsNullOrEmpty(sbid))
                {
                    DataTable dt = new DataTable();
                    dt = SqlHelper.GetTable("select * from sbzlb s inner join sbzlb_djfs sd on s.id=sd.isbid " +
                                            " inner join CabinetRecordType c on sd.idjid=c.id where s.id=" + sbid);


                    if (dt.Rows.Count > 0)
                    {
                        sb.Append("[");

                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber1"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber1\",\"text\":\"" + dt.Rows[0]["iNumber1"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber2"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber2\",\"text\":\"" + dt.Rows[0]["iNumber2"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber3"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber3\",\"text\":\"" + dt.Rows[0]["iNumber3"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber4"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber4\",\"text\":\"" + dt.Rows[0]["iNumber4"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber5"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber5\",\"text\":\"" + dt.Rows[0]["iNumber5"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber6"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber6\",\"text\":\"" + dt.Rows[0]["iNumber6"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber7"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber7\",\"text\":\"" + dt.Rows[0]["iNumber7"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber8"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber8\",\"text\":\"" + dt.Rows[0]["iNumber8"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber9"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber9\",\"text\":\"" + dt.Rows[0]["iNumber9"].ToString() + "\"},");
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["iNumber10"].ToString()))
                        {
                            sb.Append("{\"id\":\"iNumber10\",\"text\":\"" + dt.Rows[0]["iNumber10"].ToString() + "\"},");
                        }

                        sb.Replace(',', ' ', sb.Length - 1, 1);

                        sb.Append("]},");

                        sb = sb.Remove(sb.Length - 2, 2);
                    }
                    else
                    {
                        sb.Append("[{\"id\":\"\",\"text\":\"\"} ]");        //为空时加载
                    }

                    context.Response.Write(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #28
0
        private void Edit()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                //遍历获取传递过来的字符串
                foreach (string s in HttpContext.Current.Request.Form.AllKeys)
                {
                    sb.AppendFormat("{0}:{1}\n", s, HttpContext.Current.Request.Form[s]);
                }
                string   ss    = sb.ToString();
                string[] str   = ss.Split('@');
                int      id    = int.Parse(str[1]);
                string   csbbh = str[2];

                if (csbbh.Trim() == "")
                {
                    HttpContext.Current.Response.Write("1");
                    return;
                }

                DataTable dt = SqlHelper.GetTable("select * from sbzlb where DeviceId='" + csbbh + "'");
                if (dt.Rows.Count == 0)
                {
                    HttpContext.Current.Response.Write("2");
                    return;
                }

                if (str[3] == "")
                {
                    HttpContext.Current.Response.Write("3");
                    return;
                }
                sys    ex  = new sys();
                string drq = "";
                if (ex.isDate(str[3]) == true)
                {
                    drq = str[3];
                }
                string cdjr      = str[4];
                string cbz       = str[5];
                string cstr1     = str[6];
                string cstr2     = str[7];
                string cstr3     = str[8];
                string cstr4     = str[9];
                string cstr5     = str[10];
                string cstr6     = str[11];
                string cstr7     = str[12];
                string cstr8     = str[13];
                string cstr9     = str[14];
                string cstr10    = str[15];
                string bbool1    = str[16];
                string bbool2    = str[17];
                string bbool3    = str[18];
                string bbool4    = str[19];
                string bbool5    = str[20];
                string bbool6    = str[21];
                string bbool7    = str[22];
                string bbool8    = str[23];
                string bbool9    = str[24];
                string bbool10   = str[25];
                string inumber1  = str[26];
                string inumber2  = str[27];
                string inumber3  = str[28];
                string inumber4  = str[29];
                string inumber5  = str[30];
                string inumber6  = str[31];
                string inumber7  = str[32];
                string inumber8  = str[33];
                string inumber9  = str[34];
                string inumber10 = str[35];

                SqlParameter[] parms =
                {
                    new SqlParameter("@sbbh",      csbbh),
                    new SqlParameter("@rq",        drq),
                    new SqlParameter("@djr",       cdjr),
                    new SqlParameter("@bz",        cbz),
                    new SqlParameter("@cstr1",     cstr1),
                    new SqlParameter("@cstr2",     cstr2),
                    new SqlParameter("@cstr3",     cstr3),
                    new SqlParameter("@cstr4",     cstr4),
                    new SqlParameter("@cstr5",     cstr5),
                    new SqlParameter("@cstr6",     cstr6),
                    new SqlParameter("@cstr7",     cstr7),
                    new SqlParameter("@cstr8",     cstr8),
                    new SqlParameter("@cstr9",     cstr9),
                    new SqlParameter("@cstr10",    cstr10),
                    new SqlParameter("@bBool1",    bbool1),
                    new SqlParameter("@bBool2",    bbool2),
                    new SqlParameter("@bBool3",    bbool3),
                    new SqlParameter("@bBool4",    bbool4),
                    new SqlParameter("@bBool5",    bbool5),
                    new SqlParameter("@bBool6",    bbool6),
                    new SqlParameter("@bBool7",    bbool7),
                    new SqlParameter("@bBool8",    bbool8),
                    new SqlParameter("@bBool9",    bbool9),
                    new SqlParameter("@bBool10",   bbool10),
                    new SqlParameter("@iNumber1",  inumber1),
                    new SqlParameter("@iNumber2",  inumber2),
                    new SqlParameter("@iNumber3",  inumber3),
                    new SqlParameter("@iNumber4",  inumber4),
                    new SqlParameter("@iNumber5",  inumber5),
                    new SqlParameter("@iNumber6",  inumber6),
                    new SqlParameter("@iNumber7",  inumber7),
                    new SqlParameter("@iNumber8",  inumber8),
                    new SqlParameter("@iNumber9",  inumber9),
                    new SqlParameter("@iNumber10", inumber10),
                    new SqlParameter("@id",        id)
                };
                bool flag = SqlHelper.ExeNonQuery("update_djjl", CommandType.StoredProcedure, parms);
                if (flag)
                {
                    HttpContext.Current.Response.Write("修改成功!");
                }
                else
                {
                    HttpContext.Current.Response.Write("修改失败!");
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #29
0
        /// <summary>
        /// 查询的方法
        /// </summary>
        private void Query(string csbid, string sState)
        {
            try
            {
                if (sState == "" || string.IsNullOrEmpty(sState))
                {
                    HttpContext.Current.Response.Write("{ \"total\":0,\"rows\":[]");
                    return;
                }

                //一页显示几行数据
                string rows = HttpContext.Current.Request["rows"];
                //当前页
                string page = HttpContext.Current.Request["page"];

                string strWhere = "1=1";

                if (!string.IsNullOrEmpty(sState) && sState == "s")
                {
                    if (!string.IsNullOrEmpty(csbid))
                    {
                        strWhere = strWhere + " and isbid=" + csbid;
                    }
                }
                else
                {
                    HttpContext.Current.Response.Write("{ \"total\":0,\"rows\":[]");
                    return;
                }

                string qsrq = HttpContext.Current.Request["qsrq"];
                if (!string.IsNullOrEmpty(qsrq))
                {
                    strWhere = strWhere + " and dzysj>='" + qsrq + "'";
                }

                string jzrq = HttpContext.Current.Request["jzrq"];
                if (!string.IsNullOrEmpty(jzrq))
                {
                    strWhere = strWhere + " and dzysj<='" + jzrq + "'";
                }

                string ckey  = HttpContext.Current.Request["ckey"];
                string ctext = HttpContext.Current.Request["cmemo"];

                if (!string.IsNullOrEmpty(ckey))
                {
                    switch (ckey)
                    {
                    case "设备编码":
                        strWhere = strWhere + " and csbbh like '%" + ctext + "%'";
                        break;

                    case "设备名称":
                        strWhere = strWhere + " and csbmc like '%" + ctext + "%'";
                        break;

                    case "生产线":
                        strWhere = strWhere + " and cscx like '%" + ctext + "%'";
                        break;

                    case "所属专业":
                        strWhere = strWhere + " and csszy like '%" + ctext + "%'";
                        break;

                    case "作业项目":
                        strWhere = strWhere + " and czyxm like '%" + ctext + "%'";
                        break;

                    case "作业人员":
                        strWhere = strWhere + " and czyry like '%" + ctext + "%'";
                        break;

                    case "制单人":
                        strWhere = strWhere + " and cczy like '%" + ctext + "%'";
                        break;

                    case "备注":
                        strWhere = strWhere + " and cbz like '%" + ctext + "%'";
                        break;
                    }
                }

                DataSet   duser = SqlHelper.GetList("v_llb", "*", "dzysj", int.Parse(rows), int.Parse(page), false, true, strWhere);
                DataTable dt1   = duser.Tables[0];
                //获取数据源
                DataTable dt  = SqlHelper.GetTable("select * from v_llb where " + strWhere);
                string    str = string.Empty;
                //将数据转换成json格式
                str = JSonHelper.CreateJsonParameters(dt1, true, dt.Rows.Count);
                HttpContext.Current.Response.Write(str);
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }
예제 #30
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";

                DataTable dt       = new DataTable();
                string    username = context.Session["username"].ToString();
                dt = SqlHelper.GetTable("select * from v_menu where bXsf=1 order by id");
                if (dt.Rows.Count > 0)
                {
                    StringBuilder sb   = new StringBuilder();
                    DataRow[]     cRow = null;

                    sb.Append("{\"menus\":[");

                    //基础资料
                    cRow = dt.Select("cgnbh like '%B%' and cygbh='" + username + "'");
                    if (cRow.Length > 0)
                    {
                        sb.Append("{\"menuid\":\"B01\",\"menuname\":\"基础资料\",\"menus\":[");

                        for (int i = 0; i < cRow.Length; i++)
                        {
                            if (cRow[i]["cquery"].ToString() == "1")
                            {
                                sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"url\":\"" + cRow[i]["clj"].ToString() + "\"},");
                            }
                        }

                        sb.Replace(',', ' ', sb.Length - 1, 1);
                        sb.Append("]},");
                    }

                    //记录管理
                    cRow = dt.Select("cgnbh like '%R%' and cygbh='" + username + "'");
                    if (cRow.Length > 0)
                    {
                        sb.Append("{\"menuid\":\"R01\",\"menuname\":\"记录管理\",\"menus\":[");

                        for (int i = 0; i < cRow.Length; i++)
                        {
                            if (cRow[i]["cquery"].ToString() == "1")
                            {
                                sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"url\":\"" + cRow[i]["clj"].ToString() + "\"},");
                            }
                        }

                        sb.Replace(',', ' ', sb.Length - 1, 1);
                        sb.Append("]},");
                    }



                    if (username == "0000")
                    {
                        //组织设置
                        cRow = dt.Select("cgnbh like '%Z%'");
                        if (cRow.Length > 0)
                        {
                            for (int i = 0; i < cRow.Length; i++)
                            {
                                if (cRow[i]["cGnbh"].ToString().Length == 3)
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"menus\":[");
                                }
                                else
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"url\":\"" + cRow[i]["clj"].ToString() + "\"},");
                                }
                            }

                            sb.Replace(',', ' ', sb.Length - 1, 1);
                            sb.Append("]},");
                        }

                        //维护设置
                        cRow = dt.Select("cgnbh like '%W%'");
                        if (cRow.Length > 0)
                        {
                            for (int i = 0; i < cRow.Length; i++)
                            {
                                if (cRow[i]["cGnbh"].ToString().Length == 3)
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"menus\":[");
                                }
                                else
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"url\":\"" + cRow[i]["clj"].ToString() + "\"},");
                                }
                            }

                            sb.Replace(',', ' ', sb.Length - 1, 1);
                            sb.Append("]},");
                        }

                        //点检设置
                        cRow = dt.Select("cgnbh like '%D%'");
                        if (cRow.Length > 0)
                        {
                            for (int i = 0; i < cRow.Length; i++)
                            {
                                if (cRow[i]["cGnbh"].ToString().Length == 3)
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"menus\":[");
                                }
                                else
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"url\":\"" + cRow[i]["clj"].ToString() + "\"},");
                                }
                            }

                            sb.Replace(',', ' ', sb.Length - 1, 1);
                            sb.Append("]},");
                        }

                        //系统管理
                        cRow = dt.Select("cgnbh like '%S%'");
                        if (cRow.Length > 0)
                        {
                            for (int i = 0; i < cRow.Length; i++)
                            {
                                if (cRow[i]["cGnbh"].ToString().Length == 3)
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"menus\":[");
                                }
                                else
                                {
                                    sb.Append("{\"menuid\":\"" + cRow[i]["cgnbh"].ToString() + "\",\"menuname\":\"" + cRow[i]["cgnmc"].ToString() + "\",\"url\":\"" + cRow[i]["clj"].ToString() + "\"},");
                                }
                            }

                            sb.Replace(',', ' ', sb.Length - 1, 1);
                            sb.Append("]},");
                        }
                    }

                    sb.Replace(',', ' ', sb.Length - 1, 1);

                    sb.Append("]}");

                    context.Response.Write(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                sys e = new sys();
                e.GetLog(ex);
            }
        }