Ejemplo n.º 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 = " ";
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((string)Session["user"] != null)
            {
            }     // Label1.Text = "Welcome  " + (string)Session["user"];

            else
            {
                Response.Redirect("Index2.aspx");
            }

            Label2.Text = " ";
            int rows = GridView2.Rows.Count;

            if (rows == 0)
            {
                Label2.Text = "No records";
            }
            Label1.Text = " ";
            DateTime            dt1 = DateTime.Now.AddDays(-1);
            Database1Entities22 db  = new Database1Entities22();
            var      gt             = from x in db.GatePasses where x.gate_date < dt1 select x;
            GatePass gate           = new GatePass();

            foreach (var s in gt)
            {
                gate = s;
                db.GatePasses.Remove(gate);
            }
            db.SaveChanges();
        }
Ejemplo n.º 3
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int    bid             = Int32.Parse(TextBox3.Text);
            string uid             = TextBox4.Text;
            Take   tk = db.Takes.Where(s => (s.user_id).Equals(uid) && s.book_id == bid).FirstOrDefault <Take>();

            if (tk == null)
            {
                Label5.Text      = "No such Book issued";
                Label5.ForeColor = System.Drawing.Color.ForestGreen;
                return;
            }
            DateTime dt = DateTime.Now;

            if (tk.due_date < dt)
            {
                double days = (dt - tk.due_date).TotalDays;
                Label6.Text = "You are" + days + "days late penalty will be charged";
            }
            Library lb = db.Libraries.Where(s => s.book_id == bid).FirstOrDefault <Library>();

            lb.units_available++;
            db.Takes.Remove(tk);
            db.SaveChanges();
            Label5.Text      = "Book Successfully returned";
            Label5.ForeColor = System.Drawing.Color.ForestGreen;
            GridView1.DataBind();
            GridView3.DataBind();
            TextBox3.Text = "";
            TextBox4.Text = "";
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label3.Text = " ";
            int abc = Int32.Parse(DropDownList1.SelectedItem.Text);
            Database1Entities22 db = new Database1Entities22();
            Room rm = db.Rooms.Where(s => s.room_capacity == abc).FirstOrDefault <Room>();

            TextBox1.Text = rm.room_price.ToString();
        }
Ejemplo n.º 5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            GatePass            gt = new GatePass();

            gt.user_id     = (String)Session["User"];
            gt.gate_reason = TextBox1.Text;
            gt.gate_date   = Calendar1.SelectedDate;
            db.GatePasses.Add(gt);
            db.SaveChanges();
            Label3.Text = "Request Submitted";
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int abc = Int32.Parse(DropDownList1.SelectedItem.Text);
            Database1Entities22 db = new Database1Entities22();
            var rm = from s in db.Rooms where s.room_capacity == abc select s;

            foreach (var room in rm)
            {
                room.room_price = Int32.Parse(TextBox1.Text);
            }
            db.SaveChanges();
            Label3.Text = "Price Updated";
        }
Ejemplo n.º 7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            Notice not             = new Notice();

            not.notice_sub     = TextBox1.Text;
            not.notice_descrip = TextBox2.Text;
            not.notice_date    = DateTime.Now;
            Label3.Text        = "Notice Successsfully Added";
            db.Notices.Add(not);
            db.SaveChanges();
            GridView1.DataBind();
        }
Ejemplo n.º 8
0
        protected void Button7_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int mon3 = Int32.Parse(DropDownList4.SelectedItem.Value);
            var exp  = from x in db.Expenses where x.expense_date.Month == mon3 select x;

            foreach (var x in exp)
            {
                x.expense_status = "paid";
            }
            db.SaveChanges();
            GridView3.DataBind();
            Label16.Text = "Payed Succssfully";
        }
Ejemplo n.º 9
0
        protected void Button6_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int mon2 = Int32.Parse(DropDownList3.SelectedItem.Value);
            var pen  = from x in db.Penalties where x.penalty_date.Month == mon2 select x;

            foreach (var x in pen)
            {
                x.penalty_status = "paid";
            }
            db.SaveChanges();
            GridView2.DataBind();
            Label16.Text = "Payed Succssfully";
        }
