protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        int idMember = int.Parse(Session["IdMember"].ToString());

                        Member member = (from i in entity.Members
                                         where i.IdMember == idMember
                                         select i).SingleOrDefault();
                        Dependant dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 5).FirstOrDefault();
                        tbEmail.Text  = dependant.EmailAddress != null ? dependant.EmailAddress : "";
                        tbEmail2.Text = dependant.EmailAddress != null ? dependant.EmailAddress : "";
                    }
                    catch (Exception ex)
                    {
                        function.ReportError("www.compcare.co.za", "statements.aspx", ex.ToString());
                    }
                }
            }
        }
        // ---------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Alters the internal structure of this Table-Structure Definition, optionally based on the supplied Previous Table-Structure Definition and compatible-values preservation indication.
        /// Plus, propagate the changes to the registered dependant Designators.
        /// </summary>
        public void AlterStructure(bool PreserveCompatibleValues = true, IList <FieldDefinition> OriginalStorageFieldDefs = null)
        {
            if (OriginalStorageFieldDefs == null)
            {
                OriginalStorageFieldDefs = this.StorageStructureFieldDefs;
            }

            // Update structure positions (only Delete and Add operations to mantain order and to avoid costly Move operations)
            // var PreviousStorageStructureFieldDefs = this.StorageStructureFieldDefs.CloneFor(null, ECloneOperationScope.Deep);
            this.StorageStructureFieldDefs.UpdateOnlyListContentFrom(this.FieldDefinitions);

            // Update the storage indexes
            var FieldIndex = 0;

            foreach (var StorageField in this.StorageStructureFieldDefs.OrderBy(fd => fd.StorageIndex))
            {
                StorageField.StorageIndex = FieldIndex;
                FieldIndex++;
            }

            /*- for (int FieldDefIndex = 0; FieldDefIndex < this.StorageStructureFieldDefs.Count; FieldDefIndex++)
             *  this.StorageStructureFieldDefs[FieldDefIndex].StorageIndex = FieldDefIndex; */

            // Propagate the Alteration to dependants
            var Dependents = this.GetDefinedTables();

            foreach (var Dependant in Dependents)
            {
                Dependant.ApplyStructuralAlter(OriginalStorageFieldDefs,
                                               this.StorageStructureFieldDefs,
                                               this.UniqueKeyFieldDefs,
                                               PreserveCompatibleValues);
            }
        }
Example #3
0
        // GET: Dependants/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dependant dependant = await db.Dependants.FindAsync(id);

            if (dependant == null)
            {
                return(HttpNotFound());
            }
            var gender = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Male", Value = "M"
                },
                new SelectListItem {
                    Text = "Female", Value = "F"
                }
            };

            ViewBag.Gender = gender;
            //ViewBag.StaffId = new SelectList(db.Staffs, "StaffId", "FirstName", dependant.StaffId);
            return(View(dependant));
        }
Example #4
0
        public async Task <IHttpActionResult> PUT(int id, [FromBody] Dependant dependant)
        {
            try
            {
                var query = await EmployeeDependant.GetItemAsync(id);

                if (query != null)
                {
                    query = new Dependant
                    {
                        EmployeeID   = dependant.EmployeeID,
                        Firstname    = dependant.Firstname,
                        Lastname     = dependant.Lastname,
                        Gender       = dependant.Gender,
                        Relationship = dependant.Relationship
                    };
                    await EmployeeDependant.UpdateItemAsync(query);

                    return(Ok());
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                //throw new HttpRequestException();
                return(BadRequest());
            }
        }
Example #5
0
        public async Task <ActionResult> Create([Bind(Include = "Id,FirstName,LastName,PolicyNumber,EffectiveDate,EndDate,Gender,Relationship,DateOfBirth,Description,Address,StaffId,CreatedBy,CreatedOn,ModifiedBy,ModifiedOn")] Dependant dependant)
        {
            if (ModelState.IsValid)
            {
                var user = User.Identity.Name;
                dependant.CreatedBy = user;
                dependant.CreatedOn = DateTime.Today;
                dependant.StaffId   = LegalGuideUtility.StaffId;
                db.Dependants.Add(dependant);
                await db.SaveChangesAsync();

                return(RedirectToAction("Create", "Dependants"));
            }
            var gender = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Male", Value = "M"
                },
                new SelectListItem {
                    Text = "Female", Value = "F"
                }
            };

            ViewBag.Gender = gender;
            //ViewBag.StaffId = new SelectList(db.Staffs, "StaffId", "FirstName", dependant.StaffId);
            return(View(dependant));
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Dependant dependant = db.Dependants.Find(id);

            db.Dependants.Remove(dependant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Dependant dependant = await db.Dependants.FindAsync(id);

            db.Dependants.Remove(dependant);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Session["IdMember"] == null)
     {
         FormsAuthentication.RedirectToLoginPage();
     }
     else
     {
         try
         {
             using (UniversalEntities entity = new UniversalEntities())
             {
                 int       idMember  = int.Parse(Session["IdMember"].ToString());
                 Member    member    = entity.Members.Where(p => p.IdMember == idMember).SingleOrDefault();
                 User      user      = entity.Users.Where(i => i.IdMember == idMember).SingleOrDefault();
                 Dependant dependant = entity.Dependants.Where(p => p.IdMember == idMember && p.IdDependantType == 5).SingleOrDefault();
                 if (tbNewPassword.Text == "" || tbConfirmPassword.Text == "" || tbOldPassword.Text == "")
                 {
                     lblStatus.Text      = "Please provide a value for all three fields";
                     lblStatus.ForeColor = Color.Red;
                 }
                 else if (tbNewPassword.Text != tbConfirmPassword.Text)
                 {
                     lblStatus.Text      = "Your new password and confirm password does not match";
                     lblStatus.ForeColor = Color.Red;
                 }
                 else if (user.Password != tbOldPassword.Text)
                 {
                     lblStatus.Text      = "Your old password is different to what is saved in the database";
                     lblStatus.ForeColor = Color.Red;
                 }
                 else
                 {
                     user.Password = tbNewPassword.Text;
                     entity.SaveChanges();
                     lblStatus.Text      = "Password has been successfully changed";
                     lblStatus.ForeColor = Color.Blue;
                     string toAddress  = dependant.EmailAddress;
                     string toAddress2 = @"*****@*****.**";
                     string title      = "Password Changed on CompCare Website";
                     string mailBody   = string.Format("Dear {0}, you have successfully changed your website password on the CompCare Wellness Website.", dependant.DependantName);
                     string mailBody2  = string.Format("Dependant {0} changed password to {1}", member.MAMembershipNumber, tbNewPassword.Text);
                     SendEmail(toAddress2, title, mailBody2, member.MAMembershipNumber);
                     SendEmail(toAddress, title, mailBody, member.MAMembershipNumber);
                     ClearTextBoxes();
                 }
             }
         }
         catch (Exception ex)
         {
             lblStatus.Text      = @"The system was unable to change your password. The <a href='mailto:[email protected]'>webmaster</a> has been notified of this error.";
             lblStatus.ForeColor = Color.Red;
             SendEmailToWebmaster("*****@*****.**", @"Error encountered on the ExistingMembers/ChangePassword page", ex.ToString());
         }
     }
 }
