private void GravarButton_Click(object sender, EventArgs e) { Sistema_bll sistema_Class = new Sistema_bll(_connection); usuarioStruct cUser = sistema_Class.Retorna_Usuario(nId); GTI_Models.Models.Usuario reg = new GTI_Models.Models.Usuario(); reg.Id = cUser.Id; reg.Nomecompleto = cUser.Nome_completo; reg.Nomelogin = cUser.Nome_login; reg.Ativo = cUser.Ativo; reg.Setor_atual = Convert.ToInt32(SetorComboBox.SelectedValue); Exception ex = sistema_Class.Alterar_Usuario(reg); if (ex == null) { DialogResult = DialogResult.OK; } else { DialogResult = DialogResult.Cancel; ErrorBox eBox = new ErrorBox("Atenção", ex.Message, ex); eBox.ShowDialog(); } Close(); }
private void LoadReg(int nId) { Clear_Reg(); Sistema_bll sistema_Class = new Sistema_bll(_connection); usuarioStruct reg = sistema_Class.Retorna_Usuario(nId); IdLabel.Text = Convert.ToInt32(reg.Id).ToString("0000"); NomeCompletoTextBox.Text = reg.Nome_completo; NomeLoginTextBox.Text = reg.Nome_login; LocalComboBox.SelectedValue = reg.Setor_atual == null ? -1 : reg.Setor_atual; LocalTextBox.Text = reg.Nome_setor; AtivoCheckbox.Checked = reg.Ativo == 1?true:false; bExec = false; List <Usuariocc> ListaCC = sistema_Class.Lista_Usuario_Local(nId); foreach (Usuariocc item in ListaCC) { for (int i = 0; i < LocalListBox.Items.Count; i++) { CustomListBoxItem linha = (CustomListBoxItem)LocalListBox.Items[i]; int nCodCC = linha._value; if (nCodCC == item.Codigocc) { LocalListBox.SetItemChecked(i, true); } } } bExec = true; }
public ActionResult User_query_doc() { LoginViewModel model = new LoginViewModel(); if (Session["hashid"] == null) { return(RedirectToAction("Login")); } bool _func = Session["hashfunc"].ToString() == "S" ? true : false; if (!_func) { return(RedirectToAction("Login")); } int _id = Convert.ToInt32(Session["hashid"].ToString()); if (_id != 392 && _id != 270 && _id != 118 && _id != 433 && _id != 427)//392-renata,270-joseane,118-elivaine ,433-schwartz, 427-rose { return(RedirectToAction("Login")); } Sistema_bll sistemaRepository = new Sistema_bll(_connection); int _fiscal = Convert.ToInt32(Functions.Decrypt(Request.Cookies["2uC*"].Value)); usuarioStruct reg = sistemaRepository.Retorna_Usuario(_fiscal); List <Usuario_Web_Analise_Struct> Lista = sistemaRepository.Lista_Usuario_Web_Analise(); model.Lista_Usuario_Web_Analise = Lista; return(View(model)); }
public ActionResult Checkguid(CertidaoViewModel model, string c) { Imovel_bll imovelRepository = new Imovel_bll(_connection); Itbi_isencao_main_Struct _itbi = imovelRepository.Retorna_Itbi_Isencao_Main(c); List <Itbi_isencao_imovel> _Lista = imovelRepository.Retorna_Itbi_Isencao_Imovel(c); ReportDocument rd = new ReportDocument(); rd.Load(System.Web.HttpContext.Current.Server.MapPath("~/Reports/Certidao_Isencao_Itbi_Valida.rpt")); TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); ConnectionInfo crConnectionInfo = new ConnectionInfo(); Tables CrTables; string myConn = ConfigurationManager.ConnectionStrings[_connection].ToString(); SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(myConn); string IPAddress = builder.DataSource; string _userId = builder.UserID; string _pwd = builder.Password; crConnectionInfo.ServerName = IPAddress; crConnectionInfo.DatabaseName = "Tributacao"; crConnectionInfo.UserID = _userId; crConnectionInfo.Password = _pwd; CrTables = rd.Database.Tables; foreach (Table CrTable in CrTables) { crtableLogoninfo = CrTable.LogOnInfo; crtableLogoninfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(crtableLogoninfo); } Sistema_bll sistemaRepository = new Sistema_bll(_connection); Assinatura assinatura = sistemaRepository.Retorna_Usuario_Assinatura(_itbi.Fiscal_id); usuarioStruct usuario = sistemaRepository.Retorna_Usuario(_itbi.Fiscal_id); rd.SetParameterValue("ANONUMERO", _itbi.Isencao_numero.ToString("00000") + "/" + _itbi.Isencao_ano.ToString("0000")); rd.SetParameterValue("NATUREZA", _itbi.Natureza_Nome); rd.SetParameterValue("NOMEFISCAL", usuario.Nome_completo); rd.SetParameterValue("CARGO", assinatura.Cargo); string imovel = ""; foreach (Itbi_isencao_imovel item in _Lista) { imovel += item.Descricao + ", "; } imovel = imovel.Substring(0, imovel.Length - 2); rd.SetParameterValue("IMOVEL", imovel); try { rd.RecordSelectionFormula = "{itbi_isencao_main.guid}='" + c + "'"; Stream stream = rd.ExportToStream(ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf", "Certidao_Isencao_Itbi_Valida.pdf")); } catch { throw; } }
public usuarioStruct Retorna_Usuario(int Id) { using (GTI_Context db = new GTI_Context(_connection)) { var reg = (from t in db.Usuario join cc in db.Centrocusto on t.Setor_atual equals cc.Codigo into tcc from cc in tcc.DefaultIfEmpty() where t.Id == Id orderby t.Nomelogin select new usuarioStruct { Nome_login = t.Nomelogin, Nome_completo = t.Nomecompleto, Ativo = t.Ativo, Id = t.Id, Senha = t.Senha, Senha2 = t.Senha2, Setor_atual = t.Setor_atual, Nome_setor = cc.Descricao }).FirstOrDefault(); usuarioStruct Sql = new usuarioStruct { Id = reg.Id, Nome_completo = reg.Nome_completo, Nome_login = reg.Nome_login, Senha = reg.Senha, Senha2 = reg.Senha2, Setor_atual = reg.Setor_atual, Nome_setor = reg.Nome_setor, Ativo = reg.Ativo }; return(Sql); } }
public List <usuarioStruct> Lista_Usuarios() { using (GTI_Context db = new GTI_Context(_connection)) { var reg = (from t in db.Usuario join cc in db.Centrocusto on t.Setor_atual equals cc.Codigo into tcc from cc in tcc.DefaultIfEmpty() where t.Ativo == 1 orderby t.Nomecompleto select new { t.Nomelogin, t.Nomecompleto, t.Ativo, t.Id, t.Senha, t.Setor_atual, cc.Descricao }).ToList(); List <usuarioStruct> Lista = new List <usuarioStruct>(); foreach (var item in reg) { usuarioStruct Linha = new usuarioStruct { Nome_login = item.Nomelogin, Nome_completo = item.Nomecompleto, Ativo = item.Ativo, Id = item.Id, Senha = item.Senha, Setor_atual = item.Setor_atual, Nome_setor = item.Descricao }; Lista.Add(Linha); } return(Lista); } }
private void LoginButton_Click(object sender, EventArgs e) { if (txtLogin.Text.Equals(string.Empty)) { MessageBox.Show("Digite o nome de login.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtPwd.Text.Equals(string.Empty)) { MessageBox.Show("Digite a senha.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } gtiCore.Ocupado(this); gtiCore.ServerName = txtServer.Text; string _connection = gtiCore.Connection_Name(); Sistema_bll sistema_Class = new Sistema_bll(_connection); try { string sUser = sistema_Class.Retorna_User_FullName(txtLogin.Text); gtiCore.Liberado(this); if (string.IsNullOrEmpty(sUser)) { gtiCore.Liberado(this); MessageBox.Show("Usuário não cadastrado!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string sPwd = sistema_Class.Retorna_User_Password(txtLogin.Text); string sPwdOld = sistema_Class.Retorna_User_Password_Old(txtLogin.Text); TAcessoFunction _access = new TAcessoFunction(); string _decrypt = _access.DecryptGTI(sPwdOld); if (string.IsNullOrEmpty(_decrypt)) { gtiCore.Liberado(this); MessageBox.Show("Por favor cadastre uma senha!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); SenhaButton_Click(null, null); return; } else { if (string.Compare(txtPwd.Text, _decrypt) != 0) { gtiCore.Liberado(this); MessageBox.Show("Senha inválida.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } catch (Exception ex) { gtiCore.Liberado(this); MessageBox.Show(ex.InnerException.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } gtiCore.LastUser = txtLogin.Text.ToUpper(); gtiCore.UserId = sistema_Class.Retorna_User_LoginId(txtLogin.Text); //gtiCore.LastUser = txtLogin.Text.ToUpper(); //Properties.Settings.Default.Save(); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["lastuser"].Value = txtLogin.Text.ToUpper(); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); int nId = gtiCore.UserId; LoadDBSettings(nId); usuarioStruct cUser = sistema_Class.Retorna_Usuario(nId); int? nSetor = cUser.Setor_atual; if (nSetor == null || nSetor == 0) { Usuario_Setor form = new Usuario_Setor(); form.nId = nId; var result = form.ShowDialog(this); if (result != DialogResult.OK) { return; } } gtiCore.UpdateUserBinary(); //Update user Binary //string sTmp = sistema_Class.GetUserBinary(nId); //int nSize = sistema_Class.GetSizeofBinary(); //GtiTypes.UserBinary = gtiCore.Decrypt(sTmp); //if (nSize > GtiTypes.UserBinary.Length) { // int nDif = nSize - GtiTypes.UserBinary.Length; // sTmp = new string('0', nDif); // GtiTypes.UserBinary += sTmp; //} // string h = GtiTypes.UserBinary; Close(); Main f1 = (Main)Application.OpenForms["Main"]; f1.UserToolStripStatus.Text = gtiCore.LastUser; f1.LockForm(false); gtiCore.Liberado(this); }
private void LoginButton_Click(object?sender, EventArgs?e) { if (LoginText.Text.Equals(string.Empty)) { MessageBox.Show("Digite o nome de login.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (PwdText.Text.Equals(string.Empty)) { MessageBox.Show("Digite a senha.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Ocupado(this); gtiProperty.ServerName = ServerText.Text; string _connection = gtiProperty.ConnectionString; if (string.IsNullOrEmpty(_connection)) { _connection = gtiCore.Connection_Name(); gtiProperty.ConnectionString = _connection; } Sistema_bll sistemaRepository = new Sistema_bll(_connection); try { string sUser = sistemaRepository.Retorna_User_FullName(LoginText.Text); //gtiCore.Liberado(this); if (string.IsNullOrEmpty(sUser)) { //gtiCore.Liberado(this); MessageBox.Show("Usuário não cadastrado!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string sPwd = sistemaRepository.Retorna_User_Password(LoginText.Text); if (string.IsNullOrEmpty(sPwd)) { // gtiCore.Liberado(this); MessageBox.Show("Por favor cadastre uma senha!", "Senha não cadastrada", MessageBoxButtons.OK, MessageBoxIcon.Error); SenhaButton_Click(null, null); return; } else { TAcessoFunction _tAcesso = new TAcessoFunction(); if (string.Compare(PwdText.Text, _tAcesso.DecryptGTI(sPwd)) != 0) { // gtiCore.Liberado(this); MessageBox.Show("Senha inválida.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); PwdText.Text = ""; return; } } } catch (Exception ex) { //gtiCore.Liberado(this); MessageBox.Show(ex.InnerException.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } gtiProperty.ServerName = ServerText.Text.ToUpper(); gtiProperty.LastUser = LoginText.Text.ToUpper(); gtiProperty.UserId = sistemaRepository.Retorna_User_LoginId(LoginText.Text); int nId = gtiProperty.UserId; usuarioStruct cUser = sistemaRepository.Retorna_Usuario(nId); int? nSetor = cUser.Setor_atual; if (nSetor == null || nSetor == 0) { //Usuario_Setor form = new Usuario_Setor(); //form.nId = nId; //var result = form.ShowDialog(this); //if (result != DialogResult.OK) // return; } gtiCore.UpdateUserBinary(); //Update user Binary //string sTmp = sistema_Class.GetUserBinary(nId); //int nSize = sistema_Class.GetSizeofBinary(); //GtiTypes.UserBinary = gtiCore.Decrypt(sTmp); //if (nSize > GtiTypes.UserBinary.Length) { // int nDif = nSize - GtiTypes.UserBinary.Length; // sTmp = new string('0', nDif); // GtiTypes.UserBinary += sTmp; //} // string h = GtiTypes.UserBinary; Close(); Main f1 = (Main)Application.OpenForms["Main"]; f1.UserToolStripStatus.Text = gtiProperty.LastUser; f1.LockForm(false); //gtiCore.Liberado(this); }
public ActionResult Login(LoginViewModel model) { string sLogin = model.Usuario.Trim(), sNewPwd = model.Senha, sOldPwd, sOldPwd2, sName; LoginViewModel loginViewModel = new LoginViewModel(); Sistema_bll sistemaRepository = new Sistema_bll(_connection); TAcessoFunction tacesso_Class = new TAcessoFunction(); bool bFuncionario = model.Usuario.LastIndexOf('@') > 1 ? false : true; Session["hashfunc"] = bFuncionario ? "S" : "N"; var cookieF = new HttpCookie("2fN*", Functions.Encrypt(bFuncionario ? "S" : "N")); cookieF.Expires = DateTime.Now.AddHours(1); System.Web.HttpContext.Current.Response.Cookies.Add(cookieF); Tributario_bll tributarioRepository = new Tributario_bll(_connection); Form_Redirect fr = new Form_Redirect(); if (bFuncionario) { sOldPwd = sistemaRepository.Retorna_User_Password(sLogin); int UserId = sistemaRepository.Retorna_User_LoginId(sLogin); if (sOldPwd == null) { Session.Remove("hashid"); ViewBag.Result = "Usuário/Senha inválido!"; return(View(loginViewModel)); } else { sOldPwd2 = tacesso_Class.DecryptGTI(sOldPwd); if (sOldPwd2 != sNewPwd) { ViewBag.Result = "Usuário/Senha inválido!"; Session.Remove("hashid"); return(View(loginViewModel)); } else { ViewBag.Result = ""; Session["hashid"] = UserId; } } if (UserId == 0) { ViewBag.Result = "Usuário/Senha inválido."; return(View(loginViewModel)); } usuarioStruct _user = sistemaRepository.Retorna_Usuario(UserId); if (_user.Ativo == 0) { ViewBag.Result = "Usuário inativo."; return(View(loginViewModel)); } else { Session["hashlname"] = _user.Nome_login; Session["hashfname"] = _user.Nome_completo; Session["hashfiscalitbi"] = _user.Fiscal_Itbi ? "S" : "N"; Session["hashfiscalpostura"] = _user.Fiscal_postura ? "S" : "N"; Session["hashfiscalmov"] = _user.Fiscal_mov ? "S" : "N"; Session["hashfiscal"] = _user.Fiscal ? "S" : "N"; if (Session["hashid"] == null) { Session.Add("hashid", _user.Id); Session.Add("hashfname", _user.Nome_completo); Session.Add("hashlname", _user.Nome_login); Session.Add("hashfiscalitbi", "N"); Session.Add("hashfiscalpostura", "N"); Session.Add("hashfiscalmov", "N"); Session.Add("hashfiscal", "N"); Session.Add("hashfunc", "N"); } int _userid = Convert.ToInt32(Session["hashid"]); bool _func = Session["hashfunc"].ToString() == "S" ? true : false; //log //LogWeb regWeb = new LogWeb() {UserId=_userid,Evento=1,Pref=true}; //sistemaRepository.Incluir_LogWeb(regWeb); //*** List <int> ListaUsoPlataforma = tributarioRepository.Lista_Rodo_Uso_Plataforma_UserEmpresa(_userid, _func); if (ListaUsoPlataforma.Count == 0) { ViewBag.UsoPlataforma = "N"; } else { ViewBag.UsoPlataforma = "S"; } // **Rememeber me if (model.RememberMe) { var cookie = new HttpCookie("2lG*", Functions.Encrypt(model.Usuario)); cookie.Expires = DateTime.Now.AddDays(30); System.Web.HttpContext.Current.Response.Cookies.Add(cookie); cookie = new HttpCookie("2pW*", Functions.Encrypt(model.Senha)); cookie.Expires = DateTime.Now.AddDays(30); System.Web.HttpContext.Current.Response.Cookies.Add(cookie); } else { Response.Cookies["2lG*"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["2pW*"].Expires = DateTime.Now.AddDays(-1); } //****************** var cookie2 = new HttpCookie("2lG1H*", Functions.Encrypt(model.Usuario)); cookie2.Expires = DateTime.Now.AddHours(1); System.Web.HttpContext.Current.Response.Cookies.Add(cookie2); var cookie3 = new HttpCookie("2uC*", Functions.Encrypt(_userid.ToString())); cookie3.Expires = DateTime.Now.AddHours(1); System.Web.HttpContext.Current.Response.Cookies.Add(cookie3); if (Session["hashform"] == null) { return(View("../Home/SysMenu")); } else { fr = RedirectToForm(Session["hashform"].ToString()); } } } else { Usuario_web user_web = sistemaRepository.Retorna_Usuario_Web(model.Usuario); if (user_web == null) { ViewBag.Result = "Usuário/Senha inválido."; return(View(loginViewModel)); } else { if (model.Senha != Functions.Decrypt(user_web.Senha)) { ViewBag.Result = "Usuário/Senha inválido."; return(View(loginViewModel)); } else { if (!user_web.Ativo) { ViewBag.Result = "Esta conta encontra-se inativa."; return(View(loginViewModel)); } else { if (user_web.Bloqueado) { ViewBag.Result = "Esta conta encontra-se bloqueada."; return(View(loginViewModel)); } else { Session["hashid"] = user_web.Id; Session["hashlname"] = user_web.Email; Session["hashfname"] = user_web.Nome; Session.Add("hashfiscalitbi", "N"); Session.Add("hashfiscal", "N"); Session.Add("hashfunc", "N"); int _userid = Convert.ToInt32(Session["hashid"]); bool _func = Session["hashfunc"].ToString() == "S" ? true : false; //log //LogWeb regWeb = new LogWeb() { UserId = _userid, Evento = 1, Pref = false }; //sistemaRepository.Incluir_LogWeb(regWeb); //*** // **Rememeber me if (model.RememberMe) { var cookie = new HttpCookie("2lG*", Functions.Encrypt(model.Usuario)); cookie.Expires = DateTime.Now.AddDays(30); System.Web.HttpContext.Current.Response.Cookies.Add(cookie); cookie = new HttpCookie("2pW*", Functions.Encrypt(model.Senha)); cookie.Expires = DateTime.Now.AddDays(30); System.Web.HttpContext.Current.Response.Cookies.Add(cookie); } else { Response.Cookies["2lG*"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["2pW*"].Expires = DateTime.Now.AddDays(-1); } //****************** var cookie2 = new HttpCookie("2lG1H*", Functions.Encrypt(model.Usuario)); cookie2.Expires = DateTime.Now.AddDays(1); System.Web.HttpContext.Current.Response.Cookies.Add(cookie2); var cookie3 = new HttpCookie("2uC*", Functions.Encrypt(user_web.Id.ToString())); cookie3.Expires = DateTime.Now.AddHours(1); System.Web.HttpContext.Current.Response.Cookies.Add(cookie3); List <int> ListaUsoPlataforma = tributarioRepository.Lista_Rodo_Uso_Plataforma_UserEmpresa(_userid, _func); if (ListaUsoPlataforma.Count == 0) { ViewBag.UsoPlataforma = "N"; } else { ViewBag.UsoPlataforma = "S"; } if (Session["hashform"] == null) { return(View("../Home/SysMenu")); } else { fr = RedirectToForm(Session["hashform"].ToString()); } } } } } } return(RedirectToAction(fr.Action, fr.Controller)); }