Ejemplo n.º 1
0
    protected void btnDelete_Click(object sender, ImageClickEventArgs e)
    {
        string strSelectedFAUserIDs = GetSelectedFAUser();

        if (strSelectedFAUserIDs.Length > 0)
        {
            FranchisorDAL franchisorDal = new FranchisorDAL();
            var           returnresult  = franchisorDal.SaveFranchisorFranchisorUser(strSelectedFAUserIDs,
                                                                                     Convert.ToInt32(EOperationMode.DeActivate));
            if (returnresult == 0)
            {
                returnresult = 9999993;
            }

            //service.DeactivateFranchisorFranchisorUser(FrancchisorUsers, usershellmodulerole, out returnresult, out temp);

            divErrorMsg.Visible      = true;
            divErrorMsg.InnerText    = "Record(s) deleted sucessfully"; //(String)GetGlobalResourceObject("Resource", "msgDatabaseResult" + returnresult.ToString());
            hfFranchisorUserID.Value = "";
            GetFAUser();
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// this method save the franchisor data to the database
    /// </summary>
    private void SaveFranchisor()
    {
        // format phone no.
        CommonCode objCommonCode = new CommonCode();

        OtherDAL otherDal = new OtherDAL();
        EZip     objczip  = otherDal.CheckCityZip(txtCity.Text, txtzip1.Text, ddlstate.SelectedValue);

        if (objczip.CityID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('City name entered for contact address is not valid.');", true);
            return;
        }
        else if (objczip.CityID > 0 && objczip.ZipID == 0)
        {
            ClientScript.RegisterStartupScript(typeof(string), "bujscode", "alert('Zip Code entered for contact address, corresponding to its city name, is not valid.');", true);
            return;
        }

        EFranchisorFranchisorUser franchisorfranchisoruser = new EFranchisorFranchisorUser();
        EFranchisorUser           franchisoruser           = new EFranchisorUser();
        EFranchisor franchisor = new EFranchisor();


        franchisor.Active = true;
        //HealthYes.Web.UI.FranchisorFranchisorUserService.EAddress address = new HealthYes.Web.UI.FranchisorFranchisorUserService.EAddress();
        var address = new Falcon.Entity.Other.EAddress();

        address.Address1  = txtaddress1.Text;
        address.Address2  = string.Empty;
        address.CityID    = objczip.CityID;
        address.StateID   = Convert.ToInt32(ddlstate.SelectedValue);
        address.CountryID = Convert.ToInt32(hfCountryID.Value);
        address.ZipID     = objczip.ZipID;

        //HealthYes.Web.UI.FranchisorFranchisorUserService.EUser user = new HealthYes.Web.UI.FranchisorFranchisorUserService.EUser();
        var user = new Falcon.Entity.Other.EUser();

        user.FirstName   = txtfname.Text;
        user.MiddleName  = txtMiddleName.Text.Length == 0 ? "" : txtMiddleName.Text;
        user.LastName    = txtlname.Text;
        user.SSN         = txtSSN.Text.Length == 0 ? "" : txtSSN.Text;
        user.DOB         = Convert.ToDateTime(txtDOB.Text).ToString();
        user.PhoneHome   = txtphonehome.Text.Length == 0 ? "" : objCommonCode.FormatPhoneNumber(txtphonehome.Text);
        user.PhoneOffice = txtphoneother.Text.Length == 0 ? "" : objCommonCode.FormatPhoneNumber(txtphoneother.Text);
        user.PhoneCell   = txtphonecell.Text.Length == 0 ? "" : objCommonCode.FormatPhoneNumber(txtphonecell.Text);
        user.EMail1      = txtEmail1.Text;
        user.EMail2      = txtEmail2.Text.Length == 0 ? "" : txtEmail2.Text;
        user.HomeAddress = address;

        Ucupdatephotopanel1.GetAllImages();
        franchisoruser.OtherPictures = Ucupdatephotopanel1.Images;
        //franchisoruser.OtherPictures = Ucupdatephotopanel1.Images.ToArray();
        franchisoruser.TeamPicture              = Ucupdatephotopanel1.TeamImage;
        franchisoruser.MyPicture                = Ucupdatephotopanel1.MyImage;
        franchisoruser.User                     = user;
        franchisorfranchisoruser.Franchisor     = franchisor;
        franchisorfranchisoruser.FranchisorUser = franchisoruser;

        var sessionContext = IoC.Resolve <ISessionContext>();

        if (ViewState["FranchisorFranchisorUserID"] != null && ViewState["Email"].ToString().Equals(txtEmail1.Text.Trim()))
        {
            if (ViewState["FranchisorFranchisorUserID"].ToString() != string.Empty)
            {
                FranchisorDAL franchisorDal = new FranchisorDAL();
                var           listFranchisorFranchisorUser =
                    franchisorDal.GetFranchisorFranchisorUser(ViewState["FranchisorFranchisorUserID"].ToString(), 1);
                EFranchisorFranchisorUser[] FFUser = null;

                if (listFranchisorFranchisorUser != null)
                {
                    FFUser = listFranchisorFranchisorUser.ToArray();
                }

                if (FFUser != null)
                {
                    franchisorfranchisoruser.FranchisorUser.User.UserID = Convert.ToInt32(ViewState["UserID"].ToString());

                    franchisorDal.SaveFranchisorFranchisorUser(franchisorfranchisoruser,
                                                               Convert.ToInt32(EOperationMode.Update), sessionContext.UserSession.CurrentOrganizationRole.OrganizationId);

                    Response.RedirectUser(ResolveUrl("~/App/Franchisor/FranchisorAdminUser.aspx?Action=Edited"));
                }
            }
        }
        else
        {
            IUserRepository <User> userRepository = IoC.Resolve <IUserRepository <User> >();
            if (userRepository.UserNameExists(txtEmail1.Text))
            {
                divErrorMsg.Visible   = true;
                divErrorMsg.InnerHtml = "Contact email already exists. Please try another email.";
                return;
            }
            if (ViewState["FranchisorFranchisorUserID"] != null)
            {
                if (ViewState["FranchisorFranchisorUserID"].ToString() != string.Empty)
                {
                    FranchisorDAL franchisorDal = new FranchisorDAL();
                    var           listFranchisorFranchisorUser =
                        franchisorDal.GetFranchisorFranchisorUser(
                            ViewState["FranchisorFranchisorUserID"].ToString(), 1);
                    EFranchisorFranchisorUser[] FFUser = null;

                    if (listFranchisorFranchisorUser != null)
                    {
                        FFUser = listFranchisorFranchisorUser.ToArray();
                    }

                    if (FFUser != null)
                    {
                        franchisorfranchisoruser.FranchisorUser.User.UserID =
                            Convert.ToInt32(ViewState["UserID"].ToString());
                        franchisorDal.SaveFranchisorFranchisorUser(franchisorfranchisoruser,
                                                                   Convert.ToInt32(EOperationMode.Update), sessionContext.UserSession.CurrentOrganizationRole.OrganizationId);

                        Response.RedirectUser(ResolveUrl("~/App/Franchisor/FranchisorAdminUser.aspx?Action=Edited"));
                    }
                }
            }
            else
            {
                //service.AddFranchisorFranchisorUser(franchisorfranchisoruser, usershellmodulerole1, out returnresult, out temp);

                FranchisorDAL franchisorDal = new FranchisorDAL();
                franchisorDal.SaveFranchisorFranchisorUser(franchisorfranchisoruser,
                                                           Convert.ToInt32(EOperationMode.Insert), sessionContext.UserSession.CurrentOrganizationRole.OrganizationId);

                Response.RedirectUser(ResolveUrl("~/App/Franchisor/FranchisorAdminUser.aspx?Action=Added"));
            }
        }
    }