Esempio n. 1
0
        protected void btn_register_Click(object sender, EventArgs e)
        {
            string cv_Path = "~/images/" + cv_upload.FileName;

            cv_upload.SaveAs(Server.MapPath(cv_Path));

            string photo_path = "~/attach/" + photo_upload.FileName;

            photo_upload.SaveAs(Server.MapPath(photo_path));

            instractor ins = new instractor()
            {
                age = int.Parse(txt_age.Text), cvFile = cv_Path, did = int.Parse(ddl_dept.SelectedValue), emali = txt_email.Text, name = txt_name.Text, password = txt_pass.Text, photo = photo_path
            };

            if (ins != null)
            {
                db.instractors.Add(ins);
                db.SaveChanges();
                fillDept();
                lbl_stauts.Text = "congratulations you are registed";
            }
            else
            {
                lbl_stauts.Text = "error";
            }
            clearTxt();
        }
Esempio n. 2
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            string photoPath = "~/images/" + photo_upload.FileName;

            photo_upload.SaveAs(Server.MapPath(photoPath));

            string cvFile = "~/attach/" + cv_upload.FileName;

            cv_upload.SaveAs(Server.MapPath(cvFile));

            instractor ins = new instractor()
            {
                name     = txt_name.Text,
                age      = int.Parse(txt_age.Text),
                cvFile   = cvFile,
                photo    = photoPath,
                did      = int.Parse(ddl_dept.SelectedValue),
                emali    = txt_email.Text,
                password = txt_pass.Text
            };

            db.instractors.Add(ins);
            db.SaveChanges();

            clearTxt();
            fillInst();
        }
Esempio n. 3
0
        protected void btn_update_Click(object sender, EventArgs e)
        {
            string photoPath = "~/images/" + photo_upload.FileName;

            photo_upload.SaveAs(Server.MapPath(photoPath));

            string cvFile = "~/attach/" + cv_upload.FileName;

            cv_upload.SaveAs(Server.MapPath(cvFile));

            int        id   = int.Parse(txt_editid.Text);
            instractor inst = db.instractors.Where(n => n.id == id).FirstOrDefault();

            inst.name     = txt_name.Text;
            inst.age      = int.Parse(txt_age.Text);
            inst.cvFile   = cvFile;
            inst.photo    = photoPath;
            inst.did      = int.Parse(ddl_dept.SelectedValue);
            inst.emali    = txt_email.Text;
            inst.password = txt_pass.Text;



            db.SaveChanges();
            clearTxt();
            lbl_update.Text = "update!";
        }
Esempio n. 4
0
        protected void btn_edit_Click(object sender, EventArgs e)
        {
            //if (int.Parse(txt_editid.Text) > 0)


            try
            {
                int id = id = int.Parse(txt_editid.Text);

                instractor inst = db.instractors.Where(n => n.id == id).FirstOrDefault();
                txt_age.Text           = inst.age.ToString();
                txt_name.Text          = inst.name;
                txt_email.Text         = inst.emali;
                ddl_dept.DataTextField = inst.did.ToString();
                if (inst.photo.ToString() != null)
                {
                    profile_img.ImageUrl = inst.photo.ToString();
                }
                hl_cv.NavigateUrl = inst.cvFile.ToString();
            }
            catch
            {
                lbl_update.Text = "incorrect format";
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TestDBContext db   = new TestDBContext();
            int           id   = Convert.ToInt32(Session["id"]);
            instractor    inst = db.instractors.Where(n => n.id == id).FirstOrDefault();
            department    d    = db.departments.Where(n => n.id == inst.did).FirstOrDefault();

            lbl_age.Text         = inst.age.ToString();
            lbl_email.Text       = inst.emali;
            lbl_name.Text        = inst.name;
            lbl_dept.Text        = d.name;
            profile_img.ImageUrl = inst.photo.ToString();
            hycv.NavigateUrl     = inst.cvFile.ToString();
        }
Esempio n. 6
0
        protected void btn_login_Click(object sender, EventArgs e)
        {
            TestDBContext db  = new TestDBContext();
            instractor    ins = db.instractors.Where(n => n.emali == txt_email.Text && n.password == txt_pass.Text).FirstOrDefault();

            if (ins != null)
            {
                Session.Add("id", ins.id);
                Response.Redirect("~/profile.aspx");
            }
            else
            {
                lbl_status.Text = "incorect username or passsword";
            }
        }
Esempio n. 7
0
 protected void btn_del_id_Click(object sender, EventArgs e)
 {
     try
     {
         int        id  = int.Parse(txt_del_id.Text);
         instractor ins = db.instractors.Where(n => n.id == id).FirstOrDefault();
         db.instractors.Remove(ins);
         db.SaveChanges();
         fillInst();
     }
     catch (Exception)
     {
         lbl_delStauts.Text = "invalid id ";
     }
 }