示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            string msgStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            SqlConnection mycon = null;
            SqlCommand    mycom = null;
            string        idStr = context.Request.Form["id"];

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom = mycon.CreateCommand();
                StringBuilder sb = new StringBuilder();
                sb.Clear();
                sb.Append("update User_Manage set update_by='" + context.Session["user_id"] + "',update_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', user_state=\n");
                sb.Append("case (select user_state from User_Manage where user_id='" + idStr + "')\n");
                sb.Append("when '1' then '0'\n");
                sb.Append("when '0' then '1'\n");
                sb.Append("else '0' end\n");
                sb.Append("where user_id='" + idStr + "'");
                mycom.CommandText = sb.ToString();
                int ret = mycom.ExecuteNonQuery();
                if (ret > 0)
                {
                    msgStr = "OK";
                    //将用户的启用状态设置为0时,同步更新该用户对钢网的借用归还权限为0
                    sb.Clear();
                    sb.Append("if exists(select id from SteelMesh_LendAndReturnPower where user_id='" + idStr + "')\n");
                    sb.Append("begin\n");
                    sb.Append("update SteelMesh_LendAndReturnPower set power_status=\n");
                    sb.Append("case (select user_state from User_Manage where user_id='" + idStr + "')\n");
                    sb.Append("when '0' then '0'\n");
                    sb.Append("else (select power_status from SteelMesh_LendAndReturnPower where user_id='" + idStr + "')\n");
                    sb.Append("end,update_by='" + context.Session["user_id"].ToString() + "',update_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'\n");
                    sb.Append("end");
                    mycom.CommandText = sb.ToString();
                    mycom.ExecuteNonQuery();
                }
                else
                {
                    msgStr = "操作影响行数0";
                }
            }
            catch (Exception msg)
            {
                msgStr = msg.Message;
            }
            finally
            {
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(msgStr);
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idStr = Request.QueryString["id"];

            //根据传入的id设置主旨内容
            if (idStr == "0")
            {
                h2Show.InnerText     = "新增厂商";
                btnAddEdit.InnerText = "添加";
            }
            else
            {
                h2Show.InnerText     = "编辑厂商";
                btnAddEdit.InnerText = "编辑";
            }
            input_id.Value = idStr;

            SqlConnection mycon = null;
            SqlCommand    mycom = null;
            SqlDataReader dr    = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                //查询部门清单到下拉列表框
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select name,code,responsible,telephone,email,address,remark from SteelMesh_Manufacturer_Management where id='" + idStr + "'";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    name.Value        = dr[0].ToString();
                    code.Value        = dr[1].ToString();
                    responsible.Value = dr[2].ToString();
                    telephone.Value   = dr[3].ToString();
                    email.Value       = dr[4].ToString();
                    address.Value     = dr[5].ToString();
                    remark.Value      = dr[6].ToString();
                }
            }
            catch (Exception msg)
            {
                System.Console.WriteLine(msg.Message);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
        }
