Example #1
0
        protected void Change_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            string pass            = TextBox1.Text;
            //  s.Name = TextBox1.Text;
            // s.sem = Int32.Parse(TextBox2.Text);
            LoginDb s1 = db.LoginDbs.Where(s => s.password == pass).FirstOrDefault <LoginDb>();

            if (s1 == null)
            {
                Label4.Text      = "Your Old Password is Incorrect";
                Label4.ForeColor = System.Drawing.Color.Firebrick;
            }
            else
            {
                LoginDb s2 = db.LoginDbs.Where(s => (s.password).Equals(pass)).FirstOrDefault <LoginDb>();
                s2.password = TextBox2.Text;
                //  db.LoginDbs.Add(s2);
                db.SaveChanges();
                Label4.Text      = "Password successfully changed";
                Label4.ForeColor = System.Drawing.Color.ForestGreen;
            }

            TextBox1.Text = " ";
            TextBox2.Text = " ";
            TextBox3.Text = " ";
        }
Example #2
0
        protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            HttpCookie cookie1 = new HttpCookie("extension");
            //   int f = 0;
            int slots = 0;

            if (f == 0)
            {
                SqlConnection conn;
                SqlDataReader sr;
                SqlCommand    cmd = new SqlCommand();
                String        str;
                str  = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                conn = new SqlConnection(str);

                /*   Database1Entities22 db1 = new Database1Entities22();
                 * UserDb u1 = new UserDb();
                 * // String imgname;
                 * u1.user_id = TextBox1.Text;
                 * u1.name = TextBox2.Text + " " + TextBox3.Text;
                 * u1.dob = DropDownList8.SelectedItem.Text.ToString() + " " + DropDownList9.SelectedItem.Text.ToString() + " " + DropDownList10.SelectedItem.Text.ToString();
                 * u1.mobileno = Decimal.Parse(TextBox9.Text);
                 * u1.email = TextBox5.Text;
                 * u1.address = TextBox15.Text;
                 * u1.city = TextBox6.Text;
                 * u1.state = TextBox7.Text;
                 * u1.pcode = Decimal.Parse(TextBox8.Text);
                 * u1.sem = Int32.Parse(TextBox4.Text);
                 * u1.branch = TextBox17.Text;
                 *
                 *
                 *
                 * db1.UserDbs.Add(u1);
                 *
                 *
                 * db1.SaveChanges();
                 *
                 * Database1Entities22 db2 = new Database1Entities22();
                 * Allocated a = new Allocated();
                 * a.user_id = TextBox1.Text; //userid into Allocate table
                 *
                 *
                 * conn.Open();
                 * cmd.Connection = conn;
                 * cmd.CommandText = "select * from Room where room_no=@number;";
                 * //  String s = ListBox1.SelectedItem.Value;
                 * cmd.Parameters.AddWithValue("@number", Int32.Parse(ListBox1.SelectedItem.Text.Substring(6)));
                 * sr = cmd.ExecuteReader();
                 * while (sr.Read())
                 * {
                 *     a.room_no = (int)sr["room_no"];
                 * }//room no into Allocate table
                 * db2.Allocateds.Add(a);
                 * db2.SaveChanges();
                 *
                 * sr.Close();
                 * conn.Close();
                 *
                 * Database1Entities22 db3 = new Database1Entities22();
                 * LoginDb l = new LoginDb();
                 * l.user_id = TextBox1.Text;
                 * l.password = TextBox11.Text;
                 * int x = 1;
                 * l.roleid = x;
                 * // l.secque = TextBox13.Text;
                 *
                 * //l.secans = TextBox14.Text;
                 * db3.LoginDbs.Add(l);
                 * db3.SaveChanges();
                 *
                 *
                 * conn.Open();
                 * cmd.Connection = conn;
                 * cmd.CommandText = "select * from Room where room_no=@room;";
                 * cmd.Parameters.AddWithValue("@room", ListBox1.SelectedItem.Text.Substring(6));
                 *
                 * sr = cmd.ExecuteReader();
                 * sr.Read();
                 *
                 * slots = (int)sr["slots_available"];
                 * slots = slots - 1;
                 * sr.Close();
                 * cmd.CommandText = "update Room set slots_available=@slot where room_no=@room1";
                 *
                 * cmd.Parameters.AddWithValue("@room1", ListBox1.SelectedItem.Text.Substring(6));
                 * cmd.Parameters.AddWithValue("@slot", slots);
                 * cmd.ExecuteNonQuery();
                 * conn.Close();*/

                if (FileUpload1.HasFile)

                {
                    string ext = System.IO.Path.GetExtension(FileUpload1.FileName);
                    cookie1["exte"] = ext;
                    Response.Cookies.Add(cookie1);

                    if (ext == ".jpg")
                    {
                        if (FileUpload1.PostedFile.ContentLength > 2000000)
                        {
                            Label39.Text      = "Image size is greater than 2 MB......";
                            Label39.ForeColor = System.Drawing.Color.Firebrick;
                        }
                        else
                        {
                            FileUpload1.PostedFile.SaveAs(Server.MapPath("Upload\\" + TextBox1.Text + ext));

                            Database1Entities22 db1 = new Database1Entities22();
                            UserDb u1 = new UserDb();
                            // String imgname;
                            u1.user_id  = TextBox1.Text;
                            u1.name     = TextBox2.Text + " " + TextBox3.Text;
                            u1.dob      = DropDownList8.SelectedItem.Text.ToString() + " " + DropDownList9.SelectedItem.Text.ToString() + " " + DropDownList10.SelectedItem.Text.ToString();
                            u1.mobileno = Decimal.Parse(TextBox9.Text);
                            u1.email    = TextBox5.Text;
                            u1.address  = TextBox15.Text;
                            u1.city     = TextBox6.Text;
                            u1.state    = TextBox7.Text;
                            u1.pcode    = Decimal.Parse(TextBox8.Text);
                            u1.sem      = Int32.Parse(TextBox4.Text);
                            u1.branch   = TextBox17.Text;



                            db1.UserDbs.Add(u1);


                            db1.SaveChanges();

                            Database1Entities22 db2 = new Database1Entities22();
                            Allocated           a   = new Allocated();
                            a.user_id = TextBox1.Text; //userid into Allocate table


                            conn.Open();
                            cmd.Connection  = conn;
                            cmd.CommandText = "select * from Room where room_no=@number;";
                            //  String s = ListBox1.SelectedItem.Value;
                            cmd.Parameters.AddWithValue("@number", Int32.Parse(ListBox1.SelectedItem.Text.Substring(6)));
                            sr = cmd.ExecuteReader();
                            while (sr.Read())
                            {
                                a.room_no = (int)sr["room_no"];
                            }//room no into Allocate table
                            db2.Allocateds.Add(a);
                            db2.SaveChanges();

                            sr.Close();
                            conn.Close();

                            Database1Entities22 db3 = new Database1Entities22();
                            LoginDb             l   = new LoginDb();
                            l.user_id  = TextBox1.Text;
                            l.password = TextBox11.Text;
                            int x = 1;
                            l.roleid = x;
                            // l.secque = TextBox13.Text;

                            //l.secans = TextBox14.Text;
                            db3.LoginDbs.Add(l);
                            db3.SaveChanges();


                            conn.Open();
                            cmd.Connection  = conn;
                            cmd.CommandText = "select * from Room where room_no=@room;";
                            cmd.Parameters.AddWithValue("@room", ListBox1.SelectedItem.Text.Substring(6));

                            sr = cmd.ExecuteReader();
                            sr.Read();

                            slots = (int)sr["slots_available"];
                            slots = slots - 1;
                            sr.Close();
                            cmd.CommandText = "update Room set slots_available=@slot where room_no=@room1";

                            cmd.Parameters.AddWithValue("@room1", ListBox1.SelectedItem.Text.Substring(6));
                            cmd.Parameters.AddWithValue("@slot", slots);
                            cmd.ExecuteNonQuery();
                            conn.Close();

                            Response.Redirect("Register2.aspx");
                        }
                    }

                    else
                    {
                        Label39.Text      = "Please Select JPG Image file";
                        Label39.ForeColor = System.Drawing.Color.Firebrick;
                    }
                }

                else
                {
                    Label39.Text      = "Select Image";
                    Label39.ForeColor = System.Drawing.Color.Firebrick;
                }
            }

            else
            {
                string message = "Already Registered.";
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<script type = 'text/javascript'>");
                sb.Append("window.onload=function(){");
                sb.Append("alert('");
                sb.Append(message);
                sb.Append("')};");
                sb.Append("</script>");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                //Label46.Text = "Already Registered";
                //Label46.ForeColor = System.Drawing.Color.ForestGreen;
            }
        }