Ejemplo n.º 10
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int mon1 = Int32.Parse(DropDownList2.SelectedItem.Value);
            var lau  = from x in db.Laundries where x.laundry_date.Month == mon1 select x;

            foreach (var x in lau)
            {
                x.laundry_status = "paid";
            }
            db.SaveChanges();
            GridView1.DataBind();
            Label16.Text = "Payed Succssfully";
        }
        protected void Button4_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int mon = Int32.Parse(DropDownList1.SelectedItem.Value);
            var can = from x in db.User_Canteen where x.canteen_date.Month == mon select x;

            foreach (var x in can)
            {
                x.canteen_status = "paid";
            }
            db.SaveChanges();
            GridView2.DataBind();
            Label11.Text = "Payed Succssfully";
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            Canteen             c  = new Canteen();

            c.item_id    = Int32.Parse(TextBox5.Text);
            c.item_name  = TextBox6.Text;
            c.item_money = Decimal.Parse(TextBox7.Text);
            db.Canteens.Add(c);
            db.SaveChanges();
            // Label11.Text = " New Item Insert Successfully ";
            TextBox5.Text = " ";
            TextBox6.Text = " ";
            TextBox7.Text = " ";
            GridView1.DataBind();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            User_Canteen        uc = new User_Canteen();

            uc.item_id        = Int32.Parse(TextBox1.Text);
            uc.user_id        = TextBox2.Text;
            uc.quantity       = Int32.Parse(TextBox3.Text);
            uc.canteen_date   = DateTime.Today;
            uc.canteen_status = "unpaid";
            db.User_Canteen.Add(uc);
            db.SaveChanges();
            Label5.Text      = "Order added";
            Label5.ForeColor = System.Drawing.Color.ForestGreen;
            TextBox1.Text    = " ";
            TextBox2.Text    = " ";
            TextBox3.Text    = " ";
        }
Ejemplo n.º 14
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            string uid             = (GridView1.SelectedRow.Cells[1].Text);
            var    abc             = from s in db.Allocateds from t in db.Rooms where s.user_id.Equals(uid) && s.room_no == t.room_no select t;

            foreach (var x in abc)
            {
                x.slots_available = x.slots_available + 1;
            }
            //  Room rm = db.Rooms.Where(s => s.user_id.Equals(uid) && s.room_no == t.room_no).FirstOrDefault<UserDb>();
            UserDb user = db.UserDbs.Where(s => (s.user_id).Equals(uid)).FirstOrDefault <UserDb>();

            db.UserDbs.Remove(user);
            db.SaveChanges();
            Label31.Text = "User checked Out and Room slot is available";
            GridView1.DataBind();
        }
Ejemplo n.º 15
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            Complaint           c  = new Complaint();

            c.complaint_date    = DateTime.Today;
            c.complaint_subject = TextBox1.Text;
            c.complaint_descrip = TextBox2.Text;
            c.user_id           = (string)Session["user"];
            c.complaint_status  = "pending";
            db.Complaints.Add(c);
            db.SaveChanges();
            Label3.Text = "Your Complaint is Successfully Registerer to Admin and granted within 3 days";
            GridView1.DataBind();
            Label3.ForeColor = System.Drawing.Color.ForestGreen;
            TextBox1.Text    = " ";
            TextBox2.Text    = " ";
        }
