Exemple #1
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;
            }
        }
Exemple #2
0
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Button2.Visible  = true;
            Label2.Visible   = true;
            Label3.Visible   = true;
            Label27.Visible  = true;
            Label28.Visible  = true;
            Label4.Visible   = true;
            Label5.Visible   = true;
            Label6.Visible   = true;
            Label7.Visible   = true;
            Label13.Visible  = true;
            Label14.Visible  = true;
            Label8.Visible   = true;
            Label9.Visible   = true;
            Label10.Visible  = true;
            Label11.Visible  = true;
            Label12.Visible  = true;
            ListBox1.Visible = true;

            Label15.Visible = true;
            Label16.Visible = true;
            Label17.Visible = true;
            Label18.Visible = true;
            Label19.Visible = true;
            Label20.Visible = true;
            Label21.Visible = true;
            Label22.Visible = true;
            Label23.Visible = true;
            Label24.Visible = true;
            Label25.Visible = true;
            Label26.Visible = true;
            Label29.Visible = true;
            Label30.Visible = true;
            String uid = GridView1.SelectedRow.Cells[1].Text;
            // Label15.Text = uid.ToString();
            Database1Entities22 db = new Database1Entities22();
            //    UserDb user = db.UserDbs.Where(s => s.user_id==uid).FirstOrDefault();
            UserDb    user    = db.UserDbs.Where(s => (s.user_id).Equals(uid)).FirstOrDefault <UserDb>();
            Allocated alloc   = db.Allocateds.Where(s => s.user_id == uid).FirstOrDefault <Allocated>();
            Room      room    = db.Rooms.Where(s => s.room_no == alloc.room_no).FirstOrDefault <Room>();
            var       laundry = from s in db.Laundries where s.user_id.Equals(uid) select s;
            var       expense = from s in db.Expenses where s.user_id.Equals(uid) select s;
            var       penalty = from s in db.Penalties where s.user_id.Equals(uid) select s;
            var       canteen = from s1 in db.User_Canteen join s2 in db.Canteens on s1.item_id equals s2.item_id where s1.user_id.Equals(uid) select new { quan = s1.quantity, price = s2.item_money };

            var     books = from s in db.Takes from t in db.Libraries where s.book_id == t.book_id && s.user_id == uid select t;
            decimal lbill = 0;
            decimal ebill = 0;
            decimal pbill = 0;
            decimal cbill = 0;

            foreach (var money in penalty)
            {
                pbill += money.penalty_money;
            }
            foreach (var money in expense)
            {
                ebill += money.expense_money;
            }
            foreach (var money in laundry)
            {
                lbill += money.laundry_money;
            }

            foreach (var money in canteen)
            {
                cbill += (money.quan * money.price);
            }
            Label15.Text = user.user_id.ToString();
            Label16.Text = user.name;
            Label17.Text = user.dob;
            Label18.Text = user.address;
            Label19.Text = user.mobileno.ToString();
            Label20.Text = user.email;
            Label21.Text = alloc.room_no.ToString();
            Label22.Text = room.floor.ToString();
            Label23.Text = lbill.ToString();
            Label24.Text = ebill.ToString();
            Label25.Text = pbill.ToString();
            Label26.Text = cbill.ToString();
            Label29.Text = user.sem.ToString();
            Label30.Text = user.branch.ToString();
            foreach (var book in books)
            {
                ListBox1.Items.Add(book.book_name);
            }
        }