Example #9
0
 public ActionResult Edit([Bind(Include = "depNo,coveredby,fName,lName,IdNo,dOb,age,relationship,amount,policyPlan,asBeneficiary,addAnotherDep,policyNo")] Dependant dependant)
 {
     if (ModelState.IsValid)
     {
         //dependant.addAnotherDep = false;
         db.Entry(dependant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dependant));
 }
Example #10
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     using (UniversalEntities entity = new UniversalEntities())
     {
         Member member = entity.Members.Where(i => i.MAMembershipNumber == tbMembershipNumber.Text).SingleOrDefault();
         if (member == null)
         {
             lblChangePasswordError.Text = "Membership Number does not exist in database.";
         }
         else
         {
             Dependant dependant = entity.Dependants.Where(i => i.IdMember == member.IdMember && i.IdDependantType == 5).SingleOrDefault();
             User      user      = entity.Users.Where(i => i.IdMember == member.IdMember).SingleOrDefault();
             if (dependant.IdentityNumber != tbIdnumber.Text)
             {
                 lblChangePasswordError.Text = "ID Number you provided does not match with the ID Number associated with the Membership Number in the database.";
             }
             else if (tbPassword1.Text == "")
             {
                 lblChangePasswordError.Text = "Please provide a value for the password field.";
             }
             else if (tbPassword1.Text != tbPassword2.Text)
             {
                 lblChangePasswordError.Text = "Your passwords doesn't match";
             }
             else
             {
                 user.Password = tbPassword1.Text;
                 entity.SaveChanges();
                 lblChangePasswordError.Text      = "Your password has been changed.  Click here to return to the <a href='Default.aspx'>login page</a>.";
                 lblChangePasswordError.ForeColor = Color.Blue;
                 string toAddress  = dependant.EmailAddress;
                 string toAddress2 = @"*****@*****.**";
                 string title      = "Password Changed on CompCare Website";
                 string mailBody   = string.Format(" Dear {0}, you have successfully changed your website password.", dependant.DependantName);
                 string mailBody2  = string.Format("Member {0} changed password on the CompCare website to {1}", member.MAMembershipNumber, tbPassword1.Text);
                 SendEmail(toAddress2, title, mailBody2);
                 ClearFields();
                 try
                 {
                     SendEmail(toAddress, title, mailBody);
                 }
                 catch (Exception ex)
                 {
                     lblChangePasswordError.Text = string.Format(@"Your password has been changed, however, we encountered a problem sending confirmation of this transaction to your email address.  In case your address has changed, please update your profile at the membership department <a href='mailto:[email protected]?subject=Please update my profile, membership number {0}'", member.MAMembershipNumber);
                 }
             }
         }
     }
 }
Example #11
0
        // GET: Dependants/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dependant dependant = await db.Dependants.FindAsync(id);

            if (dependant == null)
            {
                return(HttpNotFound());
            }
            return(View(dependant));
        }
Example #12
0
        // GET: Dependants/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dependant dependant = db.Dependants.Find(id);

            if (dependant == null)
            {
                return(HttpNotFound());
            }
            return(View(dependant));
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (tbMembershipNumber.Text == "" || tbDateOfBirth.Text == "")
            {
                lblError.Text = "Please provide values for both fields in the form.";
            }
            else
            {
                Member member = (from i in entity.Members
                                 where i.MAMembershipNumber == tbMembershipNumber.Text
                                 select i).SingleOrDefault();
                if (member == null)
                {
                    lblError.Text = "Membership number does not exist in the database.";
                }
                else
                {
                    List <Dependant> dependants = (from i in entity.Dependants
                                                   where i.IdMember == member.IdMember
                                                   select i).ToList();
                    List <string> birthdays = new List <string>();
                    foreach (var item in dependants)
                    {
                        birthdays.Add(item.DateOfBirth.Value.ToShortDateString());
                    }

                    if (!birthdays.Contains(tbDateOfBirth.Text))
                    {
                        lblError.Text = "Date of Birth value incorrect.";
                    }
                    else
                    {
                        DateTime  dob       = DateTime.Parse(tbDateOfBirth.Text);
                        Dependant dependant = dependants.Where(p => p.DateOfBirth == dob).SingleOrDefault();

                        if (dependant.ResignationDate == null)
                        {
                            lblError.Text = "Member is active";
                        }
                        else
                        {
                            lblError.Text = "Member has resigned from the medical aid";
                        }
                    }
                }
            }
        }
