public ActionResult Register(voltab v) { if (ModelState.IsValid) { using (DBModels s = new DBModels()) { var vregister = s.volunteers.SingleOrDefault(x => x.FirstName == v.FirstName && x.LastName == v.LastName && x.DOB == v.DOB); var vlregister = s.volunteerlogins.SingleOrDefault(x => x.UserName == v.UserName); if (vregister != null || vlregister != null) { ViewBag.message = "existing account"; ViewBag.x = "yes"; return(View()); } else { volunteer vo = new volunteer(); vo.VID = v.VID; vo.FirstName = v.FirstName; vo.MiddleInitial = v.MiddleInitial; vo.LastName = v.LastName; vo.Phone = v.Phone; vo.EMail = v.EMail; vo.DOB = v.DOB; s.volunteers.Add(vo); vol_addr y = new vol_addr(); y.Apt = v.Apt; y.City = v.City; y.State = v.State; y.ZipCode = v.ZipCode; y.Street = v.Street; y.VID = v.VID; s.vol_addr.Add(y); volunteerlogin x = new volunteerlogin(); x.ID = v.VID; x.UserName = v.UserName; x.Password = v.Password; s.volunteerlogins.Add(x); s.SaveChanges(); } } return(RedirectToAction("AccountRegistered")); } //If there were errors in data return view return(View(v)); }
public ActionResult Reject_Volunteer(volunteer vol) { if (vol == null) { return(HttpNotFound()); } else { using (Context db = new Context()) { var obj = db.voulunter.Find(Session["VolunteerID"]); obj.the_reason_of_refuse = vol.the_reason_of_refuse; obj.Volunteer_status = "Reject"; db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); var visitor = db.visitor.Find(obj.Visitro_ID); visitor.volunterr = new List <volunteer>(); visitor.volunterr.Add(obj); db.Entry(visitor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Home", "Minsitry")); } } }
public ActionResult Welcome(int id, volunteer vol) { //ViewBag.Group="Admin"; if (ModelState.IsValid) { try { objVol.commitUpdateProfileV(id, vol.v_fname, vol.v_lname, vol.v_address, vol.v_city, vol.v_province, vol.v_postalCode, vol.v_phone, vol.v_email, vol.v_password, vol.v_schedule, vol.v_oppId); //vol.v_password is added on april 30, 2015 return(RedirectToAction("Welcome/" + id)); } catch { return(View()); } } IEnumerable <SelectListItem> items = objVol.getOpportunites().Select(o => new SelectListItem { Value = o.o_id.ToString(), Text = o.o_name }); ViewBag.OpportunityID = items.ToList(); return(View()); }
public ActionResult Admin_volInsert(volunteer v) { ViewBag.Group = "Admin"; if (ModelState.IsValid) { try { objVol.commitInsertV(v); return(RedirectToAction("VolunteerAdmin_volIndex")); } catch { return(View()); } } IEnumerable <SelectListItem> items = objVol.getOpportunites().Select(o => new SelectListItem { Value = o.o_id.ToString(), Text = o.o_name }); ViewBag.OpportunityID = items; return(View()); }
public ActionResult Admin_volUpdate(int id, volunteer vol) { ViewBag.Group = "Admin"; if (ModelState.IsValid) { try { objVol.commitUpdateV(id, vol.v_fname, vol.v_lname, vol.v_address, vol.v_city, vol.v_province, vol.v_postalCode, vol.v_phone, vol.v_email, vol.v_status, vol.v_schedule, vol.v_oppId); //password is not to be updated by admin, so there is no parameter of password return(RedirectToAction("Admin_volDetails/" + id)); } catch { return(View()); } } IEnumerable <SelectListItem> items = objVol.getOpportunites().Select(o => new SelectListItem { Value = o.o_id.ToString(), Text = o.o_name }); ViewBag.OpportunityID = items.ToList(); return(View()); }
public ActionResult Add_volunteer(volunteer vol) { if (vol != null) { using (Context db = new Context()) { var Supports = db.sup.Find(Session["ID"]); var visitor = db.visitor.Find(Session["ID"]); vol.Volunteer_status = "under consideration"; vol.support = Supports; vol.Visitro_ID = Supports.Supports_Id; vol.vistor = visitor; db.voulunter.Add(vol); db.SaveChanges(); Supports.vol = new List <volunteer>(); Supports.vol.Add(vol); visitor.volunterr = new List <volunteer>(); visitor.volunterr.Add(vol); db.Entry(Supports).State = System.Data.Entity.EntityState.Modified; db.Entry(visitor).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("volunteerList")); } } else { return(HttpNotFound()); } }
private void dgv_vol_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int i = dgv_vol.CurrentRow.Index; string id = dgv_vol.Rows[i].Cells["ref_no"].Value.ToString(); vol = DBAccess.get_volunteer(id); if (vol != null) { try { vol_name = vol.Vol_name; vol_pic = vol.Vol_picture; ref_no = vol.Ref_no; this.Close(); } catch (IndexOutOfRangeException ex) { MessageBox.Show(ex.Message, "Incomplete Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Null"); } }
public ActionResult DeleteConfirmed(string id) { volunteer volunteer = db.volunteers.Find(id); db.volunteers.Remove(volunteer); db.SaveChanges(); return(RedirectToAction("Index")); }
//************************ Admin side ***************************************// //method: Insert a New Volunteer public bool commitInsertV(volunteer v) { using (objVolunteers) { objVolunteers.volunteers.InsertOnSubmit(v); objVolunteers.SubmitChanges(); return(true); } }
//*********************** Volunteer Sign Up/Sign In ****************************************// //Ref1: http://geekswithblogs.net/dotNETvinz/archive/2011/06/03/asp.net-mvc-3-creating-a-simple-sign-up-form.aspx //Ref2: http://geekswithblogs.net/dotNETvinz/archive/2011/12/30/asp.net-mvc-3---creating-a-simple-log-in-form.aspx public void Add(volunteer user) {//same method as commitInsertV using (objVolunteers) { user.v_status = "Under Review"; objVolunteers.volunteers.InsertOnSubmit(user); objVolunteers.SubmitChanges(); } }
public ActionResult Edit([Bind(Include = "Email,Name,Surname,Contact,FromDate,EndDate")] volunteer volunteer) { if (ModelState.IsValid) { db.Entry(volunteer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(volunteer)); }
public ActionResult Create([Bind(Include = "Email,Name,Surname,Contact,FromDate,EndDate")] volunteer volunteer) { if (ModelState.IsValid) { db.volunteers.Add(volunteer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(volunteer)); }
//creating an instance of volunteer table (Model) as a parameter public bool commitInsert(volunteer vol) { //to ensure all data will be disposed of when finished using (objVol) { //using our model to set table columns to new values being passed and providing it to the insert command objVol.volunteers.InsertOnSubmit(vol); //commit insert with db objVol.SubmitChanges(); return(true); } }
public ActionResult VolunteerDelete(int Id, volunteer vol) { //Selected value will be deleted from the database try { objVol.commitDelete(Id); return(RedirectToAction("VolunteerIndex")); } catch { return(View()); } }
//מוסיפה מתנדבת חדשה למערכת public static bool AddNewVolunteer(volunteer v) { if (volunteeringET.volunteer.FirstOrDefault(x => x.mail == v.mail) == null) { volunteeringET.volunteer.Add(v); volunteeringET.SaveChanges(); return(true); } else { return(false); } }
// GET: volunteers/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } volunteer volunteer = db.volunteers.Find(id); if (volunteer == null) { return(HttpNotFound()); } return(View(volunteer)); }
public ActionResult Admin_volDelete(int id, volunteer vol) { ViewBag.Group = "Admin"; try { objVol.commitDeleteV(id); return(RedirectToAction("VolunteerAdmin_volIndex")); } catch { return(View()); } }
//מסירה מתנדב ע"י ת.ז public static bool removeVolunteerByID(int id) { volunteer v = volunteeringET.volunteer.Find(id); if (v != null) { volunteeringET.volunteer.Remove(v); volunteeringET.SaveChanges(); GlobalBL.SendEmail(v.mail, "הסרה מהאתר ידיד לילד", "הוסרת מאתר ידיד לילד מאחר ולא התקבל ממך שירות זמן רב"); return(true); } else { return(false); } }
public ActionResult VolunteerUpdate(int Id, volunteer vol) { //If all the input were valid , then database will be updated if (ModelState.IsValid) { try { objVol.commitUpdate(Id, vol.position, vol.location, vol.requirement); return(RedirectToAction("VolunteerIndex")); } catch { return(View()); } } return(View()); }
public ActionResult Volunteer() { ViewBag.Description = "Party in the Park volunteers"; ViewBag.Keywords = "volunteers, help, stewards, promotion, help"; volunteer vol = new volunteer(); vol.Over18 = new[] { "Yes", "No" }; vol.InterestedRoles = new[] { "Assistant Head Steward", "Chief Steward", "Steward", "Crew", "Catering Assistant", "Child steward", "Parking Steward" }; vol.Skills = new[] { "First Aid training", "Health and Safety Training", "Working with children" }; //vol.FirstAid = new[] //{ // "Yes", // "No" //}; vol.CRB = new [] { "Yes", "No" }; //vol.MadCap = false; return(View(vol)); }
public ActionResult VolunteerInsert(volunteer vol) { if (ModelState.IsValid) { try { objVol.commitInsert(vol); return(RedirectToAction("VolunteerIndex")); //On sucessful insert, redirect to the index view } catch { //Error handling, return to view if something goes wrong return(View()); } } return(View()); }
public static volunteerDTO GetVolunteer(volunteer v) { volunteerDTO newVolunteer = new volunteerDTO(); newVolunteer.age = v.age; newVolunteer.dateEntryToSite = v.dateEntryToSite; newVolunteer.firstName = v.firstName; newVolunteer.formContact = v.formContact; newVolunteer.lastName = v.lastName; newVolunteer.mail = v.mail; newVolunteer.password = v.password; newVolunteer.phone = v.phone; newVolunteer.sax = v.sax; newVolunteer.status = v.status; newVolunteer.userName = v.userName; newVolunteer.volunteerID = v.volunteerID; return(newVolunteer); }
//ביטול קבוע של התנדבות public static bool CancellationIndividualdVolunteering(int volunteerOfChildID) { volunteerOfChild voc = volunteeringET.volunteerOfChild.Find(volunteerOfChildID); if (voc != null) { child c = volunteeringET.child.Find(voc.childId); family f = volunteeringET.family.Find(c.familyId); volunteer v = volunteeringET.volunteer.Find(voc.volunteerId); string subject = "ביטול התנדבות חד פעמי"; string mail = f.mail; string body = "שלום וברכה!, מתנצלים אך נראה שהמתנדבת " + v.firstName + " " + v.lastName + " אינה יכולה להתנדב ביום " + voc.day + " בשעה: " + voc.hour + "בצורה חד פעמית ,סליחה ותודה מראש על ההבנה"; GlobalBL.SendEmail(mail, subject, body); return(true); } return(false); }
//ביטול קבוע של התנדבות public static bool CancelledVolunteering(int volunteerOfChildID) { volunteerOfChild voc = volunteeringET.volunteerOfChild.Find(volunteerOfChildID); if (voc != null) { child c = volunteeringET.child.Find(voc.childId); family f = volunteeringET.family.Find(c.familyId); volunteer v = volunteeringET.volunteer.Find(voc.volunteerId); string subject = "ביטול התנדבות קבועה"; string mail = f.mail; string body = "שלום וברכה!, מתנצלים אך נראה שהמתנדבת " + v.firstName + " " + v.lastName + " אינה יכולה עוד להתחייב בהתנדבות שנערכת ביום " + voc.day + " בשעה: " + voc.hour + "בקרוב נעדכן אותכם על מתנדבת נוספת המתאימה לתפקיד ,תודה וסליחה."; GlobalBL.SendEmail(mail, subject, body); v.status = EStatus.cancelled.ToString(); volunteeringET.SaveChanges(); return(true); } return(false); }
//CommitInsert to save the data to the database public bool commitInsert(string _fname, string _lname, int _age, string _gender, string _schoolname, string _voltype, string _email, string _phone) { volunteerclassDataContext objVolunteerDC = new volunteerclassDataContext(); using (objVolunteerDC) { //create an instance of the table volunteer objNewVolunteer = new volunteer(); objNewVolunteer.firstname = _fname; objNewVolunteer.lastname = _lname; objNewVolunteer.age = _age; objNewVolunteer.gender = _gender; objNewVolunteer.school_name = _schoolname; objNewVolunteer.volunteer_type = _voltype; objNewVolunteer.email = _email; objNewVolunteer.phone = _phone; //objNewVolunteer.vol_Id = _id; objVolunteerDC.volunteers.InsertOnSubmit(objNewVolunteer); objVolunteerDC.SubmitChanges(); return true; } }
private void button2_Click(object sender, EventArgs e) { var ans = (from volunlist in dc.volunteers where volunlist.first_name == strFName.Text && volunlist.last_name == strLName.Text select volunlist).FirstOrDefault(); if (ans != null) { MessageBox.Show("המתנדב כבר רשום במערכת"); } else { volunteer vol = new volunteer(); //create new volunteer record vol.first_name = strFName.Text; vol.last_name = strLName.Text; vol.email_address = emailAdd.Text; vol.comments = strComments.Text; vol.start_date = startDate.Value; vol.end_date = endDate.Value; dc.volunteers.InsertOnSubmit(vol); dc.SubmitChanges(); } }
public ActionResult SignUp(volunteer v) { if (ModelState.IsValid) { try { //volunteerClass userManager = new volunteerClass(); if (!objVol.IsUserLoginIDExist(v.v_email)) { objVol.Add(v); FormsAuthentication.SetAuthCookie(v.v_fname, false); //return RedirectToAction("Welcome", "Home"); return(PartialView("Thanks", v)); } else { ModelState.AddModelError("", "LogID already taken"); } } catch { return(View(v)); } } IEnumerable <SelectListItem> items = objVol.getOpportunites().Select(o => new SelectListItem { Value = o.o_id.ToString(), Text = o.o_name }); ViewBag.OpportunityID = items; return(View(v)); }
public ActionResult Add_volunteer(volunteer voluter) { if (voluter != null) { using (Context db = new Context()) { var i = db.visitor.Find(Session["ID"]); voluter.Visitro_ID = int.Parse(Session["ID"].ToString()); voluter.Volunteer_status = "under consideration"; voluter.vistor = i; db.voulunter.Add(voluter); db.SaveChanges(); i.volunterr = new List <volunteer>(); i.volunterr.Add(voluter); db.Entry(i).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("volunteerList")); } } else { return(HttpNotFound()); } }
protected void subVolunteer(object sender, CommandEventArgs e) { volunteerclassDataContext objVolunteerDC = new volunteerclassDataContext(); //create instance of volunteer table volunteer objNewVolunteer = new volunteer(); objNewVolunteer.firstname = txtfname.Text; objNewVolunteer.lastname = txtlname.Text; objNewVolunteer.age = int.Parse(txtage.Text.ToString()); objNewVolunteer.gender = rdb_gender.Text; objNewVolunteer.school_name = txtschool.Text; objNewVolunteer.volunteer_type = ddl_voltype.SelectedItem.Text; objNewVolunteer.email = txtemail.Text; objNewVolunteer.phone = txtcontact.Text; objNewVolunteer.filename = file_up.FileName.ToString(); objNewVolunteer.filedata = file_up.FileContent.ToString(); objNewVolunteer.filetype = file_up.FileBytes.ToString(); objVolunteerDC.volunteers.InsertOnSubmit(objNewVolunteer); objVolunteerDC.SubmitChanges(); //after submitting form clears all fields txtfname.Text = ""; txtlname.Text = ""; txtemail.Text = ""; txtage.Text = ""; txtschool.Text = ""; txtcontact.Text = ""; ddl_voltype.Text = ""; rdb_gender.Text = ""; lbl_msgV.Text = "Your volunteer application was submitted successfully!"; _subRebind(); }
partial void Insertvolunteer(volunteer instance);
partial void Updatevolunteer(volunteer instance);
private void dgv_vol_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int i = dgv_vol.CurrentRow.Index; string id = dgv_vol.Rows[i].Cells["ID"].Value.ToString(); vol = DBAccess.get_volunteer(id); frm_volunteer v = new frm_volunteer(); if (vol != null) { try { v.Id = vol.Vol_id; v.txtRefNo.Text = vol.Ref_no.ToString(); v.txtName.Text = vol.Vol_name; v.txtOrganization.Text = vol.Vol_org; v.cmbSex.Text = vol.Sex; v.dtBday.Value = vol.Birthdate; v.txtAddressNo.Text = vol.Add_no; v.txtAddressStreet.Text = vol.Add_st; v.txtAddressCity.Text = vol.Mun_city; v.cmbRegion.Text = vol.Region_id; v.cmbProvince.Text = vol.Prov_id; v.txtEmail.Text = vol.Email; v.txtMobileNumber.Text = vol.Mobile_number; v.rtbRemarks.Text = vol.Remarks; if (vol.Vol_picture != "") { try { v.pbVolunteer.Image = Image.FromFile("" + vol.Vol_picture); v.dest = vol.Vol_picture; } catch (FileNotFoundException ex) { MessageBox.Show("Volunteer Picture not found, Upload a new one! ", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } v.txtArrival.Text = vol.Date_arrival; v.txtDeparture.Text = vol.Date_departure; v.txtPassport.Text = vol.Passport_exp; v.txtVisa.Text = vol.Visa_exp_date; v.txtbday.Text = vol.Birthdate.ToShortDateString().ToString(); v.txtReg.Text = vol.Region_id; v.txtProv.Text = vol.Prov_id; v.txtSex.Text = vol.Sex; v.btnSave.Visible = false; v.lblError.Visible = false; // v.txtRefNo.Enabled = false; if (frm_login.UserLvl != 2) { v.btnDel.Enabled = false; } v.ShowDialog(); } catch (IndexOutOfRangeException ex) { MessageBox.Show(ex.Message, "Incomplete Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please click refresh!"); } }
private void btnUpdate_Click(object sender, EventArgs e) { bool flag = false; if (lblError.Visible == true) { MessageBox.Show("Error in updating Volunteer Info!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (check() == true) { MessageBox.Show("Please input all required fields! (If not applicable please indicate n/a)", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (id == 0) { MessageBox.Show("Bug in raw ID! hindi nakuha ung raw Id sa pag double click sa datatable Volunteer"); } else { try { if (picturePathUponUploading != "") { try { path = Functions.GetSettingItem(Application.StartupPath + @"\\Settings.ini", "volPicturePath"); dest = path + Functions.generateRandomString() + Path.GetExtension(picturePathUponUploading); File.Copy(picturePathUponUploading, dest); try { File.Delete(destForDelete); }catch (Exception ex) {} } catch (Exception ex) { flag = true; MessageBox.Show(ex.Message); goto awit; } } int prov = DBAccess.get_cmb_data(cmbProvince.Text, "sp_get_cmb_province", "prov_id"); int reg = DBAccess.get_cmb_data(cmbRegion.Text, "sp_get_cmb_region", "region_id"); int org = DBAccess.get_cmb_data(txtOrganization.Text, "sp_get_vol_org", "vol_org_id"); vol = new volunteer(id, txtRefNo.Text.Trim(), txtName.Text.Trim(), org.ToString(), cmbSex.Text.Trim(), Convert.ToDateTime(txtbday.Text.Trim()), txtAddressNo.Text.Trim(), txtAddressStreet.Text.Trim(), txtAddressCity.Text.Trim(), prov.ToString(), reg.ToString(), txtEmail.Text.Trim(), txtMobileNumber.Text.Trim(), txtArrival.Text.Trim(), txtDeparture.Text.Trim(), txtVisa.Text.Trim(), txtPassport.Text.Trim(), rtbRemarks.Text.Trim(), dest ); DBAccess.update_volunteer(vol); logs = new auditTrail(frm_login.UserName, "Updated Volunteer id " + txtRefNo.Text); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Updated!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); awit: if (flag == false) { this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } } }
partial void Deletevolunteer(volunteer instance);
//successfull registration public ActionResult AccountRegistered(volunteer v) { return(View()); }
private void _subRebind() { volunteer objNewVolunteer = new volunteer(); }