示例#3
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;
            DataSet        ds        = new DataSet();
            int            code      = 0;
            string         msgStr    = "";
            int            count     = 0;
            string         condition = context.Request.QueryString["condition"];

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                StringBuilder sb = new StringBuilder();
                mycon.Open();
                mycom = mycon.CreateCommand();
                sb.Clear();
                sb.Append("SELECT\n");
                sb.Append("id,post\n");
                sb.Append("FROM\n");
                sb.Append("Job_Manage\n");
                if (condition != "")
                {
                    sb.Append("WHERE post LIKE '%" + condition + "%'\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 (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 = ds.Tables[0].Rows.Count, data = ds.Tables[0] }));    //返回JSON数据
            ds.Dispose();
            ds = null;
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection mycon           = null;
            SqlCommand    mycom           = null;
            SqlDataReader dr              = null;
            bool          userFlag        = false;
            bool          ProductLineFlag = false;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select user_id,name,username from User_Manage where user_state='1'";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    ownerid.Items.Add(new ListItem(dr[2].ToString() + "(" + dr[1].ToString() + ")", dr[0].ToString()));
                }
                dr.Close();
                dr                = null;
                userFlag          = true;
                mycom.CommandText = "select id,ws_name from Workshop_Manage";
                dr                = mycom.ExecuteReader();
                while (dr.Read())
                {
                    workshop_id.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString()));
                }
                ProductLineFlag = true;
            }
            catch (Exception msg)
            {
                if (userFlag == false)
                {
                    ownerid.Items.Add(new ListItem(msg.Message, ""));
                }
                if (ProductLineFlag == false)
                {
                    workshop_id.Items.Add(new ListItem(msg.Message, ""));
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
        }
示例#5
0
        public void ProcessRequest(HttpContext context)
        {
            string msgStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            string        dept      = context.Request.Form["dept"].ToUpper().Trim();
            string        dept_code = context.Request.Form["dept_code"].ToUpper().Trim();
            string        mgr_1     = context.Request.Form["mgr_1"];
            string        mgr_2     = context.Request.Form["mgr_2"];
            string        mgr_3     = context.Request.Form["mgr_3"];
            SqlConnection mycon     = null;
            SqlCommand    mycom     = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select id from Department_Manage where dept='" + dept + "' or dept_code='" + dept_code + "'";
                object retStr = mycom.ExecuteScalar();
                if (retStr != null)
                {
                    msgStr = "部门:" + dept + "(" + dept_code + ")已存在,请勿重复添加!";
                }
                else
                {
                    mycom.CommandText = "insert into Department_Manage(dept,dept_code,mgr_1,mgr_2,mgr_3,create_by,create_time,update_by,update_time) values(N'" + dept + "','" + dept_code + "','" + mgr_1 + "','" + mgr_2 + "','" + mgr_3 + "','" + 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") + "')";
                    int ret = mycom.ExecuteNonQuery();
                    if (ret > 0)
                    {
                        msgStr = "OK";
                    }
                    else
                    {
                        msgStr = "数据插入失败!";
                    }
                }
            }
            catch (Exception msg)
            {
                msgStr = msg.Message;
            }
            finally
            {
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(msgStr);
        }
示例#6
0
        public void ProcessRequest(HttpContext context)
        {
            string msgStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            string        factory_code     = context.Request.Form["factory_code"].ToUpper().Trim();
            string        factory_describe = context.Request.Form["factory_describe"].Trim();
            SqlConnection mycon            = null;
            SqlCommand    mycom            = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select id from Factory_Manage where factory_code='" + factory_code + "'";
                object retStr = mycom.ExecuteScalar();
                if (retStr != null)
                {
                    msgStr = "厂区:" + factory_code + "已存在,请勿重复添加!";
                }
                else
                {
                    mycom.CommandText = "insert into Factory_Manage(factory_code,factory_describe,create_by,create_time,update_by,update_time) values('" + factory_code + "',N'" + factory_describe + "','" + 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") + "')";
                    int ret = mycom.ExecuteNonQuery();
                    if (ret > 0)
                    {
                        msgStr = "OK";
                    }
                    else
                    {
                        msgStr = "数据插入失败!";
                    }
                }
            }
            catch (Exception msg)
            {
                msgStr = msg.Message;
            }
            finally
            {
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(msgStr);
        }
示例#7
0
        public void ProcessRequest(HttpContext context)
        {
            string msgStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            SqlConnection mycon = null;
            SqlCommand    mycom = null;
            string        idStr = context.Request.Form["id"];

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "delete from User_Manage where user_id='" + idStr + "'";
                int ret = mycom.ExecuteNonQuery();
                if (ret > 0)
                {
                    msgStr            = "OK";
                    mycom.CommandText = "delete from Auth_Manage where user_id='" + idStr + "'";
                    ret = mycom.ExecuteNonQuery();
                }
                else
                {
                    msgStr = "操作影响行数0";
                }
            }
            catch (Exception msg)
            {
                msgStr = msg.Message;
            }
            finally
            {
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(msgStr);
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection mycon = null;
            SqlCommand    mycom = null;
            SqlDataReader dr    = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select id,dept,dept_code from Department_Manage";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    dept.Items.Add(new ListItem(dr[2].ToString() + "(" + dr[1].ToString() + ")", dr[0].ToString()));
                }
                dr.Close();
                mycom.CommandText = "select id,post from Job_Manage";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    post.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString()));
                }
            }
            catch (Exception msg)
            {
                System.Console.WriteLine(msg.Message);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection mycon = null;
            SqlCommand    mycom = null;
            SqlDataReader dr    = null;

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select user_id,name,username from User_Manage where user_state='1'";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    mgr_1.Items.Add(new ListItem(dr[2].ToString() + "(" + dr[1].ToString() + ")", dr[0].ToString()));
                    mgr_2.Items.Add(new ListItem(dr[2].ToString() + "(" + dr[1].ToString() + ")", dr[0].ToString()));
                    mgr_3.Items.Add(new ListItem(dr[2].ToString() + "(" + dr[1].ToString() + ")", dr[0].ToString()));
                }
            }
            catch (Exception msg)
            {
                mgr_1.Items.Add(new ListItem(msg.Message, ""));
                mgr_2.Items.Add(new ListItem(msg.Message, ""));
                mgr_3.Items.Add(new ListItem(msg.Message, ""));
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
        }
示例#10
0
        public void ProcessRequest(HttpContext context)
        {
            string msgStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            SqlConnection mycon     = null;
            SqlCommand    mycom     = null;
            string        statusStr = context.Request.Form["status"];

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "update SteelMesh_Info_List set status='" + statusStr + "'";
                int ret = mycom.ExecuteNonQuery();
                if (ret > 0)
                {
                    msgStr = "OK";
                }
                else
                {
                    msgStr = "操作影响行数0";
                }
            }
            catch (Exception msg)
            {
                msgStr = msg.Message;
            }
            finally
            {
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(msgStr);
        }
