Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            string returnStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            string pl_nameStr = context.Request.Form["pl_name"];

            pl_nameStr = pl_nameStr.Trim().ToUpper();
            string codeStr = context.Request.Form["code"];

            codeStr = codeStr.ToUpper().Trim();
            string addressStr = context.Request.Form["address"];

            addressStr = addressStr.Trim();
            string workshop_idStr = context.Request.Form["workshop_id"];
            string owneridStr     = context.Request.Form["ownerid"];
            string remarkStr      = context.Request.Form["remark"];

            remarkStr = remarkStr.Trim();
            string        create_timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string        update_time    = create_timeStr;
            SqlConnection mycon          = null;
            SqlCommand    mycom          = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom = mycon.CreateCommand();
                StringBuilder sb = new StringBuilder();
                sb.Clear();
                sb.Append("if not exists(select id from ProductLine_Management where pl_name='" + pl_nameStr + "')\n");
                sb.Append("begin\n");
                sb.Append("insert into ProductLine_Management(pl_name,code,address,workshop_id,ownerid,remark,create_by,create_time,update_by,update_time)\n");
                sb.Append("values(N'" + pl_nameStr + "',N'" + codeStr + "',N'" + addressStr + "','" + workshop_idStr + "','" + owneridStr + "',N'" + remarkStr + "','" + context.Session["user_id"] + "','" + create_timeStr + "','" + context.Session["user_id"] + "','" + update_time + "')\n");
                sb.Append("end\n");
                mycom.CommandText = sb.ToString();
                sb.Clear();
                int ret = mycom.ExecuteNonQuery();
                if (ret < 1)
                {
                    returnStr = "线别已存在,请确认!";
                }
                else
                {
                    returnStr = "OK";
                }
            }
            catch (Exception msg)
            {
                returnStr = msg.Message;
            }
            finally
            {
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(returnStr);
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            string returnStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            string idStr   = context.Request.Form["input_id"];
            string nameStr = context.Request.Form["name"];

            nameStr = nameStr.Trim();
            string usernameStr = context.Request.Form["username"];

            usernameStr = usernameStr.Trim().ToLower();
            string opidStr = context.Request.Form["opid"];

            opidStr = opidStr.Trim().ToUpper();
            string passwordStr = context.Request.Form["password"];

            passwordStr = passwordStr.Trim();
            string deptStr = context.Request.Form["dept"];

            deptStr = deptStr.Trim();
            string postStr = context.Request.Form["post"];

            postStr = postStr.Trim();
            string telephoneStr = context.Request.Form["telephone"];

            telephoneStr = telephoneStr.Trim();
            string emailStr = context.Request.Form["email"];

            emailStr = emailStr.Trim().ToLower();
            string weixin_noStr = context.Request.Form["weixin_no"];

            weixin_noStr = weixin_noStr.Trim();
            string        user_stateStr  = "1";
            string        create_timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string        update_time    = create_timeStr;
            SqlConnection mycon          = null;
            SqlCommand    mycom          = null;
            SqlDataReader dr             = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom = mycon.CreateCommand();
                StringBuilder sb = new StringBuilder();
                sb.Clear();
                if (idStr == "0")
                {
                    sb.Append("if not exists(select user_id from User_Manage where username='******' or opid='" + opidStr + "')\n");
                    sb.Append("begin\n");
                    sb.Append("insert into User_Manage(name,username,opid,password,dept,post,telephone,email,weixin_no,user_state,create_by,create_time,update_by,update_time)\n");
                    sb.Append("values(N'" + nameStr + "',N'" + usernameStr + "','" + opidStr + "',N'" + passwordStr + "','" + deptStr + "','" + postStr + "','" + telephoneStr + "','" + emailStr + "','" + weixin_noStr + "','" + user_stateStr + "','" + context.Session["user_id"] + "','" + create_timeStr + "','" + context.Session["user_id"] + "','" + update_time + "')\n");
                    sb.Append("end\n");
                    sb.Append("select @@IDENTITY");
                    mycom.CommandText = sb.ToString();
                    sb.Clear();
                    string ret = mycom.ExecuteScalar().ToString();
                    if (ret != "" && ret != null)
                    {
                        sb.Append("insert into Auth_Manage(user_id,menu_id,power_no,power_desc,create_by,create_time,update_by,update_time)\n");
                        sb.Append("select '" + ret + "',menu_id,init_power,'','" + context.Session["user_id"] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + context.Session["user_id"] + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' from Menu_Manage");
                        mycom.CommandText = sb.ToString();
                        sb.Clear();
                        int retCount = mycom.ExecuteNonQuery();
                        if (retCount > 0)
                        {
                            returnStr = "OK";
                        }
                        else
                        {
                            returnStr = "用户添加成功,菜单初始权限设置失败!";
                        }
                    }
                    else
                    {
                        returnStr = "账号已存在,请确认!";
                    }
                }
                else
                {
                    mycom.CommandText = "update User_Manage set name=N'" + nameStr + "',username=N'" + usernameStr + "',opid='" + opidStr + "',password=N'" + passwordStr + "',dept='" + deptStr + "',post='" + postStr + "',telephone='" + telephoneStr + "',email='" + emailStr + "',weixin_no='" + weixin_noStr + "',update_by='" + context.Session["user_id"] + "',update_time='" + update_time + "' where user_id='" + idStr + "'";
                    int ret = mycom.ExecuteNonQuery();
                    if (ret > 0)
                    {
                        returnStr = "OK";
                    }
                    else
                    {
                        returnStr = "用户编辑更新失败!";
                    }
                }
            }
            catch (Exception msg)
            {
                returnStr = msg.Message;
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(returnStr);
        }
Example #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            int    resultFlag = 0;
            string msgStr     = "";

            //首先判断登陆是否超时并返回超时信息Time Out
            if (context.Session.Count == 0)
            {
                msgStr = "Time Out";
            }
            else
            {
                string firstOrNext = context.Request.Form["FirstOrNext"];
                string menuID      = context.Request.Form["menuID"];
                mycon  = DBConnect.ConnectSQLServer();
                myconT = DBConnect.ConnectSQLServer();
                try
                {
                    mycon.Open();
                    mycom = mycon.CreateCommand();
                    StringBuilder sb = new StringBuilder();
                    sb.Clear();
                    switch (firstOrNext)
                    {
                    case "0":        //获取主目录
                        sb.Append("SELECT A.menu_id,A.menu_name,A.menu_url,A.icon,B.power_no\n");
                        sb.Append("FROM\n");
                        sb.Append("Menu_Manage A\n");
                        sb.Append("inner join\n");
                        sb.Append("Auth_Manage B\n");
                        sb.Append("ON A.menu_id=B.menu_id\n");
                        sb.Append("WHERE A.parent_id='0' AND A.menu_state='1' AND B.user_id='" + context.Session["user_id"] + "' AND B.power_no<>0\n");
                        sb.Append("ORDER BY A.order_num ASC");
                        mycom.CommandText = sb.ToString();
                        dr = mycom.ExecuteReader();
                        menuList.Clear();
                        while (dr.Read())
                        {
                            menuitem.menuID    = dr[0].ToString();
                            menuitem.menuName  = dr[1].ToString();
                            menuitem.menuURL   = dr[2].ToString();
                            menuitem.menuIco   = dr[3].ToString();
                            menuitem.menuPower = dr[4].ToString();
                            menuList.Add(menuitem);
                        }
                        resultFlag = 1;
                        break;

                    case "1":        //获取主目录下所有的次阶目录以及各次级目录下的菜单
                        nextMenuHTML.Clear();
                        menuCount = 0;
                        nextMenuHTML.Append("<div style=\"color:white;margin-left: 15px;line-height:30px;\">\n");
                        if ((msgStr = SearchNextMenu(menuID, 1)) == "")
                        {
                            nextMenuHTML.Append("</div>");
                            resultFlag = 1;
                            if (menuCount > 0)
                            {
                                msgStr = nextMenuHTML.ToString();
                            }
                        }
                        else
                        {
                            msgStr = "(" + msgStr + ")";
                        }
                        break;

                    default:
                        break;
                    }

                    sb.Clear();
                    switch (firstOrNext)
                    {
                    case "0":        //主目录时,在此处拼接返回的HTML
                        foreach (menuItem m in menuList)
                        {
                            sb.Append("<span style=\"height: 80px; width: 150px; text-align:center; display: inline-block; \" onclick=\"InitNextMenu(this,'" + m.menuID + "');\"><p style=\"line-height:70px; \"><img src=\"Images/" + m.menuIco + "\" style=\"height: 70px; width: 80px; \" /></p><p style=\"line-height:8px; color: white; font-weight:700; margin-top:-5px; \">" + m.menuName + "</p></span>\n");
                        }
                        msgStr = sb.ToString();
                        break;

                    case "1":
                        //直接在上面代码和SearchNextMenu函数中拼接HTML,比较方便
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception msg)
                {
                    msgStr = msg.Message;
                }
                finally
                {
                    if (dr != null)
                    {
                        dr.Close();
                        dr = null;
                    }
                    if (mycon.State != System.Data.ConnectionState.Closed)
                    {
                        mycon.Close();
                    }
                    mycon = null;
                }

                if (drT != null)
                {
                    drT.Close();
                    drT = null;
                }
                if (myconT.State != System.Data.ConnectionState.Closed)
                {
                    myconT.Close();
                }
                myconT = null;
            }
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(new { Result = resultFlag, Msg = msgStr, Data = "" }));    //返回JSON数据
        }
