private void SearchFAUser(string searchtext) { FranchisorDAL franchisorDal = new FranchisorDAL(); var listFranchisorFranchisorUser = franchisorDal.GetFranchisorFranchisorUser(searchtext, 2); EFranchisorFranchisorUser[] franchisoruser = null; // format phone no. CommonCode objCommonCode = new CommonCode(); if (listFranchisorFranchisorUser != null) { franchisoruser = listFranchisorFranchisorUser.ToArray(); } DataTable dtFAUser = new DataTable(); dtFAUser.Columns.Add("FranchisorFranchisorUserID"); dtFAUser.Columns.Add("name"); dtFAUser.Columns.Add("address"); dtFAUser.Columns.Add("phonecell"); dtFAUser.Columns.Add("UserID"); string strAddress = string.Empty; if (franchisoruser != null && franchisoruser.Length > 0) { for (int icount = 0; icount < franchisoruser.Length; icount++) { strAddress = Falcon.App.Lib.CommonCode.AddressSingleLine(franchisoruser[icount].FranchisorUser.User.HomeAddress.Address1, franchisoruser[icount].FranchisorUser.User.HomeAddress.Address2, franchisoruser[icount].FranchisorUser.User.HomeAddress.City, franchisoruser[icount].FranchisorUser.User.HomeAddress.State, franchisoruser[icount].FranchisorUser.User.HomeAddress.Zip); dtFAUser.Rows.Add(new object[] { franchisoruser[icount].FranchisorFranchisorUserID, franchisoruser[icount].FranchisorUser.User.FirstName + " " + franchisoruser[icount].FranchisorUser.User.LastName, strAddress, objCommonCode.FormatPhoneNumberGet(franchisoruser[icount].FranchisorUser.User.PhoneCell.ToString()), franchisoruser[icount].FranchisorUser.User.UserID.ToString() }); } } else { divErrorMsg.InnerText = "No records found"; divErrorMsg.Visible = true; } if ((SortDirection)ViewState["SortFAUser"] == SortDirection.Descending) { dtFAUser.DefaultView.Sort = "name desc"; } else { dtFAUser.DefaultView.Sort = "name asc"; } dtFAUser = dtFAUser.DefaultView.ToTable(); dtFAUser.DefaultView.RowFilter = "UserID <> " + IoC.Resolve <ISessionContext>().UserSession.UserId; grdFAUser.DataSource = dtFAUser.DefaultView; ViewState["DSGRID"] = dtFAUser; grdFAUser.DataBind(); //grdFAUser.Sort("name", SortDirection.Ascending); hfFranchisorUserID.Value = ""; }
/// <summary> /// Fill the Franchisor data from the Franchisor session object /// </summary> private void FillFranchisorData() { FranchisorDAL franchisorDal = new FranchisorDAL(); var listFranchisorFranchisorUser = franchisorDal.GetFranchisorFranchisorUser(ViewState["FranchisorFranchisorUserID"].ToString(), 1); EFranchisorFranchisorUser[] franchisoruser = null; if (listFranchisorFranchisorUser != null) { franchisoruser = listFranchisorFranchisorUser.ToArray(); } if (franchisoruser != null) { ViewState["UserID"] = franchisoruser[0].FranchisorUser.User.UserID; txtfname.Text = franchisoruser[0].FranchisorUser.User.FirstName; txtlname.Text = franchisoruser[0].FranchisorUser.User.LastName; txtMiddleName.Text = franchisoruser[0].FranchisorUser.User.MiddleName; txtphonecell.Text = franchisoruser[0].FranchisorUser.User.PhoneCell; txtphonehome.Text = franchisoruser[0].FranchisorUser.User.PhoneHome; txtphoneother.Text = franchisoruser[0].FranchisorUser.User.PhoneOffice; txtEmail1.Text = franchisoruser[0].FranchisorUser.User.EMail1; ViewState["Email"] = franchisoruser[0].FranchisorUser.User.EMail1; txtEmail2.Text = franchisoruser[0].FranchisorUser.User.EMail2; txtSSN.Text = franchisoruser[0].FranchisorUser.User.SSN; if (franchisoruser[0].FranchisorUser.User.DOB.Length > 0) { txtDOB.Text = Convert.ToDateTime(franchisoruser[0].FranchisorUser.User.DOB).ToShortDateString(); } else { txtDOB.Text = ""; } //Ucupdatephotopanel1.Images = franchisoruser[0].FranchisorUser.OtherPictures; Ucupdatephotopanel1.Images = new List <string>(); foreach (var images in franchisoruser[0].FranchisorUser.OtherPictures) { Ucupdatephotopanel1.Images.Add(images); } Ucupdatephotopanel1.TeamImage = franchisoruser[0].FranchisorUser.TeamPicture; Ucupdatephotopanel1.MyImage = franchisoruser[0].FranchisorUser.MyPicture; txtaddress1.Text = franchisoruser[0].FranchisorUser.Address.Address1; // txtAddress2.Text = franchisoruser[0].FranchisorUser.Address.Address2; txtzip1.Text = franchisoruser[0].FranchisorUser.Address.Zip; hfCountryID.Value = franchisoruser[0].FranchisorUser.User.HomeAddress.CountryID.ToString(); //FillState(); ddlstate.SelectedValue = franchisoruser[0].FranchisorUser.User.HomeAddress.StateID.ToString(); //FillCity(); txtCity.Text = franchisoruser[0].FranchisorUser.User.HomeAddress.City.ToString(); } }
private void GetFAUser() { FranchisorDAL franchisorDAL = new FranchisorDAL(); var listFranchisorFranchisorUser = franchisorDAL.GetFranchisorFranchisorUser(IoC.Resolve <ISessionContext>().UserSession.UserId.ToString(), 3); EFranchisorFranchisorUser[] franchisoruser = null; // format phone no. CommonCode objCommonCode = new CommonCode(); if (listFranchisorFranchisorUser != null) { franchisoruser = listFranchisorFranchisorUser.ToArray(); } DataTable dtFAUser = new DataTable(); dtFAUser.Columns.Add("FranchisorFranchisorUserID"); dtFAUser.Columns.Add("name"); dtFAUser.Columns.Add("address"); dtFAUser.Columns.Add("phonecell"); dtFAUser.Columns.Add("UserID"); string strAddress = string.Empty; if (franchisoruser != null) { for (int icount = 0; icount < franchisoruser.Length; icount++) { strAddress = Falcon.App.Lib.CommonCode.AddressSingleLine(franchisoruser[icount].FranchisorUser.User.HomeAddress.Address1, franchisoruser[icount].FranchisorUser.User.HomeAddress.Address2, franchisoruser[icount].FranchisorUser.User.HomeAddress.City, franchisoruser[icount].FranchisorUser.User.HomeAddress.State, franchisoruser[icount].FranchisorUser.User.HomeAddress.Zip); dtFAUser.Rows.Add(new object[] { franchisoruser[icount].FranchisorFranchisorUserID, franchisoruser[icount].FranchisorUser.User.FirstName + " " + franchisoruser[icount].FranchisorUser.User.LastName, strAddress, objCommonCode.FormatPhoneNumberGet(franchisoruser[icount].FranchisorUser.User.PhoneCell.ToString()), franchisoruser[icount].FranchisorUser.User.UserID.ToString() }); } } if ((SortDirection)ViewState["SortFAUser"] == SortDirection.Descending) { dtFAUser.DefaultView.Sort = "name desc"; } else { dtFAUser.DefaultView.Sort = "name asc"; } dtFAUser = dtFAUser.DefaultView.ToTable(); grdFAUser.DataSource = dtFAUser; ViewState["DSGRID"] = dtFAUser; grdFAUser.DataBind(); //grdFAUser.Sort("name", SortDirection.Ascending);//always sorts in descending order. hfFranchisorUserID.Value = ""; }
/// <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")); } } }