Ejemplo n.º 16
0
        /*    protected void SqlDatasoruce1_selecting1(object sender, SqlDataSourceSelectingEventArgs e)
         *  {
         *      String x = TextBox1.Text;
         *      if (TextBox1.Text.Length != 0)
         *      {
         *          e.Command.Parameters["@UserId"].Value = x;
         *
         *      }
         *      else
         *      {
         *          e.Command.Parameters["@UserId"].Value = "default";
         *      }
         *  }
         *
         *  protected void SqlDatasoruce2_selecting1(object sender, SqlDataSourceSelectingEventArgs e)
         *  {
         *      String x = TextBox1.Text;
         *      if (TextBox1.Text.Length != 0)
         *      {
         *          e.Command.Parameters["@UserId1"].Value = x;
         *
         *      }
         *      else
         *      {
         *          e.Command.Parameters["@UserId1"].Value = "default";
         *      }
         *  }
         *
         *  protected void SqlDatasoruce3_selecting1(object sender, SqlDataSourceSelectingEventArgs e)
         *  {
         *      String x = TextBox1.Text;
         *      if (TextBox1.Text.Length != 0)
         *      {
         *          e.Command.Parameters["@UserId2"].Value = x;
         *
         *      }
         *      else
         *      {
         *          e.Command.Parameters["@UserId2"].Value = "default";
         *      }
         *  }
         */
        protected void Button2_Click(object sender, EventArgs e)
        {
            DropDownList2.Visible = true;
            Button5.Visible       = true;
            Database1Entities22 db = new Database1Entities22();
            Laundry             ly = new Laundry();

            ly.user_id        = Label4.Text;
            ly.total_items    = Int32.Parse(TextBox2.Text);
            ly.laundry_money  = Int32.Parse(TextBox3.Text);
            ly.laundry_date   = DateTime.Today;
            ly.laundry_status = "unpaid";
            db.Laundries.Add(ly);
            db.SaveChanges();
            Label9.Text      = "Successfully Inserted";
            Label9.ForeColor = System.Drawing.Color.ForestGreen;
            GridView1.DataBind();
        }
Ejemplo n.º 17
0
        protected void Button4_Click(object sender, EventArgs e)

        {
            DropDownList4.Visible = true;
            Button7.Visible       = true;
            Database1Entities22 db = new Database1Entities22();
            Expense             ex = new Expense();

            ex.user_id         = Label4.Text;
            ex.expense_descrip = TextBox7.Text;
            ex.expense_money   = Int32.Parse(TextBox8.Text);
            ex.expense_date    = DateTime.Today;
            ex.expense_status  = "unpaid";
            db.Expenses.Add(ex);
            db.SaveChanges();
            Label9.Text      = "Successfully Inserted";
            Label9.ForeColor = System.Drawing.Color.ForestGreen;
            GridView3.DataBind();
        }
Ejemplo n.º 18
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            DropDownList3.Visible = true;
            Button6.Visible       = true;
            Database1Entities22 db = new Database1Entities22();
            Penalty             p  = new Penalty();

            p.user_id         = Label4.Text;
            p.penalty_subject = TextBox4.Text;
            p.penalty_descrip = TextBox5.Text;
            p.penalty_money   = Int32.Parse(TextBox6.Text);
            p.penalty_date    = DateTime.Today;
            p.penalty_status  = "unpaid";
            db.Penalties.Add(p);
            db.SaveChanges();
            Label9.Text      = "Successfully Inserted";
            Label9.ForeColor = System.Drawing.Color.ForestGreen;
            GridView2.DataBind();
        }
Ejemplo n.º 19
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            DateTime dt  = DateTime.Now.AddDays(-1);
            DateTime dt1 = Calendar2.SelectedDate;

            if (dt1 >= dt)
            {
                Database1Entities22 db = new Database1Entities22();
                String   s             = DropDownList1.SelectedItem.Text;
                MessMenu mm1           = new MessMenu();
                var      st            = from x in db.MessMenus where x.date == dt1 && x.menu_type == s select x;

                if (st.Count() == 0)
                {
                    MessMenu mm = new MessMenu();
                    mm.menu      = TextBox1.Text;
                    mm.menu_type = DropDownList1.SelectedItem.Text;
                    mm.date      = Calendar2.SelectedDate;
                    db.MessMenus.Add(mm);
                    db.SaveChanges();
                    Label6.Text      = "Menu is successfully added";
                    Label6.ForeColor = System.Drawing.Color.ForestGreen;
                    TextBox1.Text    = " ";
                    // TextBox4.Text = " ";
                    Calendar2.SelectedDates.Clear();
                }

                else
                {
                    Label8.Text   = "Menu already added on this date";
                    TextBox1.Text = " ";
                    Calendar2.SelectedDates.Clear();
                }
            }
            else
            {
                Label6.Text      = "Date must be greater than or equal to today";
                Label6.ForeColor = System.Drawing.Color.Firebrick;
            }
            GridView1.Visible = false;
            Calendar1.SelectedDates.Clear();
        }
