protected void Add_Enteries(object sender, EventArgs e) { string img1 = getfilepath(FileUpload1); try { using (visionsoftEntities con = new visionsoftEntities()) { string s = "server"; //string date = Request["date"].ToString(); Expenses ex = new Expenses(); ex.expense_name = expense_name.Value.ToString(); ex.date = date.Value.ToString(); ex.month = month.Value.ToString(); ex.bill_no = bill_no.Value.ToString(); ex.amount = Int32.Parse(amount.Value.ToString()); ex.img = "<a runat='" + s + "' href='" + img1 + "'> View </a> "; con.Expenses.Add(ex); int i = con.SaveChanges(); if (i > 0) { Response.Write("<script type='text/javascript'> alert('A new entry added');window.location.href='Login.aspx?';</script>"); } else { Response.Write("<script type='text/javascript'> alert('bill upload failed try again');</script>"); } } }catch (Exception ex) { Response.Write(ex); } }
protected void LogIn(object sender, EventArgs e) { using (visionsoftEntities con = new visionsoftEntities()) { var query = from u in con.admins where u.admin_name == UserName.Text && u.password == Password.Text select u; if (query.SingleOrDefault() != null) { Session["username"] = UserName.Text; Response.Redirect("Default.aspx"); } else { Response.Write("<script type='text/javascript'> alert('invalid username password');</script>"); } } }