예제 #1
0
 protected void Submit_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Label1.ForeColor = System.Drawing.Color.Green;
         Label1.Text      = "Data saved successfully";
         //The database code goes here
         detail dt = new detail
         {
             Fnm   = Fname.Text.ToString(),
             lnm   = Lname.Text.ToString(),
             eno   = rno.Text.ToString(),
             mob   = telephone.Text.ToString(),
             email = Mail.Text.ToString(),
             pass  = Pass.Text.ToString(),
         };
         datac.details.InsertOnSubmit(dt);
         try
         {
             datac.SubmitChanges();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
             datac.SubmitChanges();
         }
     }
     else
     {
         Label1.ForeColor = System.Drawing.Color.Red;
         Label1.Text      = "Error! Data not saved";
     }
 }
예제 #2
0
        protected void post_Click(object sender, EventArgs e)
        {
            LinqtoSQLDataContext datac = new LinqtoSQLDataContext();
            var c = from p in datac.details
                    where p.Fnm == namelbl.Text
                    select p.email;
            string s = c.FirstOrDefault();


            complaint cmp = new complaint
            {
                Comp = TextBox1.Text,
                Enr  = j,
            };

            datac.complaints.InsertOnSubmit(cmp);
            try
            {
                datac.SubmitChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                datac.SubmitChanges();
            }
            if (s != null)
            {
                SendEmail(s);
            }
            else
            {
                Response.Redirect("Errorpage.aspx");
            }
            TextBox1.Text = "";
            //Name.Text = "";
        }