Example #14
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     using (UniversalEntities entity = new UniversalEntities())
     {
         Member member = entity.Members.Where(i => i.MAMembershipNumber == tbMembershipNumber.Text).SingleOrDefault();
         if (member == null)
         {
             lblStatus.Text      = "Membership Number does not exist in database.";
             lblStatus.ForeColor = Color.Red;
         }
         else
         {
             Dependant dependant = entity.Dependants.Where(i => i.IdMember == member.IdMember && i.IdDependantType == 5).SingleOrDefault();
             User      user      = entity.Users.Where(i => i.IdMember == member.IdMember).SingleOrDefault();
             if (dependant.IdentityNumber != tbIdnumber.Text)
             {
                 lblStatus.Text      = "ID Number you provided does not match with the ID Number associated with the Membership Number in the database.";
                 lblStatus.ForeColor = Color.Red;
             }
             else if (dependant.EmailAddress == "" || dependant.EmailAddress == null)
             {
                 lblStatus.Text      = string.Format(@"We do not have an email address for you in our system.  Have you supplied us a valid Email Address? Please update your details with the <a href='mailto:[email protected]?subject=Please update my profile, membership number: {0}'>membership department</a>.", member.MAMembershipNumber);
                 lblStatus.ForeColor = Color.Red;
                 ClearTextInputs();
             }
             else
             {
                 string toAddress = dependant.EmailAddress;
                 string title     = "Your CompCare Wellness Username";
                 string mailBody  = string.Format("<p>Dear {0}, </p><p>You or someone on your behalf, requested that your username be sent to your email address.</p><p>Your username has been saved in the database as {1}.</p><p>.", dependant.DependantName, user.Username);
                 try
                 {
                     SendEmail(toAddress, title, mailBody);
                     lblStatus.Text      = "Your username has been sent to the email address on record.  Click here to return to the <a href='Default.aspx'>login page</a>.";
                     lblStatus.ForeColor = Color.Blue;
                     ClearTextInputs();
                 }
                 catch (Exception ex)
                 {
                     lblStatus.Text      = string.Format(@"We encountered a problem sending confirmation of this transaction to your email address.  Have you supplied us a valid Email Address? Please update your details with the <a href='mailto:[email protected]?subject=Please update my profile, membership number: {0}'>membership department</a>.", member.MAMembershipNumber);
                     lblStatus.ForeColor = Color.Red;
                     ClearTextInputs();
                 }
             }
         }
     }
 }
        public async Task <IActionResult> PostDependent([FromBody] PostDependents postDependents)
        {
            if (postDependents == null)
            {
                return(Json(new
                {
                    msg = "No Data"
                }
                            ));
            }

            var orgId           = getOrg();
            var userId          = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var employeeDetails = _context.EmployeeDetails.Where(x => x.UserId == Guid.Parse(userId)).FirstOrDefault();

            try
            {
                Dependant dependant = new Dependant()
                {
                    Id               = Guid.NewGuid(),
                    Name             = postDependents.Name,
                    Relationship     = postDependents.Relationship,
                    Address          = postDependents.Address,
                    OrganisationId   = orgId,
                    EmployeeDetailId = employeeDetails.Id,
                };

                _context.Add(dependant);
                _context.SaveChanges();


                return(Json(new
                {
                    msg = "Success"
                }
                            ));
            }
            catch (Exception ee)
            {
            }

            return(Json(
                       new
            {
                msg = "Fail"
            }));
        }
Example #16
0
        public async Task <IHttpActionResult> POST([FromBody] Dependant dependant)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = await EmployeeDependant.AddItemAsync(dependant);

                    return(Ok(dependant));
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception)
            {
                //throw new HttpRequestException();
                return(BadRequest());
            }
        }
Example #17
0
        // GET: Dependants
        public ActionResult Index(string searchString)
        {
            var dependants = from m in db.Dependants
                             select m;

            if (!String.IsNullOrEmpty(searchString))
            {
                dependants = dependants.Where(s => s.policyNo.Contains(searchString));

                Dependant d = db.Dependants.ToList().Find(r => r.policyNo == searchString);

                Session["First Name"] = d.fName;
                Session["Last Name"]  = d.lName;
                Session["ID Number"]  = d.IdNo;
                Session["Age"]        = d.age;
                Session["PolicyNo"]   = d.policyNo;

                RedirectToAction("Create", "Deceaseds");
            }
            return(View(dependants));
        }
Example #18
0
        public void DeleteRecord(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                Dependant n = new Dependant();
                n.seqNo      = index;
                n.employeeId = Request.QueryString["employeeId"];

                PostRequest <Dependant> req = new PostRequest <Dependant>();
                req.entity = n;
                PostResponse <Dependant> resp = _employeeService.ChildDelete <Dependant>(req);
                if (!resp.Success)
                {
                    //Show an error saving...
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(resp);
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    dependandtsStore.Remove(index);

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
Example #19
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (entity.Connection.State != System.Data.ConnectionState.Open)
            {
                entity.Connection.Open();
            }

            try
            {
                Member    member    = entity.Members.Where(p => p.IdMember == idMember).SingleOrDefault();
                Dependant dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 5).FirstOrDefault();
                string    toAddress = @"*****@*****.**";
                string    title     = "Member requests change of details on website";
                string    mailBody  = string.Format("A member requested that their details be updated.  The new details provided is as follows (please update where values are given): Membership Number - {0} Email - {1}, Telephone - {2}, Cellular - {3}, Postal Address Line 1 - {4}, Postal Address Line 2 - {5}, Postal Address Line 3 - {6}, Postal Address Line 4 - {13}, Postal Code - {7}, Fax Number: - {8}, Physical Address Line 1 - {9}, Physical Address Line 2 - {10}, Physical Address Line 3 - {11}, Physical Address Line 4 - {14}, Province - {15}, Physical Address Postal Code - {12}", member.MAMembershipNumber, tbEmail.Text, tbTelephone.Text, tbCellular.Text, tbAdddress1.Text, tbAddress2.Text, tbAddress3.Text, tbPostalCode.Text, tbFaxNumber.Text, tbPhysical1.Text, tbPhysical2.Text, tbPhysical3.Text, tbPhysicalCode.Text, tbAddress4.Text, tbPhysical4.Text, ddlProvince.Text);
                SendEmail(toAddress, title, mailBody);
                lblError.Text = "Request successfully processed.";
            }
            catch (Exception ex)
            {
                lblError.Text = @"Error processing your request.  Please try again later or report this problem to [email protected]";
            }
            finally
            {
                entity.Dispose();
            }
            try
            {
                string toAddress2 = tbEmail.Text != "" ? tbEmail.Text : lblEmail.Text;
                string title2     = "Update of Personal Details Request submitted on the CompCare Wellness Website";
                string mailBody2  = @"Dear Member,  your request to have your details updated was successfully captured on the CompCare Wellness Website and forwarded to the Administration Department for update.";
                SendEmail(toAddress2, title2, mailBody2);
            }
            catch (Exception)
            {
                lblError.Text = "We were unable to send you a confirmation email.";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                idMember = int.Parse(Session["IdMember"].ToString());

                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        Member        member    = entity.Members.Where(p => p.IdMember == idMember).SingleOrDefault();
                        Dependant     dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 0).SingleOrDefault();
                        LifestylePlan plan      = entity.LifestylePlans.Where(i => i.IdLifestylePlan == member.IdLifestylePlan).SingleOrDefault();
                        lbl360MemberhipNumber.Text = member.LifestyleMembershipNumber != null ? member.LifestyleMembershipNumber : "Not Available";
                        lbl360Plan.Text            = plan != null ? plan.LifestylePlanName : "Not Available";
                        lblDiabeticStartDate.Text  = dependant.DiabeticStartDate != null?dependant.DiabeticStartDate.Value.ToShortDateString() : "n/a";

                        lblDiabeticEndDate.Text = dependant.DiabeticEndDate != null?dependant.DiabeticEndDate.Value.ToShortDateString() : "n/a";

                        lblHeight.Text = dependant.Height != null?dependant.Height.ToString() + "m" : "Not Available";

                        lblWeight.Text = dependant.Weight != null?dependant.Weight.ToString() + "kg" : "Not Available";

                        lblIsDiabetic.Text = dependant.IsDiabetic != null ? (dependant.IsDiabetic.Value ? "Yes" : "No") : "Not Available";
                        lblIsSmoker.Text   = dependant.IsSmoking != null ? (dependant.IsSmoking.Value ? "Yes" : "no") : "Not Available";
                    }
                    catch
                    {
                        lblError.Text = @"The website encountered a problem retrieving your health related information. Please report this error to the <a href='mailto:[email protected]'>Webmaster</a>";
                    }
                }
            }
        }
