public string ReadePersonSurname(int dialogID, int messageID) { SQLConnectionClass oConnection = new SQLConnectionClass(); SQLCommandClass oCommand = new SQLCommandClass(); // string sqlIns = "INSERT INTO table (name, information, other) VALUES (@name, @information, @other)"; string queryString = "SELECT FromUserID FROM Messages Where (DialogID=@DialogID) and (MessageID = @MessageID)"; oCommand.PrepareSelectQuery(queryString, oConnection.connection); oCommand.AddSelectParam("@DialogID", dialogID); //Select Parameter oCommand.AddSelectParam("@MessageID", messageID); //Select Parameter SqlDataReader reader = oCommand.ExectuteReader(); int PersonID = 0; string PersonSurname = null; if (reader.Read()) { PersonID = Convert.ToInt32(reader[0]); } oConnection.closeConnection(); PeoplesClass oPeoples = new PeoplesClass(); PersonSurname = Convert.ToString(oPeoples.GetPeopleValue(PersonID, "Surname")); return(PersonSurname); }
protected void ButtonRegistration_Click(object sender, EventArgs e) { PeoplesClass oPeople = new PeoplesClass(); bool loginExist = false; if (oPeople.isLoginExist(this.TextBoxPhone.Text)) { this.LabelMessage.Text = " логин уже привязан к другой странице. Укажите другой логин."; loginExist = true; } if (this.TextBoxPassw.Text.Length < 5) { this.LabelMessage.Text = " пароль слишком короткий. введите пароль не менее 5 символов"; loginExist = true; } if (!loginExist) { SQLConnectionClass oConnection = new SQLConnectionClass(); SQLCommandClass oCommand = new SQLCommandClass(); string sqlIns = "INSERT INTO Peoples( ID, Name, Surname, Phone, Password) VALUES (@ID, @Name, @Surname, @Phone, @Password)"; //использовать только в такой последовательности oCommand.PrepareInsertQuery(sqlIns, oConnection.connection); int newIDPeoples = ID_OPerator.createNewTableID("ID", "Peoples"); if (newIDPeoples == -2) { //некорректные параметры } oCommand.AddInsertParameter("@ID", Convert.ToString(newIDPeoples));//заносим новый айди oCommand.AddInsertParameter("@Name", this.TextBoxName.Text); oCommand.AddInsertParameter("@Surname", this.TextBoxSurname.Text); oCommand.AddInsertParameter("@Phone", this.TextBoxPhone.Text); oCommand.AddInsertParameter("@Password", this.TextBoxPassw.Text); oCommand.ExecuteQuery(); oConnection.closeConnection(); Response.Cookies[ConstantNames.UserID].Value = Convert.ToString(newIDPeoples);//UserID to cookie Response.Cookies[ConstantNames.UserID].Expires = DateTime.Now.AddDays(1); Response.Redirect("Login.aspx"); } }
public string selectImageCommentText(int ImageID, int ID) { string returnValue = null; SQLConnectionClass oConnection = new SQLConnectionClass(); SQLCommandClass oCommand = new SQLCommandClass(); // string sqlIns = "INSERT INTO table (name, information, other) VALUES (@name, @information, @other)"; string queryString = "SELECT CommentPeopleID, Text FROM ImageComment Where (ID = @ID) AND (ImageID = @ImageID)"; oCommand.PrepareSelectQuery(queryString, oConnection.connection); oCommand.AddSelectParam("@ImageID", ImageID); //Select Parameter oCommand.AddSelectParam("@ID", ID); //Select Parameter SqlDataReader reader = oCommand.ExectuteReader(); if (reader.Read()) { int CommentPeopleID = Convert.ToInt32(reader[0]); PeoplesClass oPeople = new PeoplesClass(); string comPeopleSurname = oPeople.GetPeopleSurname(CommentPeopleID); string comPeopleName = oPeople.GetPeopleName(CommentPeopleID); string comText = Convert.ToString(reader[1]); returnValue = comPeopleSurname + comPeopleName + ": " + comText; //исключено что строка пустая } oConnection.closeConnection(); return(returnValue);//null если нет записей в таблице }