Ejemplo n.º 20
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int     bid            = Int32.Parse(TextBox3.Text);
            string  uid            = TextBox4.Text;
            Library lb             = db.Libraries.Where(s => s.book_id == bid).FirstOrDefault <Library>();
            int     books          = db.Takes.Count(s => (s.user_id).Equals(uid));
            int     same           = db.Takes.Count(s => (s.user_id).Equals(uid) && s.book_id == bid);

            if (same != 0)
            {
                Label5.Text = "Book already issued";
            }
            else if (lb.units_available > 0 && books < 3)
            {
                Take tk = new Take();
                tk.book_id    = Int32.Parse(TextBox3.Text);
                tk.user_id    = TextBox4.Text;
                tk.issue_date = DateTime.Now;
                tk.due_date   = DateTime.Now.AddDays(21);
                db.Takes.Add(tk);
                lb.units_available--;
                db.SaveChanges();
                Label5.Text      = "Book Successfully Issued";
                Label5.ForeColor = System.Drawing.Color.ForestGreen;
                GridView1.DataBind();
                GridView3.DataBind();
            }
            else if (books == 3)
            {
                Label5.Text      = "Maximum number of books issued";
                Label5.ForeColor = System.Drawing.Color.ForestGreen;
            }
            else
            {
                Label5.Text      = "All books issued";
                Label5.ForeColor = System.Drawing.Color.ForestGreen;
            }
            TextBox3.Text = "";
            TextBox4.Text = "";
        }
Ejemplo n.º 21
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int    bid             = Int32.Parse(TextBox3.Text);
            string uid             = TextBox4.Text;
            Take   tk = db.Takes.Where(s => (s.user_id).Equals(uid) && s.book_id == bid).FirstOrDefault <Take>();

            if (tk == null)
            {
                Label5.Text      = "No such Book issued";
                Label5.ForeColor = System.Drawing.Color.ForestGreen;
                return;
            }
            DateTime dt = DateTime.Now;

            if (tk.due_date < dt)
            {
                int days = (int)(dt - tk.due_date).TotalDays;
                Label6.Text      = "You are" + days + "days late penalty will be charged";
                Label6.ForeColor = System.Drawing.Color.ForestGreen;
                Penalty p = new Penalty();
                p.penalty_subject = "Book Submission";
                p.penalty_descrip = "You are" + days + "days late for book submission";
                p.penalty_money   = 10 * days;
                p.user_id         = uid;
                p.penalty_date    = DateTime.Now;
                db.Penalties.Add(p);
                db.SaveChanges();
            }
            tk.issue_date = DateTime.Now;
            tk.due_date   = DateTime.Now.AddDays(21);
            db.SaveChanges();
            Label5.Text = "Book successfully Renewed";
            GridView1.DataBind();
            GridView3.DataBind();
            TextBox3.Text = "";
            TextBox4.Text = "";
        }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            f = 0;

            ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            Label46.Text = " ";
            Label4.Text  = " ";
            Label35.Text = " ";
            Label36.Text = " ";
            Label37.Text = " ";

            SqlConnection conn;
            SqlDataReader sr;
            SqlCommand    cmd = new SqlCommand();
            String        str;

            str = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            int f2 = 0;

            conn           = new SqlConnection(str);
            cmd.Connection = conn;
            conn.Open();
            cmd.CommandText = "select slots_available from Room ";
            sr = cmd.ExecuteReader();

            while (sr.Read())
            {
                if ((int)sr["slots_available"] != 0)

                {
                    Wizard1.Visible = true;
                    f2 = 1;

                    break;
                }
            }
            if (f2 == 0)
            {
                Label47.Text = "Hostel is Full,Apply  Next Sem!!!!!!!";
            }

            else
            {
                Label48.Visible = true;
                sr.Close();
                conn.Close();

                conn           = new SqlConnection(str);
                cmd.Connection = conn;
                conn.Open();
                cmd.CommandText = "select user_id from UserDb";
                sr = cmd.ExecuteReader();
                while (sr.Read())
                {
                    if ((sr["user_id"].ToString()).Equals(TextBox1.Text))
                    {
                        f = 1;
                        break;
                    }
                }
                sr.Close();
                conn.Close();


                if (!IsPostBack)
                {
                    DropDownList6.Items.Clear();



                    Database1Entities22 db = new Database1Entities22();
                    //   Hostel ho = new Hostel();
                    Hostel ho1   = db.Hostels.SingleOrDefault();
                    int    floor = ho1.no_of_floors;

                    for (int i = 1; i <= floor; i++)
                    {
                        DropDownList6.Items.Add(i.ToString());
                    }
                }
            }
        }