Example #21
0
        public ActionResult Create([Bind(Include = "depNo,coveredby,fName,lName,IdNo,dOb,age,relationship,amount,policyPlan,asBeneficiary,addAnotherDep,policyNo")] Dependant dependant)
        {
            Dependant idno = db.Dependants.ToList().Find(x => x.IdNo == dependant.IdNo);

            if (idno != null)
            {
                Session["responce4"] = "Dependant Already Exists, Check ID Number! Covered under: " + idno.coveredby;
                return(RedirectToAction("Create"));
            }
            //if (ModelState.IsValid)
            //{

            else if (Session["owner"] != null)
            {
                dependant.coveredby = (Session["owner"]).ToString();
            }
            if (Session["polplan"] != null)
            {
                dependant.policyPlan = (Session["polplan"]).ToString();
            }
            if (Session["PolicyNo"] != null)
            {
                dependant.policyNo = (Session["PolicyNo"]).ToString();
            }
            if (dependant.IdNo != null)
            {
                int year   = Convert.ToInt16(dependant.IdNo.Substring(0, 2));
                int month  = Convert.ToInt16(dependant.IdNo.Substring(2, 2));
                int day    = Convert.ToInt16(dependant.IdNo.Substring(4, 2));
                int gender = Convert.ToInt16(dependant.IdNo.Substring(7, 1));
                dependant.dOb = Convert.ToDateTime(day + "-" + month + "-" + year);
            }
            if (dependant.dOb != null)
            {
                dependant.age = (DateTime.Now.Year) - (dependant.dOb.Year);
            }
            if (dependant.policyPlan == "Plan A")
            {
                if (dependant.age <= 64)
                {
                    dependant.amount = 80;
                }
                else if (dependant.age <= 74)
                {
                    dependant.amount = 160;
                }
                else if (dependant.age <= 84)
                {
                    dependant.amount = 310;
                }
                else
                {
                    Session["responce4"] = "Cannot add person over 84 years from this plan!";
                    return(View("Create"));
                }
            }
            if (dependant.policyPlan == "Plan B")
            {
                if (dependant.age <= 64)
                {
                    dependant.amount = 60;
                }
                else if (dependant.age <= 74)
                {
                    dependant.amount = 130;
                }
                else if (dependant.age <= 84)
                {
                    dependant.amount = 170;
                }
                else
                {
                    dependant.amount = 280;
                }
            }
            if (dependant.policyPlan == "Plan C1")
            {
                if (dependant.age <= 64)
                {
                    dependant.amount = 46;
                }
                else if (dependant.age <= 74)
                {
                    dependant.amount = 82;
                }
                else if (dependant.age <= 84)
                {
                    dependant.amount = 109;
                }
                else
                {
                    dependant.amount = 200;
                }
            }
            if (dependant.policyPlan == "Plan C2")
            {
                if (dependant.age <= 64)
                {
                    dependant.amount = 64;
                }
                else if (dependant.age <= 74)
                {
                    dependant.amount = 117;
                }
                else if (dependant.age <= 84)
                {
                    dependant.amount = 158;
                }
                else
                {
                    dependant.amount = 234;
                }
            }
            if (dependant.policyPlan == "Plan C3")
            {
                if (dependant.age <= 64)
                {
                    dependant.amount = 82;
                }
                else if (dependant.age <= 74)
                {
                    dependant.amount = 153;
                }
                else if (dependant.age <= 84)
                {
                    dependant.amount = 207;
                }
                else
                {
                    Session["responce4"] = "Cannot add person over 84 years from this plan!";
                    return(View("Create"));
                }
            }
            else if (dependant.age <= 18 || dependant.relationship == "Spouse")
            {
                dependant.amount = 0;
            }
            db.Dependants.Add(dependant);
            db.SaveChanges();
            if (dependant != null)
            {
                Session["Dep"] = dependant;
            }
            if (dependant.asBeneficiary == true)
            {
                Session["finame"]   = dependant.fName;
                Session["laname"]   = dependant.lName;
                Session["Id"]       = dependant.IdNo;
                Session["relation"] = dependant.relationship;
            }
            if (dependant.asBeneficiary == false)
            {
                Session["finame"]   = null;
                Session["laname"]   = null;
                Session["Id"]       = null;
                Session["relation"] = null;
            }
            if (dependant.addAnotherDep == true)
            {
                return(RedirectToAction("Create", "Dependants"));
            }
            else if (dependant.addAnotherDep == false)
            {
                return(RedirectToAction("Create", "Beneficiaries"));
            }
            //}
            return(RedirectToAction("Create", "Beneficiaries"));
        }