示例#11
0
        public void ProcessRequest(HttpContext context)
        {
            string returnStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            SqlConnection mycon           = null;
            SqlCommand    mycom           = null;
            SqlDataReader dr              = null;
            string        MailHost        = ConfigurationManager.AppSettings["MailHost"].ToString().Trim();
            int           MailPort        = Convert.ToInt32(ConfigurationManager.AppSettings["MailPort"].ToString().Trim());
            string        MailFromAddress = ConfigurationManager.AppSettings["MailFromAddress"].ToString().Trim();
            string        MailPassword    = ConfigurationManager.AppSettings["MailPassword"].ToString().Trim();
            string        userName        = context.Request.Form["userAccount"];

            userName = userName.Trim().ToLower();
            mycon    = DBConnect.ConnectSQLServer();
            try
            {
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select password,email from User_Manage where username='******' or email='" + userName + "' or opid='" + userName + "'";
                dr = mycom.ExecuteReader();
                string emailStr = "", passwordStr = "";
                while (dr.Read())
                {
                    passwordStr = dr[0].ToString();
                    emailStr    = dr[1].ToString();
                }
                if (emailStr != "")
                {
                    MailClass.EmailParameterSet emailPara = new MailClass.EmailParameterSet();
                    emailPara.mailServer       = MailHost;
                    emailPara.mailPort         = MailPort;
                    emailPara.mailFrom         = MailFromAddress;
                    emailPara.mailFromPassword = MailPassword;
                    emailPara.mailSubject      = "治工具管理系统---密码找回";
                    emailPara.mailBody         = "您的登陆密码:" + passwordStr;
                    emailPara.mailTo           = new List <string>();
                    emailPara.mailTo.Clear();
                    emailPara.mailTo.Add(emailStr);
                    emailPara.mailCopy = new List <string>();
                    emailPara.mailCopy.Clear();
                    bool mailOK = false;
                    try
                    {
                        MailClass mailFun = new MailClass();
                        mailFun.SendMail(emailPara);
                        mailOK = true;
                    }
                    catch (Exception msg)
                    {
                        Console.WriteLine(msg.Message);
                    }
                    if (mailOK)
                    {
                        returnStr = emailStr;
                    }
                }
            }
            catch (Exception msg)
            {
                System.Console.WriteLine(msg.Message);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
            context.Response.Write(returnStr);
        }
示例#12
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);
        }
示例#13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idStr = Request.QueryString["user_id"];

            //根据传入的id设置主旨内容
            if (idStr == "0")
            {
                h2Show.InnerText     = "新增用户";
                btnAddEdit.InnerText = "添加";
            }
            else
            {
                h2Show.InnerText     = "编辑用户";
                btnAddEdit.InnerText = "编辑";
            }
            input_id.Value = idStr;

            SqlConnection mycon = null;
            SqlCommand    mycom = null;
            SqlDataReader dr    = null;
            StringBuilder sb    = new StringBuilder();

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                //查询部门清单到下拉列表框
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select id,dept,dept_code from Department_Manage";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    dept.Items.Add(new ListItem(dr[2].ToString() + "(" + dr[1].ToString() + ")", dr[0].ToString()));
                }
                dr.Close();
                //查询职务清单到下拉列表框
                mycom.CommandText = "select id,post from Job_Manage";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    post.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString()));
                }
                dr.Close();
                //根据传入的id初始化对应的用户信息
                sb.Clear();
                sb.Append("select\n");
                sb.Append("A.user_id,A.name,A.username,A.opid,A.password,B.id as dept_id,B.dept as dept,B.dept_code as dept_code,C.id as post_id,C.post as post,A.telephone,A.email,A.weixin_no\n");
                sb.Append("from User_Manage A\n");
                sb.Append("left join Department_Manage B on A.dept=B.id\n");
                sb.Append("left join Job_Manage C on A.post=C.id\n");
                sb.Append("where A.user_id='" + idStr + "'");
                mycom.CommandText = sb.ToString();
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    name.Value         = dr[1].ToString();
                    username.Value     = dr[2].ToString();
                    opid.Value         = dr[3].ToString();
                    password.Value     = dr[4].ToString();
                    rpassword.Value    = dr[4].ToString();
                    dept.SelectedIndex = dept.Items.IndexOf(new ListItem(dr[7].ToString() + "(" + dr[6].ToString() + ")", dr[5].ToString()));
                    post.SelectedIndex = post.Items.IndexOf(new ListItem(dr[9].ToString(), dr[8].ToString()));
                    telephone.Value    = dr[10].ToString();
                    email.Value        = dr[11].ToString();
                    weixin_no.Value    = dr[12].ToString();
                }
            }
            catch (Exception msg)
            {
                System.Console.WriteLine(msg.Message);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
        }
示例#14
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;
 }
示例#15
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数据
        }
