protected void Button1_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["mid"] != null)
            {

                 CurrentMember.MemberBranch = MemberBranchTextBox.Text;
              CurrentMember.MemberFirstName = MemberFirstNameTextBox.Text;
                CurrentMember.MemberLastName= MemberLastNameTextBox.Text ;
                CurrentMember.MemberBranch= MemberBranchTextBox.Text ;
                //CurrentMember.Balance.Value.ToString() = BalanceTextBox.Text;

                Utils.GetDataContext().SubmitChanges();
            }
            else {
                CurrentMember = new Member() { Balance = 0M};

                CurrentMember.MemberBranch = MemberBranchTextBox.Text;
                CurrentMember.MemberFirstName = MemberFirstNameTextBox.Text;
                CurrentMember.MemberLastName = MemberLastNameTextBox.Text;
                CurrentMember.MemberBranch = MemberBranchTextBox.Text;
                CurrentMember.MemberPhoto = FileUpload1.FileBytes;
                BalanceTextBox.Text = "00.00";

                Utils.GetDataContext().Members.InsertOnSubmit(CurrentMember);
                Utils.GetDataContext().SubmitChanges();

            }
            Response.Redirect("Members.aspx");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["mid"] != null)
         {
              CurrentMember = Utils.GetDataContext().Members.First<Member>(m => m.MemberId == Convert.ToInt32(Request.QueryString["mid"]));
         MemberFirstNameTextBox.Text = CurrentMember.MemberFirstName;
         MemberLastNameTextBox.Text = CurrentMember.MemberLastName;
         MemberBranchTextBox.Text = CurrentMember.MemberBranch;
         BalanceTextBox.Text = CurrentMember.Balance.Value.ToString();
         Image1.ImageUrl = "ImageDisplay.ashx?mid=" + CurrentMember.MemberId;
         }
     }
 }
 public clsMobileBankerMember(Member member)
     : base()
 {
     this.Name = member.MemberFirstName.ToString() + " " + member.OtherName.ToString() + " " + member.MemberLastName.ToString();
     this.MemberId = member.MemberId;
     this.ContributedBy = "";
     this.AccountNumber = member.AccountNumber;
     this.Address = member.Address;
     this.BusinessAddress = member.BusinessAddress;
     this.ContactPerson = member.ContactPerson;
     this.ContactPersonPhone = member.ContactPersonPhone;
     try
     {
         this.CurrentSUSUInvestmentID = member.Investments.OrderBy(i => i.InvestmentID).LastOrDefault(inv => inv.InvestmentTypeId == 2).InvestmentID;
     }
     catch (Exception)
     {
     }
     this.DOB = member.DOB;
     this.Fax = member.Fax;
     this.IdentityNumber = member.IdentityNumber;
     this.SUSUInvestments = member.Investments.Where(i => i.InvestmentTypeId == 2).OrderByDescending(inv => inv.InvestmentID).ToList();
 }
 string ConcatMemberName(Member member)
 {
     return member.MemberFirstName + " " + member.OtherName + " " + member.MemberLastName;
 }
		private void detach_Members(Member entity)
		{
			this.SendPropertyChanging();
			entity.AccountType = null;
		}
 partial void DeleteMember(Member instance);
 partial void UpdateMember(Member instance);
 partial void InsertMember(Member instance);
        void CreateMember()
        {
            using (FinanceManagerDataContext db = new FinanceManagerDataContext())
            {
                if (Request.QueryString["mid"] != null) //editing
                {
                    Utils.IsAuthorized("Members", "Edit");

                    CurrentMember = db.Members.First<Member>(m => m.MemberId == Convert.ToInt32(Request.QueryString["mid"]));
                    CurrentMember.BranchID = Convert.ToInt32( cboBranches.SelectedValue);
                    CurrentMember.MemberFirstName = MemberFirstNameTextBox.Text;
                    CurrentMember.MemberLastName = MemberLastNameTextBox.Text;
                    //CurrentMember.MemberBranch = MemberBranchTextBox.Text;
                    //CurrentMember.Balance.Value.ToString() = BalanceTextBox.Text;
                    if (FileUpload1.HasFile)
                        CurrentMember.MemberPhoto = FileUpload1.FileBytes;
                    if (FileUpload2.HasFile)
                        CurrentMember.Signature = FileUpload2.FileBytes;
                    if (FileUpload3.HasFile)
                        CurrentMember.IDPhoto = FileUpload3.FileBytes;

                    CurrentMember.AccountNumber = AccountTextBox.Text;

                    CurrentMember.AccountNumber = AccountTextBox.Text;
                    CurrentMember.OtherName = MemberOtherNameTextBox.Text;
                    CurrentMember.DOB = Convert.ToDateTime(MemberDOBNameTextBox.Text);
                    CurrentMember.Fax = MemberFaxTextBox0.Text;
                    CurrentMember.IdentityNumber = MemberIDNumberTextBox.Text;
                    CurrentMember.Mobile = MemberMobileTextBox.Text;
                    CurrentMember.ResidentialAddress = MemberResidentialTextBox.Text;
                    CurrentMember.Telephone = MemberTelTextBox.Text;
                    CurrentMember.IdentityTypeID = Convert.ToInt32(DropDownList1.SelectedValue);
                    CurrentMember.ContactPerson = MemberContactPersonTextBox.Text;
                    CurrentMember.BusinessAddress = MemberBusinessLocationTextBox.Text;
                    CurrentMember.AccountTypeID = Convert.ToInt32(cboAccountType.SelectedValue);
                    CurrentMember.ContactPersonPhone = MemberContactNumberTextBox.Text;

                    CurrentMember.NextOfKin = txtNextOfKin.Text;
                    CurrentMember.NextOfKinTelephone = txtNextOfKinTelephone.Text;
                    CurrentMember.Gender = cboGender.SelectedValue;
                    //audit
                    Utils.logAction("Edit", CurrentMember);

                    //CurrentMember.AccountTypeId = Convert.ToInt32( cboAccountType.SelectedValue);
                    db.SubmitChanges();
                }
                else //inserting
                {
                    Utils.IsAuthorized("Members", "Create");
                    CurrentMember = new Member() { Balance = 0M };

                    CurrentMember.BranchID = Convert.ToInt32(cboBranches.SelectedValue);
                    CurrentMember.MemberFirstName = MemberFirstNameTextBox.Text;
                    CurrentMember.MemberLastName = MemberLastNameTextBox.Text;
                    //CurrentMember.MemberBranch = MemberBranchTextBox.Text;
                    if (FileUpload1.HasFile)
                        CurrentMember.MemberPhoto = FileUpload1.FileBytes;
                    if (FileUpload2.HasFile)
                        CurrentMember.Signature = FileUpload2.FileBytes;
                    if (FileUpload3.HasFile)
                        CurrentMember.IDPhoto = FileUpload3.FileBytes;
                    // BalanceTextBox.Text = "00.00";
                    CurrentMember.AccountNumber = AccountTextBox.Text;

                    CurrentMember.AccountNumber = AccountTextBox.Text;
                    CurrentMember.OtherName = MemberOtherNameTextBox.Text;
                    CurrentMember.DOB = Convert.ToDateTime(MemberDOBNameTextBox.Text);
                    CurrentMember.Fax = MemberFaxTextBox0.Text;
                    CurrentMember.IdentityNumber = MemberIDNumberTextBox.Text;
                    CurrentMember.Mobile = MemberMobileTextBox.Text;
                    CurrentMember.ResidentialAddress = MemberResidentialTextBox.Text;
                    CurrentMember.Telephone = MemberTelTextBox.Text;
                    CurrentMember.IdentityTypeID = Convert.ToInt32(DropDownList1.SelectedValue);
                    CurrentMember.ContactPerson = MemberContactPersonTextBox.Text;
                    CurrentMember.BusinessAddress = MemberBusinessLocationTextBox.Text;
                    //CurrentMember.AccountTypeId = Convert.ToInt32(cboAccountType.SelectedValue);
                    CurrentMember.ContactPersonPhone = MemberContactNumberTextBox.Text;
                    CurrentMember.AccountTypeID = Convert.ToInt32(cboAccountType.SelectedValue);
                    CurrentMember.Gender = cboGender.SelectedValue;

                    CurrentMember.NextOfKin = txtNextOfKin.Text;
                    CurrentMember.NextOfKinTelephone = txtNextOfKinTelephone.Text;
                    CurrentMember.IsDeleted = false;

                    //GET account type
                    AccountType accType = db.AccountTypes.FirstOrDefault(a => a.AccountTypeId == CurrentMember.AccountTypeID);

                    Utils.createAccount(CurrentMember, accType, CheckBox1.Checked);

                    //audit
                    Utils.logAction("Insert", CurrentMember);

                    //if (CheckBox1.Checked)
                    //{

                    //    CurrentMember.AccountNumber = Utils.GenerateAccountNumber(CurrentMember.MemberId);
                    //    db.SubmitChanges();
                    //}
                }
            }
        }
        void loadMemberDetails()
        {
            CurrentMember = Utils.GetDataContext().Members.First<Member>(m => m.MemberId == Convert.ToInt32(Request.QueryString["mid"]));
            MemberFirstNameTextBox.Text = CurrentMember.MemberFirstName;
            MemberLastNameTextBox.Text = CurrentMember.MemberLastName;
            if (CurrentMember.BranchID.HasValue)
            {
                 cboBranches.SelectedValue =  CurrentMember.BranchID.Value.ToString();
            }

            //BalanceTextBox.Text = CurrentMember.Balance.Value.ToString();
            Image1.ImageUrl = "ImageDisplay.ashx?mid=" + CurrentMember.MemberId;
            Image2.ImageUrl = "SignatureImageDisplay.ashx?mid=" + CurrentMember.MemberId;
            Image3.ImageUrl = "IDPhotoImageDisplay.ashx?mid=" + CurrentMember.MemberId;
            //HyperLink1.NavigateUrl = "Withdrawal.aspx?mid=" + CurrentMember.MemberId;
            HyperLink2.NavigateUrl = "MemberInvestments.aspx?mid=" + CurrentMember.MemberId;
            // HyperLink3.NavigateUrl = "MemberStatement.aspx?mid=" + CurrentMember.MemberId;
            HyperLink4.NavigateUrl = "MemberLoans.aspx?mid=" + CurrentMember.MemberId;
            AccountTextBox.Text = CurrentMember.AccountNumber;
            MemberOtherNameTextBox.Text = CurrentMember.OtherName;
            MemberDOBNameTextBox.Text = CurrentMember.DOB.HasValue == true ? CurrentMember.DOB.Value.ToString("dd-MMM-yyyy") : "";
            MemberFaxTextBox0.Text = CurrentMember.Fax;
            MemberIDNumberTextBox.Text = CurrentMember.IdentityNumber;
            MemberMobileTextBox.Text = CurrentMember.Mobile;
            MemberResidentialTextBox.Text = CurrentMember.ResidentialAddress;
            MemberTelTextBox.Text = CurrentMember.Telephone;
            MemberBusinessLocationTextBox.Text = CurrentMember.BusinessAddress;
            MemberContactNumberTextBox.Text = CurrentMember.ContactPersonPhone;
            txtNextOfKin.Text = CurrentMember.NextOfKin;
            txtNextOfKinTelephone.Text = CurrentMember.NextOfKinTelephone;
            // cboAccountType.SelectedValue = CurrentMember.AccountTypeID.HasValue ? CurrentMember.AccountTypeID.Value.ToString() : ;
            if (CurrentMember.Gender != null && CurrentMember.Gender.Length > 0)
            {
                cboGender.SelectedValue = CurrentMember.Gender;
            }

            if (CurrentMember.AccountTypeID.HasValue)
            {
                cboAccountType.SelectedValue = CurrentMember.AccountTypeID.Value.ToString();
            }
            try
            {
                //cboAccountType.SelectedValue = CurrentMember.AccountTypeID.ToString();
            }
            catch (Exception)
            {
            }

            if (CurrentMember.IdentityTypeID.HasValue == true)
            {
                DropDownList1.SelectedValue = CurrentMember.IdentityTypeID.Value.ToString();
            }
            MemberContactPersonTextBox.Text = CurrentMember.ContactPerson;

            //disable account number edit
            AccountTextBox.Enabled = false;
            CheckBox1.Enabled = false;
        }