示例#1
0
        private void PhonesChangesUpdate(cUser Demography)
        {
            List <cPhone> phones = Session["dem_Phones"] as List <cPhone>;

            int userId = (int)Session["UserID"];
            //For each element of the original list perform one of the following:
            //If update, update information
            //If delete, mark record for delete
            //If new, mark record for adding
            cPhone a1 = null;

            if (Demography.UserPhones != null)
            {
                foreach (cPhone a in Demography.UserPhones)                              //state in database
                {
                    a1 = phones.FirstOrDefault(x => x.PhoneNumberID == a.PhoneNumberID); //If record not found in memory that means it was deleted
                    if (a1 == null)
                    {
                        a.SaveUpdate(userId, true);
                    }
                    else
                    {
                        a1.SaveUpdate(userId);
                    }
                }
            }

            a1 = phones.FirstOrDefault(x => x.PhoneNumberID <= 0);
            if (a1 != null && a1.IsValid()) // If new and valid, let push it to the database
            {
                a1.SaveUpdate(userId);
            }
        }
示例#2
0
        protected void btnSavePhone_Click(object sender, EventArgs e)
        {
            int iPhoneNumberID;

            if (int.TryParse(hidEnterPhoneID.Value, out iPhoneNumberID))
            {
                cPhone UpdatePhone = new cPhone(iPhoneNumberID, _UserID, _UserName);
                UpdatePhone.PhoneNumberID = iPhoneNumberID;
                UpdatePhone.AreaCode      = tbEnterAreaCode.Text;
                UpdatePhone.PhoneNumber   = tbEnterPhoneNumber.Text;
                UpdatePhone.Extension     = tbEnterExtension.Text;
                UpdatePhone.IsPrimary     = cbxEnterPrimary.Checked;

                int iTemp;
                if (int.TryParse(ddlEnterPhoneType.SelectedValue, out iTemp))
                {
                    UpdatePhone.PhoneTypeID = iTemp;
                }
                if (int.TryParse(ddlEnterProvider.SelectedValue, out iTemp))
                {
                    UpdatePhone.ProviderID = iTemp;
                }

                UpdatePhone.SaveUpdate(_UserID);
            }
        }
示例#3
0
        protected void btnDeletePhone_Click(object sender, EventArgs e)
        {
            int iPhoneNumberID;

            if (int.TryParse(hidDeletePhoneID.Value, out iPhoneNumberID))
            {
                cPhone UpdatePhone = new cPhone(iPhoneNumberID, _UserID, _UserName);
                UpdatePhone.SaveUpdate(_UserID, true);
            }
        }