示例#16
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_idStr   = context.Request.Form["storage_id"];
            string storage_nameStr = context.Request.Form["storage_name"];

            storage_nameStr = storage_nameStr.Trim().ToUpper();
            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_Detail_Storage where storage_id='" + storage_idStr + "' and storage_name='" + storage_nameStr + "')\n");
                    sb.Append("begin\n");
                    sb.Append("insert into SteelMesh_Detail_Storage(storage_id,storage_name,status,create_by,create_time,update_by,update_time)\n");
                    sb.Append("values('" + storage_idStr + "',N'" + storage_nameStr + "','" + 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_Detail_Storage set storage_id='" + storage_idStr + "',storage_name=N'" + storage_nameStr + "' 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);
        }
示例#17
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;

            SqlConnection myconT = null;
            SqlCommand    mycomT = null;
            SqlDataReader drT    = null;

            DataSet   ds         = new DataSet();
            DataTable dt         = new DataTable();
            DataRow   drow       = null;
            int       code       = 0;
            string    msgStr     = "";
            string    condition  = context.Request.QueryString["condition"].Trim();
            string    flag       = context.Request.QueryString["flag"].Trim();
            int       curr       = Convert.ToInt32(context.Request.QueryString["curr"]);
            int       nums       = Convert.ToInt32(context.Request.QueryString["nums"]);
            int       totalCount = 0;

            mycon  = DBConnect.ConnectSQLServer();
            myconT = DBConnect.ConnectSQLServer();
            try
            {
                StringBuilder sb = new StringBuilder();
                mycon.Open();
                mycom = mycon.CreateCommand();
                myconT.Open();
                mycomT = myconT.CreateCommand();
                sb.Clear();

                //用户管理模块,用于获取所有用户相关信息列表
                //钢网借用权限管理模块,用于获取用户相关信息和借用权限列表
                if (flag == "0") //用户管理模块
                {
                    sb.Append("SELECT\n");
                    sb.Append("count(user_id) from User_Manage\n");
                    if (condition != "")
                    {
                        sb.Append("WHERE name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "')\n");
                    }
                }
                else if (flag == "1" || flag == "2" || flag == "3")  //钢网借用权限管理模块和用户对目录菜单权限管理模块和用户对客户端页面管理模块
                {
                    sb.Append("SELECT\n");
                    sb.Append("count(user_id) from User_Manage where user_state='1'\n");
                    if (condition != "")
                    {
                        sb.Append("and name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "')\n");
                    }
                }
                mycom.CommandText = sb.ToString();
                sb.Clear();
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    totalCount = Convert.ToInt32(dr[0].ToString());
                }
                dr.Close();
                dr = null;

                sb.Clear();
                if (flag == "0")  //用户管理模块
                {
                    sb.Append("SELECT top " + nums.ToString() + "\n");
                    sb.Append("user_id,name,username,(SELECT dept FROM Department_Manage WHERE id=User_Manage.dept) AS dept,(SELECT post FROM Job_Manage WHERE id=User_Manage.post) AS post,telephone,email,weixin_no,user_state\n");
                    sb.Append("FROM\n");
                    sb.Append("User_Manage\n");
                    if (condition != "")
                    {
                        sb.Append("WHERE (name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "'))\n");
                        sb.Append("AND user_id not in (select top " + (nums * (curr - 1)).ToString() + " user_id from User_Manage WHERE name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "'))\n");
                    }
                    else
                    {
                        sb.Append("where user_id not in (select top " + (nums * (curr - 1)).ToString() + " user_id from User_Manage)\n");
                    }
                    sb.Append("ORDER BY user_id ASC\n");
                }
                else if (flag == "1")  //钢网借用权限管理模块
                {
                    sb.Append("SELECT top " + nums.ToString() + "\n");
                    sb.Append("user_id,name,username,(SELECT dept FROM Department_Manage WHERE id=User_Manage.dept) AS dept,(SELECT post FROM Job_Manage WHERE id=User_Manage.post) AS post,\n");
                    sb.Append("case (select power_status from SteelMesh_LendAndReturnPower where user_id=User_Manage.user_id)\n");
                    sb.Append("when '0' then '0'\n");
                    sb.Append("when '1' then '1'\n");
                    sb.Append("else '0' end as power_status\n");
                    sb.Append("FROM\n");
                    sb.Append("User_Manage\n");
                    if (condition != "")
                    {
                        sb.Append("WHERE user_state='1' and (name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "'))\n");
                        sb.Append("AND user_id not in (select top " + (nums * (curr - 1)).ToString() + " user_id from User_Manage WHERE user_state='1' and name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "'))\n");
                    }
                    else
                    {
                        sb.Append("where user_state='1' and user_id not in (select top " + (nums * (curr - 1)).ToString() + " user_id from User_Manage where user_state='1')\n");
                    }
                    sb.Append("ORDER BY user_id ASC\n");
                }
                else if (flag == "2" || flag == "3")  //用户对目录菜单权限管理模块、用户对客户端页面管理模块也在这里获取用户清单并在下面拼接ds
                {
                    sb.Append("SELECT top " + nums.ToString() + "\n");
                    sb.Append("user_id,name,username,(SELECT dept FROM Department_Manage WHERE id=User_Manage.dept) AS dept,(SELECT post FROM Job_Manage WHERE id=User_Manage.post) AS post\n");
                    sb.Append("FROM\n");
                    sb.Append("User_Manage\n");
                    if (condition != "")
                    {
                        sb.Append("WHERE user_state='1' and (name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "'))\n");
                        sb.Append("AND user_id not in (select top " + (nums * (curr - 1)).ToString() + " user_id from User_Manage WHERE user_state='1' and name LIKE '%" + condition + "%' OR username LIKE '%" + condition + "%' OR dept=(select id from Department_Manage where dept='" + condition.ToUpper() + "' or dept_code='" + condition.ToUpper() + "'))\n");
                    }
                    else
                    {
                        sb.Append("where user_state='1' and user_id not in (select top " + (nums * (curr - 1)).ToString() + " user_id from User_Manage)\n");
                    }
                    sb.Append("ORDER BY user_id ASC\n");
                }
                if (flag == "3")
                {
                    dt.Columns.Add(new DataColumn("user_id", typeof(string)));
                    dt.Columns.Add(new DataColumn("name", typeof(string)));
                    dt.Columns.Add(new DataColumn("username", typeof(string)));
                    dt.Columns.Add(new DataColumn("dept", typeof(string)));
                    dt.Columns.Add(new DataColumn("post", typeof(string)));
                    dt.Columns.Add(new DataColumn("client_page", typeof(string)));
                    string clientPageStr = "";
                    mycom.CommandText = sb.ToString();
                    dr = mycom.ExecuteReader();
                    while (dr.Read())
                    {
                        clientPageStr = "";
                        drow          = dt.NewRow();
                        drow[0]       = dr[0].ToString();
                        drow[1]       = dr[1].ToString();
                        drow[2]       = dr[2].ToString();
                        drow[3]       = dr[3].ToString();
                        drow[4]       = dr[4].ToString();
                        sb.Clear();
                        sb.Append("select A.client_page\n");
                        sb.Append("FROM SteelMesh_ClientPage A\n");
                        sb.Append("inner join SteelMesh_ClientPagePower B on A.id=B.clintpage_id\n");
                        sb.Append("where B.user_id='" + dr[0].ToString() + "'\n");
                        mycomT.CommandText = sb.ToString();
                        drT = mycomT.ExecuteReader();
                        while (drT.Read())
                        {
                            clientPageStr = clientPageStr + drT[0].ToString() + "<br />";
                        }
                        drT.Close();
                        drT     = null;
                        drow[5] = clientPageStr;
                        dt.Rows.Add(drow);
                    }
                    dr.Close();
                    dr = null;
                    ds.Tables.Add(dt);
                }
                else
                {
                    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;

                if (drT != null)
                {
                    drT.Close();
                    drT = null;
                }
                if (myconT.State != ConnectionState.Closed)
                {
                    myconT.Close();
                }
                myconT = null;
            }
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(new { code = code, msg = msgStr, count = totalCount, data = ds.Tables[0] }));    //返回JSON数据
            ds.Dispose();
            ds = null;
        }
示例#18
0
        public void ProcessRequest(HttpContext context)
        {
            /*string returnStr = "";
             * SqlConnection mycon = null;
             * SqlCommand com = null;
             * SqlDataReader dr = null;
             * context.Response.ContentType = "text/plain";
             * //context.Response.Write("Hello World");
             * string userStr = context.Request.Form["user"];
             * userStr = userStr.Trim();
             * string pwdStr = context.Request.Form["password"];
             * pwdStr = pwdStr.Trim();
             * string checkedStr = context.Request.Form["checked"];
             * mycon = DBConnect.ConnectSQLServer();
             * try
             * {
             *  mycon.Open();
             *  string SQLText = "select user_id,name,username,opid,dept,telephone,email,weixin_no from User_Manage where (username='******' or email='" + userStr.ToLower() + "' or opid='" + userStr.ToUpper() + "') and password='******' and user_state='1'";
             *  com = mycon.CreateCommand();
             *  com.CommandText = SQLText;
             *  dr = com.ExecuteReader();
             *  int userCount = 0;
             *  while (dr.Read())
             *  {
             *      userCount++;
             *      //将用户信息保存至session中,客户端网页关闭后自动清除
             *      context.Session["user_id"] = dr[0].ToString();
             *      context.Session["Name"] = dr[1].ToString();
             *      context.Session["UserName"] = dr[2].ToString();
             *      context.Session["OPID"] = dr[3].ToString();
             *      context.Session["Department"] = dr[4].ToString();
             *      context.Session["Telephone"] = dr[5].ToString();
             *      context.Session["Email"] = dr[6].ToString();
             *      context.Session["WeiXin"] = dr[7].ToString();
             *      break;
             *  }
             *  if (userCount > 0)
             *  {
             *      returnStr = "OK";
             *      if (checkedStr.ToLower() == "true" && object.Equals(context.Request.Cookies["UserName"], null) && object.Equals(context.Request.Cookies["Password"], null))
             *      {
             *          context.Response.Cookies["UserName"].Value = userStr;
             *          context.Response.Cookies["Password"].Value= pwdStr;
             *          context.Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(1);
             *          context.Response.Cookies["Password"].Expires = DateTime.Now.AddDays(1);
             *      }
             *  }
             *  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;
             * }*/
            string        returnStr = "";
            SqlConnection mycon     = null;
            SqlCommand    com       = null;
            SqlDataReader dr        = null;

            context.Response.ContentType = "text/plain";
            string nameStr = "", opidStr = "", deptStr = "", deptDesStr = "", postStr = "", telephoneStr = "", emailStr = "";
            string create_timeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string update_timeStr = create_timeStr;
            bool   LoginFlag      = false;
            //context.Response.Write("Hello World");
            string userStr = context.Request.Form["user"];

            userStr = userStr.Trim().ToLower();
            if (!userStr.Contains("acn\\"))
            {
                userStr = "acn\\" + userStr;
            }
            string pwdStr = context.Request.Form["password"];

            pwdStr = pwdStr.Trim();
            string checkedStr = context.Request.Form["checked"];

            //DA验证登陆
            using (DirectoryEntry adsEntry = new DirectoryEntry(ConfigurationManager.AppSettings["DAVerify"].ToString(), userStr, pwdStr, AuthenticationTypes.Secure))
            {
                using (DirectorySearcher adsSearcher = new DirectorySearcher(adsEntry))
                {
                    adsSearcher.Filter = "(sAMAccountName=" + userStr.Substring(4) + ")";
                    adsSearcher.PropertiesToLoad.Add("msrtcsip-userenabled");
                    adsSearcher.PropertiesToLoad.Add("mobile");
                    adsSearcher.PropertiesToLoad.Add("mail");
                    adsSearcher.PropertiesToLoad.Add("title");
                    try
                    {
                        SearchResult             adsSearchResult = adsSearcher.FindOne();
                        ResultPropertyCollection rprops          = adsSearchResult.Properties;
                        foreach (string name in rprops.PropertyNames)
                        {
                            foreach (object vl in rprops[name])
                            {
                                switch (name)
                                {
                                case "msrtcsip-userenabled":
                                    LoginFlag = Convert.ToBoolean(vl.ToString());
                                    break;

                                case "mobile":
                                    telephoneStr = vl.ToString();
                                    break;

                                case "mail":
                                    emailStr = vl.ToString().ToLower();
                                    break;

                                case "title":
                                    postStr = vl.ToString();
                                    break;
                                }
                            }
                        }
                        ServiceReference1.Service1SoapClient getUserClient = new ServiceReference1.Service1SoapClient();
                        DataTable dt = getUserClient.GeteOAUserForDCC(userStr);
                        foreach (DataRow row in dt.Rows)
                        {
                            foreach (DataColumn column in dt.Columns)
                            {
                                switch (column.Caption)
                                {
                                case "var_hrid":
                                    opidStr = row[column].ToString().ToUpper();
                                    break;

                                case "var_name":
                                    nameStr = row[column].ToString();
                                    break;

                                case "var_dept":
                                    deptStr = row[column].ToString().ToUpper();
                                    break;

                                case "var_deptname":
                                    deptDesStr = row[column].ToString().ToUpper();
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        returnStr = ex.Message;
                    }
                    finally
                    {
                        adsEntry.Close();
                    }
                }
            }
            StringBuilder sb = new StringBuilder();

            if (LoginFlag && returnStr == "")
            {
                mycon = DBConnect.ConnectSQLServer();
                //DA认证成功后,查询数据表里是否有维护上面查询到的部门和职务,若没有则插入对应的数据表并返回部门或职务对应的id号,并将用户信息更新到数据表里,同时初始化权限
                try
                {
                    mycon.Open();
                    com = mycon.CreateCommand();
                    //部门
                    if (deptStr != "")
                    {
                        sb.Clear();
                        sb.Append("if not exists(select id from Department_Manage where dept_code='" + deptStr + "')\n");
                        sb.Append("begin\n");
                        sb.Append("insert into Department_Manage(dept,dept_code,create_by,create_time,update_by,update_time)\n");
                        sb.Append("values('" + deptDesStr + "','" + deptStr + "',(select max(user_id) from User_Manage)+1,'" + create_timeStr + "',(select max(user_id) from User_Manage)+1,'" + update_timeStr + "')\n");
                        sb.Append("end");
                        com.CommandText = sb.ToString();
                        com.ExecuteNonQuery();
                        com.CommandText = "select id from Department_Manage where dept_code='" + deptStr + "'";
                        deptStr         = com.ExecuteScalar().ToString();
                    }
                    //职务
                    if (postStr != "")
                    {
                        sb.Clear();
                        sb.Append("if not exists(select id from Job_Manage where post='" + postStr + "')\n");
                        sb.Append("begin\n");
                        sb.Append("insert into Job_Manage(post,create_by,create_time,update_by,update_time)\n");
                        sb.Append("values('" + postStr + "',(select max(user_id) from User_Manage)+1,'" + create_timeStr + "',(select max(user_id) from User_Manage)+1,'" + update_timeStr + "')\n");
                        sb.Append("end");
                        com.CommandText = sb.ToString();
                        com.ExecuteNonQuery();
                        com.CommandText = "select id from Job_Manage where post='" + postStr + "'";
                        postStr         = com.ExecuteScalar().ToString();
                    }
                    //将用户插入数据表或更新用户信息
                    userStr = userStr.Substring(4);
                    sb.Clear();
                    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 + "','" + userStr + "','" + opidStr + "','" + pwdStr + "','" + deptStr + "','" + postStr + "','" + telephoneStr + "','" + emailStr + "','','1',(select max(user_id) from User_Manage)+1,'" + create_timeStr + "',(select max(user_id) from User_Manage)+1,'" + update_timeStr + "')\n");
                    sb.Append("end\n");
                    sb.Append("else\n");
                    sb.Append("begin\n");
                    sb.Append("update User_Manage set name='" + nameStr + "',username='******',password='******',opid='" + opidStr + "',dept='" + deptStr + "',post='" + postStr + "',telephone='" + telephoneStr + "',email='" + emailStr + "',update_time='" + update_timeStr + "' where (username='******' or opid='" + opidStr + "') and user_state='1'\n");
                    sb.Append("end\n");
                    sb.Append("select @@IDENTITY");
                    com.CommandText = sb.ToString();
                    string ret = com.ExecuteScalar().ToString();
                    //初始化用户权限
                    if (ret != "" && ret != null)
                    {
                        sb.Clear();
                        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,'','" + ret + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + ret + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' from Menu_Manage");
                        com.CommandText = sb.ToString();
                        sb.Clear();
                        com.ExecuteNonQuery();
                    }
                    //将用户信息保存至session中,客户端网页关闭后自动清除
                    string SQLText = "select user_id,name,username,opid,dept,telephone,email,weixin_no from User_Manage where (username='******' or opid='" + opidStr + "') and user_state='1'";
                    com.CommandText = SQLText;
                    dr = com.ExecuteReader();
                    int userCount = 0;
                    while (dr.Read())
                    {
                        userCount++;
                        //将用户信息保存至session中,客户端网页关闭后自动清除
                        context.Session["user_id"]    = dr[0].ToString();
                        context.Session["Name"]       = dr[1].ToString();
                        context.Session["UserName"]   = dr[2].ToString();
                        context.Session["OPID"]       = dr[3].ToString();
                        context.Session["Department"] = dr[4].ToString();
                        context.Session["Telephone"]  = dr[5].ToString();
                        context.Session["Email"]      = dr[6].ToString();
                        context.Session["WeiXin"]     = dr[7].ToString();
                        break;
                    }
                    returnStr = "OK";
                }
                catch (Exception msg)
                {
                    returnStr = msg.Message;
                }
                finally
                {
                    if (dr != null)
                    {
                        dr.Close();
                        dr = null;
                    }
                    if (mycon.State != ConnectionState.Closed)
                    {
                        mycon.Close();
                    }
                    mycon = null;
                }
            }
            context.Response.Write(returnStr);
        }
示例#19
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 codeStr = context.Request.Form["code"];

            codeStr = codeStr.ToUpper().Trim();
            string responsibleStr = context.Request.Form["responsible"];

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

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

            emailStr = emailStr.ToLower().Trim();
            string addressStr = context.Request.Form["address"];

            addressStr = addressStr.Trim();
            string statusStr = "1";
            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();
                if (idStr == "0")
                {
                    sb.Append("if not exists(select id from SteelMesh_Manufacturer_Management where name='" + nameStr + "')\n");
                    sb.Append("begin\n");
                    sb.Append("insert into SteelMesh_Manufacturer_Management(name,code,responsible,telephone,email,address,status,remark,create_by,create_time,update_by,update_time)\n");
                    sb.Append("values(N'" + nameStr + "',N'" + codeStr + "',N'" + responsibleStr + "','" + telephoneStr + "','" + emailStr + "',N'" + addressStr + "','" + statusStr + "',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";
                    }
                }
                else
                {
                    mycom.CommandText = "update SteelMesh_Manufacturer_Management set name=N'" + nameStr + "',code=N'" + codeStr + "',responsible=N'" + responsibleStr + "',telephone='" + telephoneStr + "',email='" + emailStr + "',address='" + addressStr + "',remark='" + remarkStr + "',update_by='" + context.Session["user_id"] + "',update_time='" + update_time + "' 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);
        }
示例#20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idStr = Request.QueryString["id"];

            //根据传入的id设置主旨内容
            if (idStr == "0")
            {
                h2Show.InnerText     = "新增详细储位";
                btnAddEdit.InnerText = "添加";
            }
            else
            {
                h2Show.InnerText     = "编辑详细储位";
                btnAddEdit.InnerText = "编辑";
            }
            input_id.Value = idStr;

            SqlConnection mycon = null;
            SqlCommand    mycom = null;
            SqlDataReader dr    = null;
            StringBuilder sb    = new StringBuilder();

            mycon = DBConnect.ConnectSQLServer();
            try
            {
                //查询部门清单到下拉列表框
                mycon.Open();
                mycom             = mycon.CreateCommand();
                mycom.CommandText = "select id,storage_name from SteelMesh_Storage_Management where status='1'";
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    storage_id.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString()));
                }
                dr.Close();
                //根据传入的id初始化对应的用户信息
                sb.Clear();
                sb.Append("select\n");
                sb.Append("A.id,B.id,B.storage_name,A.storage_name\n");
                sb.Append("from SteelMesh_Detail_Storage A\n");
                sb.Append("inner join SteelMesh_Storage_Management B on A.storage_id=B.id\n");
                sb.Append("where A.id='" + idStr + "'");
                mycom.CommandText = sb.ToString();
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    storage_name.Value       = dr[3].ToString();
                    storage_id.SelectedIndex = storage_id.Items.IndexOf(new ListItem(dr[2].ToString(), dr[1].ToString()));
                }
            }
            catch (Exception msg)
            {
                System.Console.WriteLine(msg.Message);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
                if (mycon.State != System.Data.ConnectionState.Closed)
                {
                    mycon.Close();
                }
                mycon = null;
            }
        }
示例#21
0
        public void ProcessRequest(HttpContext context)
        {
            string returnStr = "";

            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            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();
                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 + "',(select max(user_id) from User_Manage)+1,'" + create_timeStr + "',(select max(user_id) from User_Manage)+1,'" + 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,'','" + ret + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + ret + "','" + 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 = "账号已存在,请确认!";
                }
            }
            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);
        }
