// Load store in combo public DataTable FillStore() { dbconnection.Connection con = new dbconnection.Connection(); SqlConnection connection = new SqlConnection(con.SetConnection()); DataTable dt = new DataTable(); try { connection.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT ID,Name From InfoRetailer Where Activity='Active'", connection); da.Fill(dt); DataRow row = dt.NewRow(); row["Name"] = "--Please select store--"; row["ID"] = 0; dt.Rows.InsertAt(row, 0); } catch (Exception ex) { return(dt); } finally { connection.Close(); } return(dt); }
public bool Valid_login(string UsrName, string UsrPass, string StoreId) { dbconnection.Connection conn = new dbconnection.Connection(); SqlConnection connection = new SqlConnection(conn.SetConnection()); try { if (UsrName == "admin") { sqltext = "SELECT UserName,Password FROM UserLogIn WHERE UserName='******' AND Password='******'"; } else { sqltext = "SELECT UserName,Password FROM UserLogIn WHERE UserName='******' AND Password='******' AND BranchID='" + StoreId + "'"; } connection.Open(); SqlCommand myCommand1 = new SqlCommand(sqltext, connection); object retVal = myCommand1.ExecuteScalar(); if (retVal != null) { return(true); } } catch (Exception ex) { throw ex; } finally { connection.Close(); } return(false); }