public static int Add(WaitList w) { string sSQL = @"INSERT INTO dbo.grp_WaitList (GroupID, FirstName, LastName, Phone, Email, AgentFlexID, PaxCnt, IsConverted) VALUES (@GroupID, @FirstName, @LastName, @Phone, @Email, @AgentFlexID, @PaxCnt, @IsConverted); SELECT @@IDENTITY";; using (SqlConnection cn = new SqlConnection(Config.ConnectionString)) { cn.Open(); SqlCommand cmd = new SqlCommand(sSQL, cn); cmd.Parameters.Add("@GroupID", SqlDbType.VarChar, 6).Value = w.groupID; cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value = w.firstName; cmd.Parameters.Add("@LastName", SqlDbType.VarChar, 50).Value = w.lastName; cmd.Parameters.Add("@Phone", SqlDbType.VarChar, 20).Value = w.phone; cmd.Parameters.Add("@Email", SqlDbType.VarChar, 100).Value = w.email; cmd.Parameters.Add("@AgentFlexID", SqlDbType.Int).Value = DBNull.Value; if (w.agentFlexID > 0) { cmd.Parameters["@AgentFlexID"].Value = w.agentFlexID; } cmd.Parameters.Add("@PaxCnt", SqlDbType.Int).Value = w.paxCnt; cmd.Parameters.Add("@IsConverted", SqlDbType.Bit).Value = w.isConverted; return(Convert.ToInt32(cmd.ExecuteScalar())); } }
public static void Update(WaitList w) { string sSQL = @"UPDATE dbo.grp_WaitList SET FirstName=@FirstName, LastName=@LastName, Phone=@Phone, Email=@Email, AgentFlexID=@AgentFlexID, PaxCnt=@PaxCnt, IsConverted=@IsConverted WHERE WaitListID = @WaitListID"; using (SqlConnection cn = new SqlConnection(Config.ConnectionString)) { cn.Open(); SqlCommand cmd = new SqlCommand(sSQL, cn); cmd.Parameters.Add("@WaitListID", SqlDbType.Int).Value = w.waitListID; cmd.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value = w.firstName; cmd.Parameters.Add("@LastName", SqlDbType.VarChar, 50).Value = w.lastName; cmd.Parameters.Add("@Phone", SqlDbType.VarChar, 20).Value = w.phone; cmd.Parameters.Add("@Email", SqlDbType.VarChar, 100).Value = w.email; cmd.Parameters.Add("@AgentFlexID", SqlDbType.Int).Value = DBNull.Value; if (w.agentFlexID > 0) { cmd.Parameters["@AgentFlexID"].Value = w.agentFlexID; } cmd.Parameters.Add("@PaxCnt", SqlDbType.Int).Value = w.paxCnt; cmd.Parameters.Add("@IsConverted", SqlDbType.Bit).Value = w.isConverted; cmd.ExecuteNonQuery(); } }
public static WaitList GetWaitList(int waitListID) { string sSQL = "SELECT * FROM dbo.grp_WaitList WHERE waitlistid=@waitlistid"; WaitList w = new WaitList(); using (SqlConnection cn = new SqlConnection(Config.ConnectionString)) { cn.Open(); SqlCommand cmd = new SqlCommand(sSQL, cn); cmd.Parameters.Add("@waitlistid", SqlDbType.Int).Value = waitListID; SqlDataReader rs = cmd.ExecuteReader(CommandBehavior.SingleRow); if (!rs.Read()) { return(null); } w.waitListID = Convert.ToInt32(rs["waitlistid"]); w.groupID = rs["groupid"] + ""; w.firstName = rs["firstname"] + ""; w.lastName = rs["lastname"] + ""; w.phone = rs["phone"] + ""; w.email = rs["email"] + ""; w.agentFlexID = Util.parseInt(rs["agentflexid"]); w.paxCnt = Convert.ToInt32(rs["paxcnt"]); w.isConverted = Convert.ToBoolean(rs["isconverted"]); w.created = Convert.ToDateTime(rs["created"]); } return(w); }