public IHttpActionResult GetUser(string user, string pwd) { List <SalesStore> store = new List <SalesStore>(); List <User> userlist = new List <User>(); if (user == "admindev" && pwd == "_admin123") { userlist.Add(new Models.User { Username = user, Password = pwd, UserType = "4" }); } else { string sql = string.Format(@"SELECT [STMNAME] ,[STMPASSWORD] ,[STMSALESSTORETYPE] ,[STMUSERNAME] FROM [dbo].[STMSALESUSER] WHERE STMUSERNAME = '******' AND STMPASSWORD = '******'", user, pwd); DataTable dtUser = STM.QuerySelect(sql); if (dtUser.Rows.Count > 0) { //encode password byte[] encodebyte = System.Text.Encoding.UTF8.GetBytes(pwd); string encode = System.Convert.ToBase64String(encodebyte); userlist.Add(new Models.User { Username = user, Password = encode, UserType = dtUser.Rows[0]["StmSalesStoreType"].ToString() }); } else { userlist.Add(new Models.User { Username = "******" }); } } return(Json(userlist)); }
public ActionResult Index(string user) { string sql = string.Format(@"DECLARE @x AS varchar(60) = '{0}'; IF @x = 'admindev' Begin; SELECT [SALESAMOUNT] ,[SALESDATE] ,[SALESPOOLID] ,[SALESQTY] ,[STMSTOREID] ,[RECID] ,[CREATEDDATETIME] ,[CONFIRMDATE] ,[DUEDATE] ,[PURCHID] ,[SALESID] ,[SALESNAME] FROM [dbo].[STMSALESSODAILY] End; ELSE Begin; SELECT so.[SALESAMOUNT] ,so.[SALESDATE] ,so.[SALESPOOLID] ,so.[SALESQTY] ,so.[STMSTOREID] ,so.[RECID] ,so.[CREATEDDATETIME] ,so.[CONFIRMDATE] ,so.[DUEDATE] ,so.[PURCHID] ,so.[SALESID] ,so.[SALESNAME] ,u.[STMNAME] ,u.[STMPASSWORD] ,u.[STMSALESSTORETYPE] ,u.[STMUSERNAME] ,store.STMSTOREID ,store.STMSTORENAME FROM [dbo].[STMSALESUSER] u LEFT JOIN dbo.STMSALESSTORE store ON u.STMNAME = CASE WHEN u.STMSALESSTORETYPE = 4 THEN store.KEYACMANAGER WHEN u.STMSALESSTORETYPE = 3 THEN store.AREAMANAGER WHEN u.STMSALESSTORETYPE = 2 THEN store.SALESMANAGER WHEN u.STMSALESSTORETYPE = 1 THEN store.SALES END LEFT JOIN [dbo].[STMSALESSODAILY] so ON so.STMSTOREID = store.STMSTOREID WHERE STMUSERNAME = @x End;" , user); DataTable dt = STM.QuerySelect(sql); ViewData["Order"] = dt; string JSONresult; JSONresult = JsonConvert.SerializeObject(dt); return(View()); }