Example #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            SqlConnection  mycon      = null;
            SqlCommand     mycom      = null;
            SqlDataAdapter da         = null;
            SqlDataReader  dr         = null;
            DataSet        ds         = new DataSet();
            int            code       = 0;
            string         msgStr     = "";
            int            count      = 0;
            string         condition  = context.Request.QueryString["condition"].Trim().ToUpper();
            int            curr       = Convert.ToInt32(context.Request.QueryString["curr"]);
            int            nums       = Convert.ToInt32(context.Request.QueryString["nums"]);
            int            totalCount = 0;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                StringBuilder sb = new StringBuilder();
                mycon.Open();
                mycom = mycon.CreateCommand();
                sb.Clear();
                sb.Append("SELECT\n");
                sb.Append("count(id) from SteelMesh_Detail_Storage\n");
                if (condition != "")
                {
                    sb.Append("WHERE storage_name LIKE '%" + condition + "%' OR storage_id=(select id from SteelMesh_Storage_Management where storage_name='" + condition + "')");
                }
                mycom.CommandText = sb.ToString();
                sb.Clear();
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    totalCount = Convert.ToInt32(dr[0].ToString());
                }
                dr.Close();
                dr = null;
                sb.Append("SELECT top " + nums.ToString() + "\n");
                sb.Append("id,(select storage_name from SteelMesh_Storage_Management where id=SteelMesh_Detail_Storage.storage_id) AS storage,storage_name,status\n");
                sb.Append("FROM\n");
                sb.Append("SteelMesh_Detail_Storage\n");
                if (condition != "")
                {
                    sb.Append("WHERE (storage_name LIKE '%" + condition + "%'\n");
                    sb.Append("OR storage_id=(select id from SteelMesh_Storage_Management where storage_name='" + condition + "'))\n");
                    sb.Append("and id not in(select top " + (nums * (curr - 1)).ToString() + " id from SteelMesh_Detail_Storage WHERE storage_name LIKE '%" + condition + "%'\n");
                    sb.Append("OR storage_id=(select id from SteelMesh_Storage_Management where storage_name='" + condition + "'))\n");
                }
                else
                {
                    sb.Append("WHERE id not in(select top " + (nums * (curr - 1)).ToString() + " id from SteelMesh_Detail_Storage)\n");
                }
                sb.Append("ORDER BY id ASC\n");
                mycom.CommandText = sb.ToString();
                sb.Clear();
                da = new SqlDataAdapter(mycom.CommandText, mycon);
                da.Fill(ds);
            }
            catch (Exception msg)
            {
                code   = 1;
                msgStr = msg.Message;
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
                if (da != null)
                {
                    da.Dispose();
                }
                if (mycon.State != ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(new { code = code, msg = msgStr, count = totalCount, data = ds.Tables[0] }));    //返回JSON数据
            ds.Dispose();
            ds = null;
        }