Ejemplo n.º 23
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            String email1          = " ";
            Database1Entities22 db = new Database1Entities22();
            int gid = (int)GridView2.SelectedValue;
            var x   = from a in db.GatePasses from b in db.UserDbs where a.gate_id == gid && a.user_id == b.user_id select b;

            foreach (var s in x)
            {
                email1 = s.email;
            }
            GatePass gt = db.GatePasses.Where(s => s.gate_id == gid).FirstOrDefault <GatePass>();

            db.GatePasses.Remove(gt);
            db.SaveChanges();
            GridView2.DataBind();
            int           f = 0;
            SqlConnection conn;
            SqlDataReader sr;
            SqlCommand    cmd = new SqlCommand();
            String        str;

            str = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            conn = new SqlConnection(str);

            /*  conn.Open();
             * cmd.Connection = conn;
             * cmd.CommandText = "select email from UserDb where user_id=@user1;";
             * cmd.Parameters.AddWithValue("@user1", GridView2.SelectedRow.Cells[0]);
             * sr = cmd.ExecuteReader();
             * sr.Read();
             *
             *    email1 = sr["email"].ToString();
             * gate1 = (int)sr["gate_id"];
             *
             * sr.Close();*/



            //  if (!string.IsNullOrEmpty(pwd))
            //{
            MailMessage msg = new MailMessage();

            msg.From = new MailAddress("*****@*****.**");
            msg.To.Add(email1);
            msg.Subject    = "GatePass ";
            msg.Body       = ("Your GatePass Id is: " + gid.ToString());
            msg.IsBodyHtml = true;

            SmtpClient smt = new SmtpClient();

            smt.Host = "smtp.gmail.com";
            System.Net.NetworkCredential ntwd = new NetworkCredential();
            ntwd.UserName             = "******"; //Your Email ID
            ntwd.Password             = "******";        // Your Password
            smt.UseDefaultCredentials = true;
            smt.Credentials           = ntwd;
            smt.Port      = 587;
            smt.EnableSsl = true;
            smt.Send(msg);
            Label1.Text = "Mail sent";
            //  Label2.Text = "Username and Password Sent Successfully";
            //Label2.ForeColor = System.Drawing.Color.ForestGreen;
            // }
            //else
            //{
            // Label2.Text = "Invalid Email";
            //  Label2.ForeColor = System.Drawing.Color.ForestGreen;

            int rows = GridView2.Rows.Count;

            if (rows == 0)
            {
                Label2.Text = "No records";
            }
            //}
        }
Ejemplo n.º 24
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;
            }
        }
Ejemplo n.º 25
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);
            }
        }