protected void Page_Load(object sender, EventArgs e) { if (Session["userid"] == null) Response.Redirect("~/Login.aspx"); Session.Add("url","Wishlist.aspx"); dw = new DeleteWishlist(); string userstr = "SELECT * from wishlist where userid = "+ Convert.ToInt16(Session["userid"]); con = new MyConnection(); c1 = con.GetConnection(); SqlCommand cmd = new SqlCommand(userstr, c1); c1.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { isWishlistEmpty = false; } else { isWishlistEmpty = true; } c1.Close(); }
// TODO(HonzaS): test the special subclasses of MyNode (Input/Output nodes etc.) public NodeConnectionTests() { m_node1 = new TestNode(); m_node2 = new TestNode(); m_connection = new MyConnection(m_node1, m_node2, 0, 0); m_connection.Connect(); }
public UpdateUser() { // // TODO: Add constructor logic here // con1 = new MyConnection(); con2 = new MyConnection(); con3 = new MyConnection(); con4 = new MyConnection(); }
public RegisterUser() { // // TODO: Add constructor logic here // // con1 = new MyConnection(); con2 = new MyConnection(); con3 = new MyConnection(); id = 0; con4 = new MyConnection(); }
/// <summary> /// Lấy top tin hot theo chuyên mục /// </summary> /// <param name="DatasetName"></param> /// <param name="nTop"></param> /// <param name="Lang"></param> /// <param name="CategoryID"></param> /// <param name="ArticleID"></param> /// <param name="ContentType"></param> /// <returns></returns> public DataSet GetTopHotArticleByCateID(string DatasetName, int nTop, string Lang, int CategoryID, string ContentType) { DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); try { string Sql = "SELECT TOP " + nTop.ToString() + " ArticleID, CategoryID, Lang, Title, Excerpt, [Content], ImageURL, ImageWidth, ImageHeight, ImageDesc, "; Sql += "Authors, PostDate, LastModificationDate, TotalViews, TotalRates, ArticleMark, Status, UserName, Keyword, ViewIndex "; Sql += "FROM Article WHERE IsHot=1 AND ContentType='" + ContentType + "' AND CategoryID = '" + CategoryID + "' AND Lang='" + Lang + "' ORDER By ArticleID DESC"; ds = ca.SelectData(DatasetName, Sql); } catch { } return(ds); }
public void AddProduct(Product p)//string name, string file, string ownerfk) { string sql = "INSERT into products (name, file, ownerfk, shareuser) values (@name, @file, @ownerfk, @shareuser)"; NpgsqlCommand cmd = new NpgsqlCommand(sql, MyConnection); cmd.Parameters.AddWithValue("@name", p.Name); cmd.Parameters.AddWithValue("@file", p.File); cmd.Parameters.AddWithValue("@ownerfk", p.OwnerFK); cmd.Parameters.AddWithValue("@shareuser", p.Shareuser); MyConnection.Open(); cmd.ExecuteNonQuery(); MyConnection.Close(); }
private IEnumerable <XElement> allItems(MyConnection connection, User CurrentUser) { var listXElementUser = connection.mXDoc.Descendants(XmlTags.USER); UserDAO dao = new UserDAO(); foreach (XElement element in listXElementUser) { User UserParent = dao.ReadUser(element); if (UserParent.Equals(CurrentUser) && CurrentUser.ID == UserParent.ID) { return(element.Descendants(XmlTags.ITEM)); } } return(null); }
public void AddFile(string name, string description, string ownerfk, string link) { string sql = "INSERT into files (name, description, ownerfk, link) values (@name, @description, @ownerfk, @link)"; NpgsqlCommand cmd = new NpgsqlCommand(sql, MyConnection); cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@description", description); cmd.Parameters.AddWithValue("@ownerfk", ownerfk); cmd.Parameters.AddWithValue("@link", link); MyConnection.Open(); cmd.ExecuteNonQuery(); MyConnection.Close(); }
public void AddUser(string email, string name, string surname) { string sql = "INSERT into users (email, name, surname, lastloggedin) values (@email, @name, @surname, @lastloggedin)"; NpgsqlCommand cmd = new NpgsqlCommand(sql, MyConnection); cmd.Parameters.AddWithValue("@email", email); cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@surname", surname); cmd.Parameters.AddWithValue("@lastloggedin", DateTime.Now); MyConnection.Open(); cmd.ExecuteNonQuery(); MyConnection.Close(); }
public AddOrders() { con1 = new MyConnection(); con2 = new MyConnection(); con3 = new MyConnection(); con4 = new MyConnection(); q = 0; p = 0; c_id = new List<int>(); gp_id = new List<int>(); quantity = new List<int>(); price = new List<int>(); }
private void FormInspectionType_Load(object sender, EventArgs e) { daInspectionType = Vetting.InspectionType.GetAdapter(MyConnection.GetConnection()); // TODO: This line of code loads data into the 'attendance.InspectionTypes' table. You can move, or remove it, as needed. daInspectionType.Fill(this.attendance.InspectionTypes); if (ApplicationInfo.ActiveUserMode == ApplicationInfo.UserMode.NormalUser) { this.InitializeRole(false); } else { this.InitializeRole(true); } }
private void InsertIntoDatabase(Battle toSave) { try { using (DbCommand cmd = MyConnection.CreateCommand()) { cmd.CommandText = SqlBattleInsert; SqlCeCommand ceCmd = cmd as SqlCeCommand; if (ceCmd != null) { ceCmd.Parameters.Add(new SqlCeParameter("@typ", SqlDbType.SmallInt)); ceCmd.Parameters.Add(new SqlCeParameter("@tst", SqlDbType.NVarChar)); ceCmd.Parameters.Add(new SqlCeParameter("@bid", SqlDbType.Int)); ceCmd.Parameters["@tst"].Size = 20; ceCmd.Prepare(); ceCmd.Parameters["@typ"].Value = toSave.GameType; ceCmd.Parameters["@tst"].Value = toSave.GameTypeString; ceCmd.Parameters["@bid"].Value = toSave.BattleId; } else { SqlCommand sqlCmd = cmd as SqlCommand; if (sqlCmd != null) { sqlCmd.Parameters.Add("@typ", SqlDbType.SmallInt); sqlCmd.Parameters["@typ"].Value = toSave.GameType; sqlCmd.Parameters.Add("@tst", SqlDbType.NVarChar); sqlCmd.Parameters["@tst"].Value = toSave.GameTypeString; sqlCmd.Parameters["@tst"].Size = 20; sqlCmd.Parameters.Add("@bid", SqlDbType.Int); sqlCmd.Parameters["@bid"].Value = toSave.BattleId; sqlCmd.Prepare(); } } cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } gridDao.SaveGrid(new Tuple <int, Grid>(toSave.BattleId, toSave.CurrentState)); } catch (Exception e) { throw new DAOException(String.Format("Error while creating new battle : {0}", e.Message)); } }
public DataSet SearchProduct(string DatasetName, int AgentCatID, string Lang, int CatID, int ProducerID) { DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); //try { string Sql = "SELECT ID, GroupID, TenGoi, ProducerID, MaSanPham, QuyCach, NgoaiTe, GiaBan, GiaThamKhao, GiaKhuyenMai, ThongTin1, ThongTin2, TonKho, TrangThai, Anh, DonViTinh "; Sql += "FROM ProductCat "; Sql += "WHERE AgentCatID = '" + AgentCatID + "' AND Lang = '" + Lang + "' "; Sql += " AND GroupID = '" + CatID + "' AND ProducerID = '" + ProducerID + "' ORDER BY ID DESC"; ds = ca.SelectData(DatasetName, Sql); } //catch { } return(ds); }
public DataSet GetProductByProductID(string DatasetName, int ProductID) { DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); try { string Sql = "SELECT p.ID, GroupID, MaSanPham, TenGoi, QuyCach, NgoaiTe, GiaBan, "; Sql += "GiaThamKhao, GiaKhuyenMai, ThongTin1, ThongTin2, TonKho, TrangThai, Anh, DonViTinh, "; Sql += "ProducerID, TotalViews, UserName, Keyword, IsNew, IsHot, IsBestSeller, DateCreated "; Sql += "FROM ProductCat as p WHERE p.ID = '" + ProductID + "'"; ds = ca.SelectData(DatasetName, Sql); } catch { } return(ds); }
public double GetTotalMarkByPollID(int PollID) { double TotalMark = 0; MyConnection ca = new MyConnection(); try { DataSet ds = GetPollAnswerByPollID("Poll", PollID, "VI"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { TotalMark += Convert.ToDouble(ds.Tables[0].Rows[i]["Mark"]); } } catch { } return(TotalMark); }
private void FormVettingRequest_Load(object sender, EventArgs e) { bs_vettingrequests = new BindingSource(); DataTable tbl = Vetting.VettingRequest.Select(MyConnection.GetConnection()); bs_vettingrequests.DataSource = tbl; bs_vettingrequests.PositionChanged += new EventHandler(bs_vettingrequests_PositionChanged); this.dgv_vettingrequest.DataSource = bs_vettingrequests; bs_requestShcedule = new BindingSource(); DataTable tbl_sch = Vetting.VettingRequest.SelectSchedule(MyConnection.GetConnection(), null); bs_requestShcedule.DataSource = tbl_sch; }
public EmploisTemp FindById(int id) { string Requete = "Select * from EmploisTemps where id=" + id; OleDbDataReader read = MyConnection.ExecuteReader(Requete); read.Read(); EmploisTemp f = new EmploisTemp(); f.Id = read.GetInt32(0); f.DateDebut = read.GetDateTime(1); f.DateFin = read.GetDateTime(2); // f.Anneeformation = read.GetDateTime(3); return(f); }
private void ConsultaDatos() { MyConnection nuevaConexion = new MyConnection(); nuevaConexion.abrirConexion(); MySqlCommand cmd = new MySqlCommand(Variables.accion, nuevaConexion.GetConexion()); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { direccion = reader[0].ToString(); contacto = reader[1].ToString(); telefono2 = reader[2].ToString(); cuenta = reader[3].ToString(); } }
/// <summary> /// Lấy tất cả danh sách bài viết phân theo loại ContentType /// </summary> /// <param name="DatasetName"></param> /// <param name="AgentCatID"></param> /// <param name="Lang"></param> /// <param name="ContentType">news: tin tức, real_estate: sàn giao dịch, apartment: căn hộ chung cư</param> /// <returns></returns> public DataSet GetAllArticle(string DatasetName, int AgentCatID, string Lang, string ContentType, string OrderBy) { DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); try { string Sql = "SELECT ArticleID, CategoryID, Lang, Title, Excerpt, [Content], ImageURL, ImageWidth, ImageHeight, ImageDesc, "; Sql += "Authors, PostDate, LastModificationDate, TotalViews, TotalRates, ArticleMark, Status, UserName, Keyword, ViewIndex "; Sql += "FROM Article WHERE ContentType='" + ContentType + "' AND AgentCatID = '" + AgentCatID + "' AND Lang = '" + Lang + "' "; Sql += "ORDER By ArticleID " + OrderBy; ds = ca.SelectData(DatasetName, Sql); } catch { } return(ds); }
/// <summary> /// Lấy tất cả công ty /// </summary> /// <param name="DatasetName"></param> /// <param name="ParentID">126</param> /// <param name="Lang"></param> /// <returns></returns> public DataSet GetAllAgentCat(string DatasetName, int ParentID, string Lang) { DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); try { string Sql = "SELECT ID, AgentCode, AgentUsername, AgentPassword, AgentName" + Lang + ", AgentNameHidden, ContactName, Address" + Lang + ", Introduction" + Lang + ", "; Sql += "ProvinceID, Tel, Fax, Email, Yahoo, Skype, Website, Logo, Visitors, ParentID, "; Sql += "FacultyID, IsHot, OrderNumber, Keyword, CreationDate, HostName, UploadHost, Visible "; Sql += "FROM AgentCat WHERE ParentID='" + ParentID + "' ORDER By ID DESC"; ds = ca.SelectData(DatasetName, Sql); } catch { } return(ds); }
public override BusinessObject get(MyConnection connection, int id) { Category Category = null; string query = "SELECT * FROM Category where ID = " + id; var cmd = new MySqlCommand(query, connection.ConnectionMysql); var reader = cmd.ExecuteReader(); while (reader.Read()) { Category = new Category((string)reader["Title"], (int)reader["ID"]); } return(Category); }
//Add user public void AddUser(string email, string name, string surname) { //To avoid sql injection we add the values using parameters such as @email. string sql = "INSERT INTO users (email, name, surname, lastloggedin) VALUES(@email, @name, @surname, @lastLoggedIn)"; NpgsqlCommand cmd = new NpgsqlCommand(sql, MyConnection); cmd.Parameters.AddWithValue("@email", email); cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@surname", surname); cmd.Parameters.AddWithValue("@lastLoggedIn", DateTime.UtcNow); //Connection is Opend and closed after Adding the new user MyConnection.Open(); cmd.ExecuteNonQuery(); MyConnection.Close(); }
public void ConsultaUsuario() { MyConnection nuevaConexion = new MyConnection(); nuevaConexion.abrirConexion(); MySqlCommand cmd = new MySqlCommand(Variables.accion, nuevaConexion.GetConexion()); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Nombre.Text = Convert.ToString(reader[0]); Usuario.Text = Convert.ToString(reader[1]); pass.Text = Convert.ToString(reader[2]); ConfirmaPass.Text = Convert.ToString(reader[2]); } }
public Groupe FindByName(string Name) { string Requete = "Select * from Groupes where Nom='Groupe 1'"; OleDbDataReader read = MyConnection.ExecuteReader(Requete); read.Read(); Groupe g = new Groupe(); g.Id = read.GetInt32(0); g.Code = read.GetString(1); g.Nom = read.GetString(2); g.Filiere = new FiliereDAO().FindById(read.GetInt32(3)); MyConnection.Close(); return(g); }
public DataSet GetCustomerByCustomerUsername(string DatasetName, int AgentCatID, string CustomerUsername) { DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); try { string Sql = "SELECT CustomerID, CustomerParentID, AgentCatID, CustomerCode, CustomerEmail, CustomerUsername, CustomerPassword, CustomerFullName, CustomerAddress, "; Sql += "CustomerIDNumber, CustomerPassport, CustomerDes, CustomerMobi, CustomerTel, CustomerFax, CustomerGender, CustomerUserEmail, CustomerIntroCode, "; Sql += "CustomerPercent, CustomerIntroEmail, CustomerAddDate, CustomerUpdate, CustomerContent, IsGetOfferEmail, Stat "; Sql += "FROM Customer WHERE CustomerUsername='******' AND AgentCatID = '" + AgentCatID + "'"; ds = ca.SelectData(DatasetName, Sql); } catch { } return(ds); }
public DataSet SearchEntrepreneur(string DatasetName, int ParentAgentCatID, string Lang, string Name) { DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); try { string Sql = "SELECT ID, AgentCatID, Username, FirstName" + Lang + ", LastName" + Lang + ", Position" + Lang + ", BirthDay, ImageURL, GroupID, Sex, ParentAgentCatID, Visitors, CreationDate, LastUpdate "; Sql += "FROM Entrepreneur WHERE ParentAgentCatID='" + ParentAgentCatID + "' "; Sql += "AND (FullNameVI LIKE N'%" + Name + "%' OR FullNameEN LIKE N'%" + Name + "%') "; Sql += "ORDER By CreationDate DESC"; ds = ca.SelectData(DatasetName, Sql); } catch { } return(ds); }
public bool DoesEmailExist(string email) { string sql = "Select Count(*) from users where email = @email"; NpgsqlCommand cmd = new NpgsqlCommand(sql, MyConnection); cmd.Parameters.AddWithValue("@email", email); MyConnection.Open(); bool result = Convert.ToBoolean(cmd.ExecuteScalar()); MyConnection.Close(); return(result); }
/// <summary> /// This method takes a Person object as a parameter /// and inserts its data as a new database record /// </summary> /// <param name="newPerson"></param> public void insertPerson(Person newPerson) { //Opening and closing methods already check for possible exceptions. No need to wrap them around try catch again //Instantiating necessary objects connection = new MyConnection(); connection.myCommand = new SqlCommand(); List <Person> PersonList = new List <Person>(); //Opening DB connection -> setting SQL sentence as a SqlCommand object -> SQLCommand object executes the code and returns //a new reader, passed to our own reader -> Reader returns queried information, if any connection.openConnection(); //Passing myConnection property to myCommand's own connection property connection.myCommand.Connection = connection.myConnection; connection.myCommand.CommandText = "INSERT INTO Persons (FirstName, LastName, Birthdate, Email, PhoneNumber, DepartmentID)" + " VALUES (@FirstName, " + " @LastName, " + " CONVERT(date, @Birthdate, 103), " + " @Email, " + " @PhoneNumber, " + " @DepartmentID)"; //DepartmentID should be verified connection.myCommand.Parameters.Add("@FirstName", System.Data.SqlDbType.NVarChar).Value = newPerson.FirstName; connection.myCommand.Parameters.Add("@LastName", System.Data.SqlDbType.NVarChar).Value = newPerson.LastName; connection.myCommand.Parameters.Add("@Birthdate", System.Data.SqlDbType.Date).Value = newPerson.Birthdate; connection.myCommand.Parameters.Add("@Email", System.Data.SqlDbType.NVarChar).Value = newPerson.Email; connection.myCommand.Parameters.Add("@PhoneNumber", System.Data.SqlDbType.NVarChar).Value = newPerson.PhoneNumber; connection.myCommand.Parameters.Add("@DepartmentID", System.Data.SqlDbType.Int).Value = newPerson.DepartmentID; //Executing non-query statement andPassing the value of rows affected to our handler's property try { this.rowsAffected = connection.myCommand.ExecuteNonQuery(); } catch (InvalidOperationException e) { throw e; } catch (SqlException e) { throw e; } //Closing connection this.connection.closeConnection(); }
public List <Module> findbyname(Module m) { string req = "select * from [modules]"; if (m.Nom != "" || m.Description != "" || m.Id_f.Id != 0 || m.Duree != 0) { req += " where "; } bool and = false; if (m.Nom != "") { req += " nom like '%" + m.Nom + "%'"; and = true; } if (m.Id_f.Id != 0) { req += " and Filiere_id like '%" + m.Id_f.Id + "%'"; and = true; } if (m.Description != null) { if (and) { req += " and description like '%" + m.Description + "%'"; } and = true; } if (m.Duree != null) { if (and) { req += " and duree like " + m.Duree; } } List <Module> liste = new List <Module>(); OleDbDataReader da = MyConnection.ExecuteReader(req); while (da.Read()) { liste.Add(new Module(da.GetInt32(0), new PackageFilieres.FiliereDAO().FindById(da.GetInt32(1)), da.GetString(2), da.GetInt32(3), da.GetString(4), da.GetString(5), da.GetString(6), da.GetString(7), da.GetString(8), da.GetString(9), da.GetString(10), da.GetString(11), da.GetString(12))); } return(liste); }
public void SimulationStateChangedOnNodesTest() { var simulation = new MyLocalSimulation(); var handler = new MySimulationHandler(simulation); MyProject project = new MyProject { Network = new MyNetwork() }; project.CreateWorld(typeof(MyTestingWorld)); var node = project.CreateNode<TestingNode>(); node.Event = new AutoResetEvent(false); project.Network.AddChild(node); var connection = new MyConnection(project.Network.GroupInputNodes[0], project.Network.Children[0]); connection.Connect(); project.Network.PrepareConnections(); handler.Project = project; handler.UpdateMemoryModel(); handler.StartSimulation(oneStepOnly: false); node.Event.WaitOne(); Assert.Equal(MySimulationHandler.SimulationState.STOPPED, node.PreviousState); Assert.Equal(MySimulationHandler.SimulationState.RUNNING, node.CurrentState); handler.PauseSimulation(); node.Event.WaitOne(); Assert.Equal(MySimulationHandler.SimulationState.RUNNING, node.PreviousState); Assert.Equal(MySimulationHandler.SimulationState.PAUSED, node.CurrentState); handler.StartSimulation(oneStepOnly: true); node.Event.WaitOne(); // Here the sim goes from paused to RUNNING_STEP. Assert.Equal(MySimulationHandler.SimulationState.PAUSED, node.PreviousState); Assert.Equal(MySimulationHandler.SimulationState.RUNNING_STEP, node.CurrentState); node.Event.WaitOne(); // Here it goes to PAUSED. Assert.Equal(MySimulationHandler.SimulationState.RUNNING_STEP, node.PreviousState); Assert.Equal(MySimulationHandler.SimulationState.PAUSED, node.CurrentState); handler.StopSimulation(); node.Event.WaitOne(); Assert.Equal(MySimulationHandler.SimulationState.PAUSED, node.PreviousState); Assert.Equal(MySimulationHandler.SimulationState.STOPPED, node.CurrentState); handler.Finish(); }
private void GuardaVehiculo() { Variables.accion = "INSERT INTO vehiculos (Marca, Modelo, Color, Fabricacion, Transmision, Tipo, Placa, Descripcion, Precio, Estatus) Values" + "('" + marca.Text + "','" + modelo.Text + "','" + color.Text + "','" + fabricacion.Text + "','" + transmision.Text + "','" + tipo.Text + "'," + "'" + placa.Text + "','" + descripcion.Text + "'," + "'" + precio.Text + "','DISPONIBLE' )"; MessageBox.Show(Variables.accion); MyConnection cons = new MyConnection(); cons.abrirConexion(); MySqlCommand pro = new MySqlCommand(Variables.accion); pro.Connection = cons.GetConexion(); pro.ExecuteNonQuery(); cons.cerrarConexion(); MessageBox.Show("Vehiculo guardado exitosamente", "¡Insercion Exitosa!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public bool IsUserExistent(string Username, int AgentCatID) { bool IsExistent = false; DataSet ds = new DataSet(); MyConnection ca = new MyConnection(); try { ds = GetUserByUsername("UserCat", Username, AgentCatID); if (ds.Tables[0].Rows.Count > 0) //có Username này rùi! { IsExistent = true; } } catch { } return(IsExistent); }
public PageListView <TEntity> FindAllPages(long from, long to, Expression <Func <TEntity, bool> > expression, Expression <Func <TEntity, object> > field, bool isDesc = false) { var queryResult = SqlGenerator.GetSelectAll(expression); var countResult = SqlGenerator.GetSelectCount(queryResult.Sql, queryResult.Param); var pageResult = SqlGenerator.GetSelectPages(from, to, queryResult.Sql, queryResult.Param, field, isDesc); var Connection = MyConnection.Pop(); var result = new PageListView <TEntity> { PageIndex = from, PageSize = to, DataRows = Convert.ToInt64(Connection.ExecuteScalar(countResult.Sql, countResult.Param)), Data = Connection.Query <TEntity>(pageResult.Sql, pageResult.Param) as List <TEntity> }; MyConnection.Push(Connection); return(result); }
public List <Groupe> Select() { string Requete = "Select * from Groupes"; List <Groupe> ListGroupe = new List <Groupe>(); OleDbDataReader read = MyConnection.ExecuteReader(Requete); while (read.Read()) { Groupe g = new Groupe(); g.Id = read.GetInt32(0); g.Code = read.GetString(1); g.Nom = read.GetString(2); ListGroupe.Add(g); } MyConnection.Close(); return(ListGroupe); }
private void GuardaNuevo() { try { MyConnection cons = new MyConnection(); cons.abrirConexion(); MySqlCommand pro = new MySqlCommand(Variables.accion); pro.Connection = cons.GetConexion(); pro.ExecuteNonQuery(); cons.cerrarConexion(); Variables.se_guardo = "SI"; } catch { Variables.se_guardo = "NO"; } }
private void ActualizaUsuario() { MyConnection conecta = new MyConnection(); conecta.abrirConexion(); string actulizar = "UPDATE usuarios SET NOMBRE=@C2, USER=@C3, PASS=@C4 WHERE CLAVE='" + this.laClave + "'"; MySqlCommand ejecuta = new MySqlCommand(actulizar); ejecuta.Connection = conecta.GetConexion(); ejecuta.Parameters.AddWithValue("@C2", (Nombre.Text)); ejecuta.Parameters.AddWithValue("@C3", (Usuario.Text)); ejecuta.Parameters.AddWithValue("@C4", (pass.Text)); MessageBox.Show("Usuario actualizado correctamente ", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); conecta.GetConexion(); ejecuta.ExecuteNonQuery(); conecta.cerrarConexion(); }
private void btnYesClick(object sender, EventArgs e) { connection = new MyConnection(); try { connection = new MyConnection(); com = new SqlCommand("DELETE FROM KTR WHERE id=@id"); com.Parameters.AddWithValue("@id", id); connection.executeMyQuery(com); connection.closeMyConnection(); this.Close(); } catch (SqlException ex) { connection.closeMyConnection(); throw ex; } }
private bool ValidateCredentials(string userName, string password) { bool returnValue = false; if (this.IsAlphaNumeric(this.username_textbox.Text) && this.username_textbox.Text.Length <= 50 && this.password_textbox.Text.Length <= 50) { using (var authDB = new MyConnection()) { try { if (authDB.Authentication.Where(x => x.Username == userName).Count() == 0) { statusLabel.Text = "No user found"; return false; } var verify = authDB.Authentication.Where(x => x.Username == userName).First(); if (PasswordHash.PasswordHash.ValidatePassword(password, verify.Password)) { return true; } else { statusLabel.Text = "Invalid Username/Password"; } } catch (Exception err) { statusLabel.Text = "Error: " + err.Message; return false; } } } else { statusLabel.Text = "Username/Password exceeded character limit"; return false; } return returnValue; }
public MyConnectionTest() { this._name = "MyName"; this._uris = new[] { "uri_0", "uri_1", "uri_2", "uri_3", "uri_4" }; this._connectorMock = new Mock<IMyConnector>(MockBehavior.Strict); this._connectorFactoryMock = new Mock<IMyConnectorFactory>(MockBehavior.Strict); this._connectorFactoryMock.Setup(f => f.Create(this._uris, It.IsAny<IConnectionEventFirer>())).Returns(this._connectorMock.Object); this._subscriptionManagerMock = new Mock<IMySubscriptionManager>(MockBehavior.Strict); this._subscriptionManagerFactoryMock = new Mock<IMySubscriptionManagerFactory>(MockBehavior.Strict); this._subscriptionManagerFactoryMock.Setup(f => f.Create(this._name, this._connectorMock.Object)).Returns(this._subscriptionManagerMock.Object); this._connection = new MyConnection( this._name, this._uris, this._connectorFactoryMock.Object, this._subscriptionManagerFactoryMock.Object); }
private void btnGetClick(object sender, EventArgs e) { lblInfo.Text = ""; try { myConnection = new MyConnection(); dataReader = myConnection.executeMyQuery("SELECT * FROM KTR ORDER BY id DESC"); dataGridView.Rows.Clear(); while (dataReader.Read()) { readSingleRow((IDataRecord)dataReader); } myConnection.closeMyConnection(); } catch (SqlException ex) { lblInfo.Text = ex.Message; myConnection.closeMyConnection(); } }
void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e) { bool isHidden = (Control.ModifierKeys & Keys.Shift) != 0; MyNode fromNode = (e.Connection.From.Node as MyNodeView).Node; MyNode toNode = (e.Connection.To.Node as MyNodeView).Node; int fromIndex = (int) e.Connection.From.Item.Tag; int toIndex = (int) e.Connection.To.Item.Tag; if (toNode.AcceptsConnection(fromNode, fromIndex, toIndex)) { MyConnection newConnection = new MyConnection(fromNode, toNode, fromIndex, toIndex); newConnection.Connect(); newConnection.IsHidden = isHidden; e.Connection.Tag = newConnection; (e.Connection as MyNodeViewConnection).Hidden = isHidden; m_mainForm.RefreshConnections(this); m_mainForm.ProjectStateChanged("Connection added"); } else { // Make the graph library drop the connection. e.Cancel = true; } }
public int UpdateAfterDeserialization(int topId, MyProject parentProject) { if (topId < this.Id) { topId = this.Id; } this.Owner = parentProject; Dictionary<int, MyNode> nodes = new Dictionary<int,MyNode>(); topId = CollectNodesAndUpdate(this, nodes, topId); parentProject.ReadOnly = false; MyNodeGroup.IteratorAction findUnknownAction = delegate(MyNode node) { if (!MyConfiguration.KnownNodes.ContainsKey(node.GetType())) { MyLog.WARNING.WriteLine("Unknown node type in loaded project: " + node.GetType()); parentProject.ReadOnly = true; try { MyNodeConfig nodeConfig = new MyNodeConfig() { NodeType = node.GetType(), NodeTypeName = node.GetType().FullName }; nodeConfig.InitIcons(Assembly.GetExecutingAssembly()); nodeConfig.AddObservers(Assembly.GetExecutingAssembly()); MyConfiguration.KnownNodes[nodeConfig.NodeType] = nodeConfig; } catch (Exception e) { MyLog.ERROR.WriteLine("Node type loading failed: " + e.Message); } } }; Iterate(true, findUnknownAction); foreach (MyConnectionProxy cp in m_connections) { try { MyConnection connection = new MyConnection(nodes[cp.From], nodes[cp.To], cp.FromIndex, cp.ToIndex); connection.Connect(); } catch (Exception e) { MyLog.ERROR.WriteLine("Error during connection deserialization: From id " + cp.From +" to id " + cp.To); } } return topId; }
void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e) { MyNode fromNode = (e.Connection.From.Node as MyNodeView).Node; MyNode toNode = (e.Connection.To.Node as MyNodeView).Node; int fromIndex = (int)e.Connection.From.Item.Tag; int toIndex = (int)e.Connection.To.Item.Tag; MyConnection newConnection = new MyConnection(fromNode, toNode, fromIndex, toIndex); newConnection.Connect(); e.Connection.Tag = newConnection; }
public async Task SubclassDisposeKillsHttpClientAndCallsOwnDispose() { var connection = new MyConnection(endpoint, UserName, Password); Assert.Null(connection.Disposing); connection.Dispose(); await Assert.ThrowsAsync<NullReferenceException>(() => connection.HttpClient.GetAsync(new Uri("http://something.com"))); Assert.Equal(connection.Disposing, true); }
void OnConnectionAdded(object sender, AcceptNodeConnectionEventArgs e) { MyNode fromNode = (e.Connection.From.Node as MyNodeView).Node; MyNode toNode = (e.Connection.To.Node as MyNodeView).Node; int fromIndex = (int)e.Connection.From.Item.Tag; int toIndex = (int)e.Connection.To.Item.Tag; if (toNode.AcceptsConnection(fromNode, fromIndex, toIndex)) { MyConnection newConnection = new MyConnection(fromNode, toNode, fromIndex, toIndex); newConnection.Connect(); e.Connection.Tag = newConnection; m_mainForm.RefreshConnections(this); } else { // Make the graph library drop the connection. e.Cancel = true; } }
private void btnAddClick(object sender, EventArgs e) { switch(type) { case 1: // adding row if (!checkBox.Checked) { del = 0; } else { del = 1; } try { myConnection = new MyConnection(); if (txtName.Text.Length < 3 | txtName.Text.Length > 32) { lblInfo.Text = "Не коректное значение!"; return; } command = new SqlCommand("INSERT INTO KTR (Name,ShortName,Del,Stamp,created,creator,changed,changer) VALUES (@Name,@ShortName,@Del,@Stamp,@created,@creator,@changed,@changer)"); command.Parameters.AddWithValue("@Name", txtName.Text); command.Parameters.AddWithValue("@ShortName", txtShort.Text); command.Parameters.AddWithValue("@changer", txtChanger.Text); command.Parameters.AddWithValue("@Del", del); command.Parameters.AddWithValue("@Stamp", DateTime.Now); command.Parameters.AddWithValue("@created", DateTime.Now); command.Parameters.AddWithValue("@changed", DateTime.Now); command.Parameters.AddWithValue("@creator", "user"); myConnection.executeMyQuery(command); myConnection.closeMyConnection(); this.Close(); } catch (SqlException ex) { this.Close(); throw ex; } break; case 2: // updating row if (!checkBox.Checked) { del = 0; } else { del = 1; } try { myConnection = new MyConnection(); if (txtName.Text.Length < 3 | txtName.Text.Length > 32 | txtID.Text.Length < 0) { lblInfo.Text = "Не коректное значение!"; return; } command = new SqlCommand("UPDATE KTR SET Name=@Name,ShortName=@ShortName,Del=@Del,Stamp=@Stamp,creator=@creator,changed=@changed,changer=@changer WHERE id=@id"); command.Parameters.AddWithValue("@id", txtID.Text); command.Parameters.AddWithValue("@Name", txtName.Text); command.Parameters.AddWithValue("@ShortName", txtShort.Text); command.Parameters.AddWithValue("@changer", txtChanger.Text); command.Parameters.AddWithValue("@Del", del); command.Parameters.AddWithValue("@Stamp", DateTime.Now); command.Parameters.AddWithValue("@created", DateTime.Now); command.Parameters.AddWithValue("@changed", DateTime.Now); command.Parameters.AddWithValue("@creator", "user"); myConnection.executeMyQuery(command); myConnection.closeMyConnection(); this.Close(); } catch (SqlException ex) { this.Close(); throw ex; } break; } }
protected void SetUp() { _output = new StreamWriter(new MemoryStream()); _connection = new MyConnection(_output.BaseStream); _session = new Session(_connection, SessionConstants.Scp10, TemplateRegistryFields.Null, TemplateRegistryFields.Null); }