Example #5
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     //context.Response.Write("Hello World");
     dt.Columns.Add(new DataColumn("menu_name", typeof(string)));
     dt.Columns.Add(new DataColumn("parent", typeof(string)));
     dt.Columns.Add(new DataColumn("url", typeof(string)));
     dt.Columns.Add(new DataColumn("type", typeof(string)));
     dt.Columns.Add(new DataColumn("status", typeof(string)));
     dt.Columns.Add(new DataColumn("remark", typeof(string)));
     dt.Columns.Add(new DataColumn("power", typeof(string)));
     mycon  = DBConnect.ConnectSQLServer();
     myconT = DBConnect.ConnectSQLServer();
     //首先查询主目录
     try
     {
         mycon.Open();
         mycom             = mycon.CreateCommand();
         mycom.CommandText = "select menu_id,menu_name,menu_state,remark,(select power_no from Auth_Manage where user_id='" + context.Session["user_id"].ToString() + "' and menu_id=Menu_Manage.menu_id) as init_power from Menu_Manage where parent_id='0' and menu_state='1' order by order_num asc";
         dr = mycom.ExecuteReader();
         while (dr.Read())
         {
             totalCount++;
             drow    = dt.NewRow();
             drow[0] = dr[1].ToString();
             drow[1] = "N/A";
             drow[2] = "N/A";
             drow[3] = "目录";
             drow[4] = dr[2].ToString();
             drow[5] = dr[3].ToString();
             if (dr[4].ToString() == "0")
             {
                 drow[6] = "不可显";
             }
             else if (dr[4].ToString() == "1")
             {
                 drow[6] = "只读";
             }
             else if (dr[4].ToString() == "2")
             {
                 drow[6] = "读写";
             }
             dt.Rows.Add(drow);
             GetNextMenu(dr[0].ToString());
         }
         ds.Tables.Add(dt);
     }
     catch (Exception msg)
     {
         code   = 1;
         msgStr = msgStr + msg.Message + "\n";
     }
     finally
     {
         if (drT != null)
         {
             drT.Close();
             drT = null;
         }
         if (myconT.State != ConnectionState.Closed)
         {
             myconT.Close();
         }
         myconT = null;
         if (dr != null)
         {
             dr.Close();
             dr = null;
         }
         if (mycon.State != ConnectionState.Closed)
         {
             mycon.Close();
         }
         mycon = null;
     }
     HttpContext.Current.Response.Write(JsonConvert.SerializeObject(new { code = code, msg = msgStr, count = totalCount, data = ds.Tables[0] }));    //返回JSON数据
     ds.Dispose();
     ds = null;
 }
