public static void LoadDatabase(TreeView projectView, ref DataBaseObjectClass aDataObject, ListView lstVwDatabaseTables) { DataBaseSelection openDatabase = new DataBaseSelection(); openDatabase.IntitialFolderPath = Application.StartupPath; if (openDatabase.ShowDialog() == DialogResult.OK) { projectView.Nodes[0].Nodes[0].Nodes.Clear(); DataLogin dataLogin = openDatabase.Connection; aDataObject = new DataBaseObjectClass(dataLogin.FromDatabase.DataBaseType); aDataObject.Connection(dataLogin.FromDatabase.ServerFile, dataLogin.FromDatabase.DatabaseName, dataLogin.FromDatabase.UserID, dataLogin.FromDatabase.Password, dataLogin.FromDatabase.Integrated); DataTable dt = aDataObject.GetSchemaData(SchemaRestrictions.Tables, null); lstVwDatabaseTables.Items.Clear(); if (dt != null) { foreach (DataRow aRow in dt.Rows) { lstVwDatabaseTables.Items.Add(aRow["TABLE_NAME"].ToString()); } projectView.Nodes[0].Nodes[0].Nodes.Add("Server: " + dataLogin.FromDatabase.ServerFile); projectView.Nodes[0].Nodes[0].Nodes.Add("Database Name: " + dataLogin.FromDatabase.DatabaseName); } else { MessageBox.Show("Restriction not valid"); } } }
private async void HomePage_Click(object sender, EventArgs e) { if (email.Text != " " && email.Text != " " && password.Text != null && password.Text != null) { DataLogin usuario = new DataLogin(); usuario.email = email.Text; usuario.password = password.Text; UserResponse response = FarmaciaService.Login(usuario); if (response.error != null) { await DisplayAlert("Ops!", response.error, "OK"); } else { await SecureStorage.SetAsync("userEmail", response.usuario.email); await SecureStorage.SetAsync("userName", response.usuario.firstName); await SecureStorage.SetAsync("avatar", response.usuario.avatar); await Navigation.PushAsync(new PedidosPage()); } } else { await DisplayAlert("Ops!", "CamposRequeridos", "OK"); } }
public ActionResult Login(DataLogin clog, string ReturnUrl) { if (ModelState.IsValid) { string userpassword = "******" /*db.QL_mstprof.Where(o => o.profoid.ToLower().Equals(clog.userid) && o.profstatus == "ACTIVE").Any() ? db.QL_mstprof.Where(o => o.profoid.ToLower().Equals(clog.userid) && o.profstatus == "ACTIVE").FirstOrDefault().profpass : ""*/; if (string.IsNullOrEmpty(userpassword)) { ModelState.AddModelError("", "User ID doesn't exist, please contact administrator"); } else { if (clog.userpwd.ToLower().Equals(userpassword.ToLower())) { SetUserSession(clog.userid); //if (!string.IsNullOrEmpty(ReturnUrl)) return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Incorrect Password"); } } } return(View(clog)); }
public ActionResult Login([FromBody] DataLogin LoginAuthen) { CreateLogin Body_Login = new CreateLogin(); Body_Login = _repo.Get_Find_Login(LoginAuthen.email, LoginAuthen.senha); if (Body_Login != null) { Ultimo_Login(Body_Login.id); return(SucessCreateLogin(Body_Login)); } else { return(HttpStatusCodeResult(401, "Usuário e/ou senha não batem")); } }
private void LoadAllUtilities() { UtilityDetails vendor = new UtilityDetails(); vendor.UtilityCode = ""; vendor.Active = true; DataLogin datafile = new DataLogin(); DataTable dataTable = datafile.GetAllUtilities(); //cboUtility.CurrentPageIndex = 0; cboUtility.DataSource = dataTable; cboUtility.DataValueField = "UtilityCode"; cboUtility.DataTextField = "UtilityCode"; cboUtility.DataBind(); }
public ActionResult Login(DataLogin pessoas) { var user = bd.Pessoas.FirstOrDefault(x => x.Email == pessoas.Email && x.Senha == pessoas.Senha && x.StatusId != 2); if (user != null) { user.UltimoAcesso = DateTime.Now; bd.Entry(user).State = EntityState.Modified; bd.SaveChanges(); FormsAuthentication.SetAuthCookie(user.PessoaId.ToString(), true); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Login", "Login", new { status = 1 })); } }
public Retorno Logar(Login Entity) { try { var retorno = new DataLogin().Consultar(Entity); if (retorno.IsValido && (retorno.Entity as Login).Codigo == 0) { return(new Retorno(false, Mensagens.MSG_07)); } return(new Retorno(retorno.Entity)); } catch (Exception ex) { return(Retorno.CriarRetornoExcecao(ex)); } }
private void tsbDbConnect_Click(object sender, EventArgs e) { DataBaseSelection openDatabase = new DataBaseSelection(); openDatabase.IntitialFolderPath = Application.StartupPath; if (openDatabase.ShowDialog() == DialogResult.OK) { DataLogin dataLogin = openDatabase.Connection; _aDataObject = new DataBaseObjectClass(dataLogin.FromDatabase.DataBaseType); _aDataObject.Connection(dataLogin.FromDatabase.ServerFile, dataLogin.FromDatabase.DatabaseName, dataLogin.FromDatabase.UserID, dataLogin.FromDatabase.Password, dataLogin.FromDatabase.Integrated); lblDB.Text = _aDataObject.DatabaseName; lblServer.Text = _aDataObject.ServerOrFile; TablesAndViewsUI.DataInitialization(_aDataObject); ProceduresAndFunctions.DataInitialization(_aDataObject); SQLView.DataInitialization(_aDataObject); } }
public Retorno VerificarLogin(Login login) { try { Retorno retorno = PreenchimentoObrigatorio(login); if (retorno.IsValido) { login.Senha = Seguranca.Criptografar(login.Senha, "VESTIRY"); retorno = ConsultarExistenciaSenha(); if (retorno.IsValido) { if (retorno.Entity != null && retorno.Entity.ConverteValor(0) == 1) { retorno = new DataLogin().Consultar(login); if (retorno.IsValido) { retorno.IsValido = retorno.Entity != null && ((Login)retorno.Entity).Codigo > 0; if (retorno.IsValido) { CarregarPermissoesFuncoes(retorno.Entity as Login); } else { retorno.Mensagem = Mensagens.MSG_30; } } } else { return(new BusinessLogin().Salvar(login)); } } } return(retorno); } catch (Exception ex) { return(Retorno.CriarRetornoExcecao(ex)); } }
public Retorno Salvar(Login Entity) { try { Retorno retorno = PreenchimentoObrigatorio(Entity); if (retorno.IsValido) { if (Entity.Codigo == 0) { retorno = new DataLogin().Incluir(Entity); } else { retorno = new DataLogin().Alterar(Entity); } } return(retorno); } catch (Exception ex) { return(Retorno.CriarRetornoExcecao(ex)); } }
public ActionResult Login(DataLogin user) { try { if (bd.pessoa.Any(x => x.email == user.email && x.senha == user.senha)) { var usuario = bd.pessoa.FirstOrDefault(x => x.email == user.email && x.senha == user.senha); FormsAuthentication.SetAuthCookie(usuario.pessoaId.ToString(), true); Session["PessoaId"] = usuario.pessoaId; return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Login", "Login", new { status = 2 })); } } catch { return(RedirectToAction("Login", "Login", new { status = 1 })); } }
public static UserResponse Login(DataLogin dataLogin) { var respuesta = ApiHelper.Post <UserResponse>("/login", dataLogin); return(respuesta); }
public ArrayList readExcelFile(string filePath, string extension) { ArrayList result = new ArrayList(); OleDbConnection oledbConn; try { dh = new DataLogin(); if (extension.ToUpper().Equals(".XLSX")) { oledbConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';"); } else { oledbConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.8.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;';"); } oledbConn.Open(); OleDbCommand cmd = new OleDbCommand();; OleDbDataAdapter oleda = new OleDbDataAdapter(); DataSet ds = new DataSet(); cmd.Connection = oledbConn; cmd.CommandType = CommandType.Text; DataTable dt1 = oledbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); String[] excelSheets = new String[dt1.Rows.Count]; int i = 0; // Add the sheet name to the string array. foreach (DataRow row in dt1.Rows) { excelSheets[i] = row["TABLE_NAME"].ToString(); i++; } string tableName = excelSheets[0].ToString(); ArrayList excelColumns = dh.GetExcelColNames(); string cols = ""; int intCols = excelColumns.Count; for (int p = 0; p < intCols; p++) { if (p == intCols - 1) { cols = cols + excelColumns[p].ToString().Replace(",", ""); } else { cols = cols + excelColumns[p].ToString().Replace(",", "") + ","; } } cmd.CommandText = "SELECT " + cols + " FROM [" + tableName + "]"; oleda = new OleDbDataAdapter(cmd); oleda.Fill(ds, "dsSlno"); DataTable dt = ds.Tables["dsSlno"]; for (int k = 0; k < dt.Rows.Count; k++) { string h = ""; for (int j = 0; j < excelColumns.Count; j++) { if (j == excelColumns.Count - 1) { h = h + dt.Rows[k][j].ToString().Replace(",", " "); } else { h = h + dt.Rows[k][j].ToString().Replace(",", " ") + ","; } } result.Add(h); } } catch (Exception ex) { throw ex; } return(result); }
public string ValidateColumNames(string filePath, string extension) { string result = ""; string wrongCols = ""; string correctCols = ""; OleDbConnection oledbConn; try { /* connection string to work with excel file. HDR=Yes - indicates * that the first row contains columnnames, not data. HDR=No - indicates * the opposite. "IMEX=1;" tells the driver to always read "intermixed" * (numbers, dates, strings etc) data columns as text. * Note that this option might affect excel sheet write access negative. */ if (extension.ToUpper().Equals(".XLSX")) { oledbConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';"); } else { oledbConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.8.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;';"); } oledbConn.Open(); OleDbCommand cmd = new OleDbCommand();; OleDbDataAdapter oleda = new OleDbDataAdapter(); DataSet ds = new DataSet(); cmd.Connection = oledbConn; cmd.CommandType = CommandType.Text; DataTable dt1 = oledbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); String[] excelSheets = new String[dt1.Rows.Count]; int i = 0; // Add the sheet name to the string array. foreach (DataRow row in dt1.Rows) { excelSheets[i] = row["TABLE_NAME"].ToString(); i++; } string tableName = excelSheets[0].ToString(); cmd.CommandText = "SELECT * FROM [" + tableName + "]"; oleda = new OleDbDataAdapter(cmd); oleda.Fill(ds, "dsSlno"); DataTable dt = ds.Tables["dsSlno"]; ArrayList columns = new ArrayList(); dh = new DataLogin(); ArrayList excelColumns = dh.GetExcelColNames(); if (dt.Columns.Count != excelColumns.Count) { result = "THE NUMBER OF FIELDS IN YOUR EXCEL FILE SHOULD BE " + excelColumns.Count; } else { ArrayList failedCols = new ArrayList(); foreach (DataColumn col in dt.Columns) { if (!excelColumns.Contains(col.ColumnName.ToUpper().Trim())) { failedCols.Add(col.ColumnName); wrongCols = wrongCols + col.ColumnName + ","; } } if (failedCols.Count > 0) { foreach (string s in excelColumns) { correctCols = correctCols + s + ","; } result = "THE FOLLOWING FIELDS IN YOUR EXCEL HAVE INVALID NAMES:" + wrongCols + ". THE CORRECT FIELD NAMES SHOULD BE: " + correctCols; } else { result = "YES"; } } } catch (Exception ex) { throw ex; } return(result); }
public ActionResult Autorization(DataLogin data) { ViewBag.error = ""; if (!ModelState.IsValid) { return(View("Index")); } else { using (var db = new RegistryEntities()) { User result = db.Users.FirstOrDefault (u => u.Dni.Equals(data.dm_Dni) && u.Code_login.Equals(data.dm_Code_login)); if (result != null) { if (data.dm_isManager) { if (result.Profile.Type == "Manager") { Debug.WriteLine("User is Manager"); DataUser dataUser = new DataUser(); dataUser.id = result.id; dataUser.Name = result.Name; dataUser.Last_name = result.Last_Name; dataUser.Type = result.Profile.Type; return(RedirectToAction("Index", "Manager", dataUser)); } else { //Debug.WriteLine("User not Found"); ViewBag.error = "User not Found"; } } else { if (result.Profile.Type == "Student") { Debug.WriteLine("User is Student"); //Llamar aqui al cambio de pagina. DataUser dataUser = new DataUser(); dataUser.id = result.id; dataUser.Name = result.Name; dataUser.Last_name = result.Last_Name; dataUser.Type = result.Profile.Type; return(RedirectToAction("Index", "Student", dataUser)); } else { Debug.WriteLine("User not Found"); ViewBag.error = "User not Found"; } } } else { ViewBag.error = "User not Found"; } } } return(View("Index"));//vamos a la pagina designada. }