Example #22
0
        private void creationAbonnement(int idAjout, object sender, EventArgs e)
        {
            if (this.ValidateChildren(ValidationConstraints.Enabled))
            {
                if (idAjout == 1)
                {
                    booPrincipalAjoute = true;
                    var tousLesAbonnements =
                        from abonnement in dataClasses1DataContext.Abonnements
                        select abonnement.Id;

                    int    idAbonnement    = tousLesAbonnements.Count() + 1;
                    string strIdAbonnement = "";
                    if (nomTextBox.Text.Length > 0)
                    {
                        strIdAbonnement = char.ToUpper(nomTextBox.Text[0]) + nomTextBox.Text.ToLower().Substring(1) + idAbonnement;
                    }
                    string strProvince = cmbProvince.SelectedValue.ToString();
                    strIDAbonnementPrincipal = strIdAbonnement + "P";
                    DateTime dateAbonnement = Convert.ToDateTime(lblDateAbonnement.Text);

                    var nouvelAbonnerPrincipal = new Abonnement
                    {
                        Id               = strIDAbonnementPrincipal,
                        DateAbonnement   = dateAbonnement,
                        Nom              = nomTextBox.Text,
                        Prenom           = prenomTextBox.Text,
                        Sexe             = Convert.ToChar(cmbSexe.SelectedValue),
                        DateNaissance    = Convert.ToDateTime(dateNaissanceDateTimePicker.Value),
                        NoCivique        = noCiviqueTextBox.Text,
                        Rue              = rueTextBox.Text,
                        Ville            = villeTextBox.Text,
                        IdProvince       = cmbProvince.SelectedValue.ToString(),
                        CodePostal       = codePostalTextBox.Text,
                        Telephone        = telephoneTextBox.Text,
                        Cellulaire       = cellulaireTextBox.Text,
                        Courriel         = courrielTextBox.Text,
                        NoTypeAbonnement = Convert.ToInt32(cmbTypeAbonnement.SelectedValue),
                        Remarque         = remarqueTextBox.Text
                    };

                    dataClasses1DataContext.Abonnements.InsertOnSubmit(nouvelAbonnerPrincipal);

                    try
                    {
                        dataClasses1DataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
                        MessageBox.Show($"L'abonnennement {strIdAbonnement} a été ajouté", "Enregistrement de l'abonné principal", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        foreach (Control ctrl in panelAbonnePrincipal.Controls)
                        {
                            TextBox txtboxAbonnement = ctrl as TextBox;
                            if (txtboxAbonnement != null)
                            {
                                txtboxAbonnement.ReadOnly = true;
                            }
                            MaskedTextBox maskedtxtBox = ctrl as MaskedTextBox;
                            if (maskedtxtBox != null)
                            {
                                maskedtxtBox.ReadOnly = true;
                            }
                            Button btnAjoute = ctrl as Button;
                            if (btnAjoute != null)
                            {
                                btnAjoute.Enabled = false;
                            }
                            ComboBox combo = ctrl as ComboBox;
                            if (combo != null)
                            {
                                combo.Enabled = false;
                            }
                        }
                        dateNaissanceDateTimePicker.Enabled = false;
                        // Devrait juste enable selon le combo ?
                        // Parce que sinon ça enable dès le clique
                        foreach (Control ctrl in panelDependant.Controls)
                        {
                            ctrl.Enabled = true;
                        }
                        cmbTypeAbonnement_SelectedIndexChanged(this, new EventArgs());
                        if (Convert.ToInt32(cmbTypeAbonnement.SelectedValue) == 1 || Convert.ToInt32(cmbTypeAbonnement.SelectedValue) == 2)
                        {
                            resetForm(sender, e);
                            btnEnregistrerAbonnement.Enabled = false;
                        }
                    }
                    catch (ChangeConflictException)
                    {
                        dataClasses1DataContext.ChangeConflicts.ResolveAll(RefreshMode.KeepCurrentValues);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("L'abonnennement a échoué " + ex, "Enregistrement de l'abonné principal", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (idAjout == 2)
                {
                    if (!booPrincipalAjoute)
                    {
                        MessageBox.Show("L'abonné principal n'a pas été ajouté", "Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (dateNaissanceDateTimePicker1.Value > DateTime.Now.Date.AddYears(-18))
                    {
                        MessageBox.Show("Le/La conjoint(e) doit avoir plus de 18 ans", "Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        string strIDConjoint    = strIDAbonnementPrincipal.Substring(0, strIDAbonnementPrincipal.Length - 1) + cmbSexe.SelectedValue + "0";
                        var    nouveauDependant = new Dependant
                        {
                            Id            = strIDConjoint,
                            Nom           = nomTextBox1.Text,
                            Prenom        = prenomTextBox1.Text,
                            Sexe          = Convert.ToChar(cmbSexeDependant.SelectedValue),
                            DateNaissance = Convert.ToDateTime(dateNaissanceDateTimePicker1.Value),
                            IdAbonnement  = strIDAbonnementPrincipal,
                            Remarque      = remarqueTextBox1.Text
                        };

                        dataClasses1DataContext.Dependants.InsertOnSubmit(nouveauDependant);

                        try
                        {
                            dataClasses1DataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
                            MessageBox.Show($"Le dépendant (Conjoint) {strIDConjoint} a été ajouté", "Enregistrement du conjoint", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            btnConjoint.Enabled = false;
                            booConjointAjoute   = true;
                            if (Convert.ToInt32(cmbTypeAbonnement.SelectedValue) == 3)
                            {
                                resetForm(sender, e);
                                btnEnregistrerAbonnement.Enabled = false;
                            }
                        }
                        catch (ChangeConflictException)
                        {
                            dataClasses1DataContext.ChangeConflicts.ResolveAll(RefreshMode.KeepCurrentValues);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("L'ajout du dépendant a échoué", "Enregistrement du conjoint", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                else if (idAjout == 3)
                {
                    if (!booPrincipalAjoute)
                    {
                        MessageBox.Show("L'abonné principal n'a pas été ajouté", "Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (!booConjointAjoute)
                    {
                        MessageBox.Show("Le/La conjoint(e) n'a pas été ajouté(e)", "Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (dateNaissanceDateTimePicker1.Value <= DateTime.Now.Date.AddYears(-18) || dateNaissanceDateTimePicker1.Value >= DateTime.Now.Date)
                    {
                        MessageBox.Show("L'enfant doit avoir entre 0 et 18 ans", "Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        int intNbEnfants = 0;
                        switch (Int32.Parse(cmbTypeAbonnement.SelectedValue.ToString()))
                        {
                        case 4:
                            intNbEnfants = 1;
                            break;

                        case 5:
                            intNbEnfants = 2;
                            break;

                        case 6:
                            intNbEnfants = 3;
                            break;
                        }
                        if (nbEnfantsAjoute == 9)
                        {
                            MessageBox.Show("Vous ne pouvez pas ajouter plus de 9 enfants", "Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            btnEnfant.Enabled = false;
                        }
                        else if ((nbEnfantsAjoute <= intNbEnfants) || intNbEnfants == 3)
                        {
                            if (intNbEnfants != 3 && nbEnfantsAjoute == intNbEnfants)
                            {
                                btnEnfant.Enabled = false;
                                booEnfantAjoute   = true;
                                MessageBox.Show("Vous avez enregistré le nombre maximal d'enfant pour ce type d'abonnement \n\nVeuillez confirmer l'ajout des enfants.", "Avertissement", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                nbEnfantsAjoute++;
                                if (intNbEnfants == 3 && intNbEnfants == nbEnfantsAjoute)
                                {
                                    booEnfantAjoute = true;
                                }
                                string strIDEnfant      = strIDAbonnementPrincipal.Substring(0, strIDAbonnementPrincipal.Length - 1) + "E" + nbEnfantsAjoute;
                                var    nouveauDependant = new Dependant
                                {
                                    Id            = strIDEnfant,
                                    Nom           = nomTextBox1.Text,
                                    Prenom        = prenomTextBox1.Text,
                                    Sexe          = Convert.ToChar(cmbSexeDependant.SelectedValue),
                                    DateNaissance = Convert.ToDateTime(dateNaissanceDateTimePicker1.Value),
                                    IdAbonnement  = strIDAbonnementPrincipal,
                                    Remarque      = remarqueTextBox1.Text
                                };
                                lstDependants.Add(nouveauDependant);
                                lblEnfantsEnreg.Text = nbEnfantsAjoute + " enfant(s) ajouté(s)";
                                foreach (Control ctrl in panelDependant.Controls)
                                {
                                    TextBox txtbox = ctrl as TextBox;
                                    if (txtbox != null)
                                    {
                                        txtbox.Text = "";
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        int idMember = int.Parse(Session["IdMember"].ToString());

                        Member member = (from i in entity.Members
                                         where i.IdMember == idMember
                                         select i).SingleOrDefault();
                        Dependant    dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 5).FirstOrDefault();
                        SchemeOption option    = (from i in entity.SchemeOptions
                                                  where i.IdSchemeOption == member.IdSchemeOption
                                                  select i).SingleOrDefault();
                        User          user            = entity.Users.Where(i => i.IdMember == idMember).FirstOrDefault();
                        MemberAddress postalAddress   = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == true).FirstOrDefault();
                        MemberAddress physicalAddress = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == false).FirstOrDefault();
                        Gender        gender          = entity.Genders.Where(p => p.IdGender == dependant.IdGender).SingleOrDefault();
                        lblEmail.Text        = dependant.EmailAddress != null ? dependant.EmailAddress : "Not Available";
                        lblAddress2.Text     = postalAddress != null ? postalAddress.Address2 : "Not Available";
                        lblAddress3.Text     = postalAddress != null ? postalAddress.Address3 : "Not Available";
                        lblAddress4.Text     = postalAddress != null ? postalAddress.Address4 : "Not Available";
                        lblAddress1.Text     = postalAddress != null ? postalAddress.Address1 : "Not Available";
                        lblPostalCode.Text   = postalAddress != null ? postalAddress.PostalCode : "Not Available";
                        lblPhysical1.Text    = physicalAddress != null ? physicalAddress.Address1 : "Not Available";
                        lblPhysical2.Text    = physicalAddress != null ? physicalAddress.Address2 : "Not Available";
                        lblPhysical3.Text    = physicalAddress != null ? physicalAddress.Address3 : "Not Available";
                        lblPhysical4.Text    = physicalAddress != null ? physicalAddress.Address4 : "Not Available";
                        lblPhysicalCode.Text = physicalAddress != null ? physicalAddress.PostalCode : "Not Available";
                        lblTelephone.Text    = dependant.TelephoneNumber != null ? dependant.TelephoneNumber : "Not Available";
                        lblCellular.Text     = dependant.CellularNumber != null ? dependant.CellularNumber : "Not Available";
                        lblFaxNumber.Text    = dependant.FaxNumber != null || dependant.FaxNumber != "" ? dependant.FaxNumber : "Not Available";
                        lblWorkNumber.Text   = dependant.WorkNumber != null ? dependant.WorkNumber : "Not Available";
                        lblDOB.Text          = dependant.DateOfBirth != null?dependant.DateOfBirth.Value.ToShortDateString() : "Not Available";

                        //lblGender.Text = gender.GenderDescription;
                        lblGender.Text      = dependant.Gender.GenderDescription;
                        lblIdNo.Text        = dependant.IdentityNumber;
                        lblInitials.Text    = dependant.Initials;
                        lblJoiningDate.Text = dependant.JoiningDate != null?dependant.JoiningDate.Value.ToShortDateString() : "Not Available";

                        lblSurname.Text     = dependant.DependantSurname;
                        lblName.Text        = dependant.DependantName;
                        lblMemberName.Text  = dependant.DependantName;
                        lblBenefitDate.Text = dependant.JoiningDate != null?dependant.JoiningDate.Value.ToShortDateString() : "Not Available";

                        lblMembershipNumber.Text = member.MAMembershipNumber;
                        lblResignationDate.Text  = dependant.ResignationDate != null?dependant.ResignationDate.Value.ToShortDateString() : @"n/a";

                        lblSchemeOption.Text  = option.SchemeOptionDescription;
                        lblSuspendedDate.Text = dependant.SuspendedFrom != null?dependant.SuspendedFrom.Value.ToShortDateString() : @"n/a";

                        lblSuspendedTo.Text = dependant.SuspendedTo != null?dependant.SuspendedTo.Value.ToShortDateString() : @"n/a";
                    }
                    catch
                    {
                        lblError.Text = @"The website encountered a problem retrieving all of your data.  Please report this problem to the CompCare <a href='mailto:[email protected]'>Webmaster</a>.";
                    }
                }
            }
        }
Example #24
0
        protected void PoPuP(object sender, DirectEventArgs e)
        {
            int    id   = Convert.ToInt32(e.ExtraParams["id"]);
            string type = e.ExtraParams["type"];

            switch (type)
            {
            case "imgEdit":
                //Step 1 : get the object from the Web Service
                Dependant entity = GetDEById(id.ToString());
                //Step 2 : call setvalues with the retrieved object
                this.infoForm.Reset();
                this.addressForm.Reset();
                this.infoForm.SetValues(entity);
                street1.Text    = entity.address.street1;
                street2.Text    = entity.address.street2;
                postalCode.Text = entity.address.postalCode;
                city.Text       = entity.address.city;
                address.Text    = entity.address.recordId;
                FillState();
                stateId.Select(entity.address.stateId);
                phone.Text = entity.address.phone;

                if (entity.gender == "1")
                {
                    gender0.Checked = true;
                }
                else
                {
                    gender1.Checked = true;
                }

                if (entity.hasSpecialNeeds == true)
                {
                    hasSpecialNeeds.Checked = true;
                }
                else
                {
                    hasSpecialNeeds.Checked = false;
                }

                if (entity.isEmployed == true)
                {
                    isEmployed.Checked = true;
                }
                else
                {
                    isEmployed.Checked = false;
                }

                if (entity.isStudent == true)
                {
                    isStudent.Checked = true;
                }
                else
                {
                    isStudent.Checked = false;
                }

                if (entity.isCitizen == true)
                {
                    isCitizen.Checked = true;
                }
                else
                {
                    isCitizen.Checked = false;
                }

                FillNationality();
                countryId.Select(entity.address.countryId);
                dependencyType.Select(entity.dependencyType);
                recordId.Text = id.ToString();
                this.EditContactWindow.Title = Resources.Common.EditWindowsTitle;
                this.EditContactWindow.Show();
                break;

            case "imgDelete":
                X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig
                {
                    Yes = new MessageBoxButtonConfig
                    {
                        //We are call a direct request metho for deleting a record
                        Handler = String.Format("App.direct.DeleteRecord({0})", id),
                        Text    = Resources.Common.Yes
                    },
                    No = new MessageBoxButtonConfig
                    {
                        Text = Resources.Common.No
                    }
                }).Show();
                break;

            default:
                break;
            }
        }
Example #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdMember"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                idMember = int.Parse(Session["IdMember"].ToString());
            }

            if (!IsPostBack)
            {
                btnSubmit.Enabled = false;
                using (UniversalEntities entity = new UniversalEntities())
                {
                    try
                    {
                        int idMember = int.Parse(Session["IdMember"].ToString());

                        Member member = (from i in entity.Members
                                         where i.IdMember == idMember
                                         select i).SingleOrDefault();
                        Dependant    dependant = entity.Dependants.Where(i => i.IdMember == idMember && i.IdDependantType == 5).FirstOrDefault();
                        SchemeOption option    = (from i in entity.SchemeOptions
                                                  where i.IdSchemeOption == member.IdSchemeOption
                                                  select i).SingleOrDefault();
                        User          user            = entity.Users.Where(i => i.IdMember == idMember).FirstOrDefault();
                        MemberAddress postalAddress   = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == true).FirstOrDefault();
                        MemberAddress physicalAddress = entity.MemberAddresses.Where(p => p.IdMember == idMember && p.IsPostalAddress == false).FirstOrDefault();
                        Gender        gender          = entity.Genders.Where(p => p.IdGender == dependant.IdGender).SingleOrDefault();
                        ddlProvince.DataSource = entity.Provinces.ToList();
                        ddlProvince.DataBind();
                        Province physProvince = entity.Provinces.Where(p => p.IdProvince == physicalAddress.IdProvince).FirstOrDefault();
                        lblEmail.Text        = dependant.EmailAddress != null ? dependant.EmailAddress : "Not Available";
                        lblAddress2.Text     = postalAddress != null ? postalAddress.Address2 : "Not Available";
                        lblAddress3.Text     = postalAddress != null ? postalAddress.Address3 : "Not Available";
                        lblAddress4.Text     = postalAddress != null ? postalAddress.Address4 : "Not Available";
                        lblAddress1.Text     = postalAddress != null ? postalAddress.Address1 : "Not Available";
                        lblPostalCode.Text   = postalAddress != null ? postalAddress.PostalCode : "Not Available";
                        lblPhysical1.Text    = physicalAddress != null ? physicalAddress.Address1 : "Not Available";
                        lblPhysical2.Text    = physicalAddress != null ? physicalAddress.Address2 : "Not Available";
                        lblPhysical3.Text    = physicalAddress != null ? physicalAddress.Address3 : "Not Available";
                        lblPhysical4.Text    = physicalAddress != null ? physicalAddress.Address4 : "Not Available";
                        lblProvince.Text     = physProvince != null ? physProvince.Name : "Not Available";
                        lblPhysicalCode.Text = physicalAddress != null ? physicalAddress.PostalCode : "Not Available";
                        lblTelephone.Text    = dependant.TelephoneNumber != null ? dependant.TelephoneNumber : "Not Available";
                        lblCellular.Text     = dependant.CellularNumber != null ? dependant.CellularNumber : "Not Available";
                        lblFaxNumber.Text    = dependant.FaxNumber != null || dependant.FaxNumber != "" ? dependant.FaxNumber : "Not Available";
                        lblWorkNumber.Text   = dependant.WorkNumber != null ? dependant.WorkNumber : "Not Available";
                    }
                    catch
                    {
                        lblError.Text = @"The website encountered a problem retrieving all of your data.  Please report this problem to the CompCare <a href='mailto:[email protected]'>Webmaster</a>.";
                    }
                    tbEmail.Visible         = false;
                    tbFaxNumber.Visible     = false;
                    groupPhysicalTB.Visible = false;
                    groupPostalTB.Visible   = false;
                    tbCellular.Visible      = false;
                    tbTelephone.Visible     = false;
                    tbWorkNumber.Visible    = false;
                    groupPhysicalLB.Visible = true;
                    groupPostalLB.Visible   = true;
                    lblCellular.Visible     = true;
                    lblEmail.Visible        = true;
                    lblFaxNumber.Visible    = true;
                    lblTelephone.Visible    = true;
                    lblWorkNumber.Visible   = true;
                }
            }
        }
Example #26
0
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            //Getting the id to check if it is an Add or an edit as they are managed within the same form.
            string id = e.ExtraParams["id"];

            string obj       = e.ExtraParams["info"];
            string address   = e.ExtraParams["address"];
            string addressId = e.ExtraParams["addressId"];



            Dependant b = JsonConvert.DeserializeObject <Dependant>(obj);

            b.employeeId = CurrentEmployee.Text;
            b.seqNo      = id;
            AddressBook add = JsonConvert.DeserializeObject <AddressBook>(address);

            // Define the object to add or edit as null
            if (!b.isCitizen.HasValue)
            {
                b.isCitizen = false;
            }
            if (!b.isStudent.HasValue)
            {
                b.isStudent = false;
            }
            if (!b.isEmployed.HasValue)
            {
                b.isEmployed = false;
            }
            if (!b.hasSpecialNeeds.HasValue)
            {
                b.hasSpecialNeeds = false;
            }
            if (string.IsNullOrEmpty(add.city) && string.IsNullOrEmpty(add.countryId) && string.IsNullOrEmpty(add.street1) && string.IsNullOrEmpty(add.stateId) && string.IsNullOrEmpty(add.phone))
            {
                b.address = null;
            }
            else
            {
                if (string.IsNullOrEmpty(add.city) || string.IsNullOrEmpty(add.countryId) || string.IsNullOrEmpty(add.street1) || string.IsNullOrEmpty(add.stateId))
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("ErrorAddressMissing")).Show();
                    return;
                }
                b.address          = JsonConvert.DeserializeObject <AddressBook>(address);
                b.address.recordId = addressId;
            }



            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    PostRequest <Dependant> request = new PostRequest <Dependant>();
                    request.entity = b;

                    PostResponse <Dependant> r = _employeeService.ChildAddOrUpdate <Dependant>(request);
                    b.seqNo = r.recordId;


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        //Add this record to the store
                        //this.dependandtsStore.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title     = Resources.Common.Notification,
                            Icon      = Icon.Information,
                            Html      = Resources.Common.RecordSavingSucc,
                            HideDelay = 250
                        });

                        this.EditContactWindow.Close();
                        //RowSelectionModel sm = this.dependandtsGrid.GetSelectionModel() as RowSelectionModel;
                        //sm.DeselectAll();
                        //sm.Select(b.seqNo.ToString());
                        dependandtsStore.Reload();
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <Dependant> request = new PostRequest <Dependant>();
                    request.entity = b;
                    b.seqNo        = index.ToString();


                    PostResponse <Dependant> r = _employeeService.ChildAddOrUpdate <Dependant>(request);


                    //Step 3 :  Check if request fails
                    if (!r.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        dependandtsStore.Reload();
                        Notification.Show(new NotificationConfig
                        {
                            Title     = Resources.Common.Notification,
                            Icon      = Icon.Information,
                            Html      = Resources.Common.RecordUpdatedSucc,
                            HideDelay = 250
                        });
                        this.EditContactWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }
Example #27
0
 public ActionResult AddDependant(Dependant dependant)
 {
     _context.Dependants.Add(dependant);
     _context.SaveChanges();
     return(RedirectToAction("/", "Dependant"));
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Member member = entity.Members.Where(i => i.MAMembershipNumber == tbMembershipNumber.Text).SingleOrDefault();

            if (member == null)
            {
                lblMembershipNumber.Text = "Membership Number does not exist in database.";
            }
            else
            {
                Dependant dependant = entity.Dependants.Where(p => p.IdMember == member.IdMember && p.IdDependantType == 5).FirstOrDefault();
                User      user      = entity.Users.Where(i => i.IdMember == member.IdMember).FirstOrDefault();
                if (dependant.IdentityNumber != tbIdNumber.Text)
                {
                    lblError.Text = "Please provide a valid ID Number";
                }
                else if (user != null && user.Password != "")
                {
                    lblError.Text = "You have already been registered on the website";
                }
                else if (user != null && user.Password == "")
                {
                    user.UserEmail        = dependant.EmailAddress;
                    user.IsCompCare       = true;
                    user.IdMember         = member.IdMember;
                    user.IsActive         = true;
                    user.Username         = tbUsername.Text;
                    user.Password         = tbPassword.Text;
                    user.RegistrationDate = DateTime.Today;
                    user.UserLevel        = 0;
                    user.DateCreated      = DateTime.Today;
                    entity.SaveChanges();
                    string toAddress  = dependant.EmailAddress;
                    string toAddress2 = @"*****@*****.**";
                    string title      = "Member Registration on CompCare Website";
                    string mailBody   = string.Format("Dear {0}, you have been successfully registered on the CompCare website.  Your email address has been registered in the database as being {1}", dependant.DependantName, dependant.EmailAddress);
                    string mailBody2  = string.Format("CompCare user dependant ID {0} registered. username {1} password {2}", dependant.IdDependant, user.Username, user.Password);
                    SendEmail(toAddress2, title, mailBody2);
                    SendEmail(toAddress, title, mailBody);
                    lblSuccess.Text            = @"You have been successfully registered.  Please use your credentials to log onto the website.  Please <a href='Default.aspx'>click here</a> to return to the login page.";
                    tbMembershipNumber.Text    = member.MAMembershipNumber;
                    tbMembershipNumber.Enabled = false;
                    tbIdNumber.Text            = dependant.IdentityNumber;
                    tbIdNumber.Enabled         = false;
                    trName.Visible             = true;
                    trSurname.Visible          = true;
                    trEmail.Visible            = true;
                    lblName.Text       = dependant.DependantName;
                    lblName.Enabled    = false;
                    lblSurname.Text    = dependant.DependantSurname;
                    lblSurname.Enabled = false;
                    tbEmail.Text       = dependant.EmailAddress;
                    tbEmail.Enabled    = false;
                    trButton.Visible   = false;
                    btnSubmit.Enabled  = false;
                    trPsword.Visible   = false;
                    trPsword2.Visible  = false;
                    tbUsername.Enabled = false;
                }
                else
                {
                    User newUser = new User
                    {
                        UserEmail        = dependant.EmailAddress,
                        IsCompCare       = true,
                        IdMember         = member.IdMember,
                        IsActive         = true,
                        Username         = tbUsername.Text,
                        Password         = tbPassword.Text,
                        RegistrationDate = DateTime.Today,
                        UserLevel        = 0,
                        DateCreated      = DateTime.Today
                    };
                    entity.AddToUsers(newUser);
                    entity.SaveChanges();
                    string toAddress2 = @"*****@*****.**";
                    string toAddress  = dependant.EmailAddress;
                    string title      = "Member Registration on CompCare Website";
                    string mailBody   = string.Format(" Dear {0}, you have been successfully registered on the CompCare website.  Your email address has been registered in the database as being {1}", dependant.DependantName, dependant.EmailAddress);
                    string mailBody2  = string.Format("CompCare user dependant ID {0} registered. username {1} password {2}", dependant.IdDependant, user.Username, user.Password);
                    SendEmail(toAddress2, title, mailBody2);
                    SendEmail(toAddress, title, mailBody);
                    lblSuccess.Text            = @"You have been successfully registered.  Please use your credentials to log onto the website.  Please <a href='Default.aspx'>click here</a> to return to the login page.";
                    tbMembershipNumber.Text    = member.MAMembershipNumber;
                    tbMembershipNumber.Enabled = false;
                    tbIdNumber.Text            = dependant.IdentityNumber;
                    tbIdNumber.Enabled         = false;
                    trName.Visible             = true;
                    trSurname.Visible          = true;
                    trEmail.Visible            = true;
                    lblName.Text       = dependant.DependantName;
                    lblName.Enabled    = false;
                    lblSurname.Text    = dependant.DependantSurname;
                    lblSurname.Enabled = false;
                    tbEmail.Text       = dependant.EmailAddress;
                    tbEmail.Enabled    = false;
                    trButton.Visible   = false;
                    btnSubmit.Enabled  = false;
                    trPsword.Visible   = false;
                    trPsword2.Visible  = false;
                    tbUsername.Enabled = false;
                }
            }
        }