protected void Button1_Click(object sender, EventArgs e) { reservationrules.insert insert = new reservationrules.insert(); reservationstructure struc = new reservationstructure(); struc.isapproved = 0; struc.firstname = txt_first_name.Text; struc.lastname = txt_last_name.Text; struc.middlename = txt_middlename.Text; struc.reservationtype = getINT(cbo_reservationtype.SelectedValue); struc.address = txt_address.Text; struc.checkin = getDate(txt_checkinv.Text); struc.checkout = getDate(txt_checkoutv.Text); struc.contactnumber = getINT(text_contact_number.Text); struc.email = text_email.Text; if (insert.Execute(struc)) { Program.da.createCommand("select max(id) id from elmarfin.dbo.reservation"); if (Program.da.fillCommand()) { DataTable dt = new DataTable(); dt = Program.da.getTable(); Session["revid"] = dt.Rows[0][0].ToString(); try { MailMessage oMsg = new MailMessage(); oMsg.From = new MailAddress("*****@*****.**", "Elmarfin Hotel and Pavillion"); oMsg.To.Add(new MailAddress("*****@*****.**")); oMsg.Subject = "Packet Parsing Problem"; oMsg.Body = " Problem Occuread test mail"; oMsg.SubjectEncoding = System.Text.Encoding.UTF8; oMsg.BodyEncoding = System.Text.Encoding.UTF8; oMsg.IsBodyHtml = false; oMsg.Priority = MailPriority.High; SmtpClient oSmtp = new SmtpClient("smtp.gmail.com", 587); oSmtp.DeliveryMethod = SmtpDeliveryMethod.Network; oSmtp.EnableSsl = true; NetworkCredential oCredential = new NetworkCredential("*****@*****.**", "090927808470"); oSmtp.UseDefaultCredentials = false; oSmtp.Credentials = oCredential; oSmtp.Send(oMsg); } catch (Exception ex) { } Response.Redirect("Assessment.aspx"); } } else { Response.Write("<Script>alert('Connection failed!')</Script>"); } }
public bool Execute(reservationstructure structure) { Program.da.createCommand("elmarfin.dbo.sp_insert_reservation"); Program.da.addParameter("@reservationtype", structure.reservationtype); Program.da.addParameter("@firstname", structure.firstname); Program.da.addParameter("@lastname", structure.lastname); Program.da.addParameter("@middlename", structure.middlename); Program.da.addParameter("@contactnumber", structure.contactnumber); Program.da.addParameter("@email", structure.email); Program.da.addParameter("@address", structure.address); Program.da.addParameter("@checkin", structure.checkin); Program.da.addParameter("@checkout", structure.checkout); Program.da.addParameter("@isapproved", structure.isapproved); Program.da.useStoreProcedure(); if (Program.da.executeCommand()) { return(true); } return(false); }