Example #6
0
        public void ProcessRequest(HttpContext context)
        {
            string returnStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            string idStr           = context.Request.Form["input_id"];
            string storage_nameStr = context.Request.Form["storage_name"];

            storage_nameStr = storage_nameStr.Trim().ToUpper();
            string addressStr = context.Request.Form["address"];

            addressStr = addressStr.Trim();
            string        statusStr      = "1";
            string        create_timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string        update_time    = create_timeStr;
            SqlConnection mycon          = null;
            SqlCommand    mycom          = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom = mycon.CreateCommand();
                StringBuilder sb = new StringBuilder();
                sb.Clear();
                if (idStr == "0")
                {
                    sb.Append("if not exists(select id from SteelMesh_Storage_Management where storage_name='" + storage_nameStr + "')\n");
                    sb.Append("begin\n");
                    sb.Append("insert into SteelMesh_Storage_Management(storage_name,address,status,create_by,create_time,update_by,update_time)\n");
                    sb.Append("values(N'" + storage_nameStr + "',N'" + addressStr + "','" + statusStr + "','" + context.Session["user_id"] + "','" + create_timeStr + "','" + context.Session["user_id"] + "','" + update_time + "')\n");
                    sb.Append("end\n");
                    mycom.CommandText = sb.ToString();
                    sb.Clear();
                    int ret = mycom.ExecuteNonQuery();
                    if (ret < 1)
                    {
                        returnStr = "储位已存在,请确认!";
                    }
                    else
                    {
                        returnStr = "OK";
                    }
                }
                else
                {
                    mycom.CommandText = "update SteelMesh_Storage_Management set storage_name=N'" + storage_nameStr + "',address=N'" + addressStr + "' where id='" + idStr + "'";
                    int ret = mycom.ExecuteNonQuery();
                    if (ret > 0)
                    {
                        returnStr = "OK";
                    }
                    else
                    {
                        returnStr = "储位编辑更新失败!";
                    }
                }
            }
            catch (Exception msg)
            {
                returnStr = msg.Message;
            }
            finally
            {
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(returnStr);
        }