示例#22
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     = "";
            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 ProductLine_Management\n");
                if (condition != "")
                {
                    sb.Append("WHERE pl_name LIKE '%" + condition + "%' OR code LIKE '%" + condition + "%' OR workshop_id=(select id from Workshop_Manage where ws_name='" + condition + "')\n");
                }
                mycom.CommandText = sb.ToString();
                sb.Clear();
                dr = mycom.ExecuteReader();
                while (dr.Read())
                {
                    totalCount = Convert.ToInt32(dr[0].ToString());
                }
                dr.Close();
                dr = null;
                sb.Clear();
                sb.Append("SELECT top " + nums.ToString() + "\n");
                sb.Append("id,pl_name,code,address,(SELECT ws_name FROM Workshop_Manage WHERE id=ProductLine_Management.workshop_id) AS workshop,(SELECT name FROM User_Manage WHERE user_id=ProductLine_Management.ownerid) AS owner,remark\n");
                sb.Append("FROM\n");
                sb.Append("ProductLine_Management\n");
                if (condition != "")
                {
                    sb.Append("WHERE (pl_name LIKE '%" + condition + "%' OR code LIKE '%" + condition + "%' OR workshop_id=(select id from Workshop_Manage where ws_name='" + condition + "'))\n");
                    sb.Append("AND id not in (select top " + (nums * (curr - 1)).ToString() + " id from ProductLine_Management\n");
                    sb.Append("WHERE pl_name LIKE '%" + condition + "%' OR code LIKE '%" + condition + "%' OR workshop_id=(select id from Workshop_Manage where ws_name='" + condition + "'))\n");
                }
                else
                {
                    sb.Append("WHERE id not in (select top " + (nums * (curr - 1)).ToString() + " id from ProductLine_Management)\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;
        }
示例#23
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     = "";
            string         condition  = context.Request.QueryString["condition"].Trim();
            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_Manufacturer_Management\n");
                if (condition != "")
                {
                    sb.Append("WHERE name LIKE '%" + condition + "%' OR code LIKE '%" + condition + "%'\n");
                }
                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,name,code,responsible,telephone,email,address,status,remark\n");
                sb.Append("FROM\n");
                sb.Append("SteelMesh_Manufacturer_Management\n");
                if (condition != "")
                {
                    sb.Append("WHERE (name LIKE '%" + condition + "%' OR code LIKE '%" + condition + "%')\n");
                    sb.Append("and id not in (select top " + (nums * (curr - 1)).ToString() + " id from SteelMesh_Detail_Storage WHERE name LIKE '%" + condition + "%' OR code LIKE '%" + 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;
        }