Beispiel #1
0
    public List <Fabrica> createTable()
    {
        var farmManager =
            new FarmManager(ConfigurationManager.ConnectionStrings["AdditionalInformation"].ConnectionString);

        var factory = Fabrica.Text.Length > 0 ? Fabrica.Text.Trim() : null;
        var farm    = Ferma.Text.Length > 0 ? Ferma.Text.Trim() : null;
        var cod     = Code.Text.Length > 0 ? Code.Text.Trim() : null;

        var farms = farmManager.GetAllFarms(farm, cod);

        var factoryManager =
            new FactoryManager(ConfigurationManager.ConnectionStrings["AdditionalInformation"].ConnectionString);
        var factories = factoryManager.GetFactories(factory);

        var countiesManager =
            new CountyManager(ConfigurationManager.ConnectionStrings["fccl2ConnectionString"].ConnectionString);
        var counties = countiesManager.GetAllCounties();

        var values = farms.Select(x => new Fabrica
        {
            id        = x.Id.ToString(),
            cod       = x.Cod,
            nume      = x.Nume,
            numar     = x.Numar,
            email     = x.Email,
            telefon   = x.Telefon,
            oras      = x.Oras,
            strada    = x.Strada,
            fabricaid = x.FabricaId.ToString(),
            judet     = x.Judet
        }).ToList();

        var farctorieslist = values.ToList();

        foreach (var fabrica in farctorieslist)
        {
            var factoryEntity = factories.FirstOrDefault(x => x.Id.ToString(CultureInfo.InvariantCulture) == fabrica.fabricaid);
            if (factoryEntity == null)
            {
                values.Remove(fabrica);
            }
            else
            {
                fabrica.fabricaid = factoryEntity.Nume;
            }

            var countyEntity = counties.FirstOrDefault(x => x.Id.ToString(CultureInfo.InvariantCulture) == fabrica.judet);
            if (countyEntity != null)
            {
                fabrica.judet = countyEntity.DenLoc;
            }
        }

        lcount.Text = values.Count + " ferme";
        return(values);
    }
Beispiel #2
0
        public ActionResult Create()
        {
            CreateClientViewModel model = new CreateClientViewModel();
            var allEthnicities          = EthnicityManager.GetAll();
            var allDemographics         = DemographicManager.GetAll();
            var allAbuseTypes           = AbuseTypeManager.GetAll();
            var allCounties             = CountyManager.GetAll();
            var allServiceCounties      = CountyManager.GetInServiceArea();
            var allTypes    = TypeManager.GetAll();
            var allStates   = StateManager.GetAll();
            var allGenders  = GenderManager.GetAll();
            var allStatuses = StatusManager.GetAll();

            var checkBoxListItems          = new List <CheckBoxListItem>();
            var abuseTypeCheckBoxListItems = new List <CheckBoxListItem>();

            model.Ethnicities       = allEthnicities;
            model.CountyOfResidence = allCounties;
            model.CountyOfIncident  = allServiceCounties;
            model.Genders           = allGenders;
            model.Types             = allTypes;
            model.States            = allStates;
            model.Statuses          = allStatuses;

            foreach (var demographic in allDemographics)
            {
                checkBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = demographic.DemographicId,
                    Display   = demographic.DemographicName,
                    IsChecked = false //On the add view, no genres will be selected by default
                });
            }

            model.Demographics = checkBoxListItems;

            foreach (var abuseType in allAbuseTypes)
            {
                abuseTypeCheckBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = abuseType.AbuseTypeId,
                    Display   = abuseType.AbuseTypeName,
                    IsChecked = false //On the add view, no genres will be selected by default
                });
            }

            model.AbuseTypes = abuseTypeCheckBoxListItems;

            return(View(model));
        }
Beispiel #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            FCCL_DAL.Entities.Ferme_CCL farm = null;
            if (Request.Params["ID"] != null)
            {
                var farmManager = new FarmManager(ConfigurationManager.ConnectionStrings["AdditionalInformation"].ConnectionString);
                farm = farmManager.GetFarmById(Convert.ToInt32(Request.Params["ID"]));
            }

            var fabricaManager =
                new FactoryManager(ConfigurationManager.ConnectionStrings["AdditionalInformation"].ConnectionString);
            var fabrici = fabricaManager.GetFactories();
            Asociatia.DataSource = fabrici;
            if (farm != null && farm.FabricaId != null)
            {
                Asociatia.SelectedValue = farm.FabricaId.ToString();
            }
            Asociatia.DataBind();

            var countyManager =
                new CountyManager(ConfigurationManager.ConnectionStrings["fccl2ConnectionString"].ConnectionString);
            var counties = countyManager.GetAllCounties();
            Judet.DataSource = counties;
            if (farm != null && farm.JudetId != null)
            {
                Judet.SelectedValue = farm.JudetId.ToString();
            }
            Judet.DataBind();

            InsertF.Visible = true;

            if (farm != null)
            {
                //populate farm table
                IdFerma.Text        = farm.Id.ToString();
                FermaCod.Text       = farm.Cod;
                FermaName.Text      = farm.Nume;
                FarmEmail.Text      = farm.Email;
                Localitate.Text     = farm.Oras;
                Strada.Text         = farm.Strada;
                Numar.Text          = farm.Numar;
                CodPostal.Text      = farm.CodPostal;
                Telefon.Text        = farm.Telefon;
                Fax.Text            = farm.Fax;
                PersContact.Text    = farm.PersoanaDeContact;
                TelPersContact.Text = farm.TelPersoanaContact;
                SendSms.Checked     = farm.SendSms;

                //populate user table
                var userManager =
                    new UserManager(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
                var userInfo = userManager.GetUserInformationByCod(farm.Cod);
                if (userInfo != null)
                {
                    UserId.Value           = userInfo.UserId.ToString();
                    Nume.Text              = userInfo.LastName;
                    Prenume.Text           = userInfo.FirstName;
                    UserNameLbl.Text       = userInfo.UserName;
                    Email.Text             = userInfo.Email;
                    Update.Visible         = true;
                    ResetareParola.Visible = true;
                    UserNameLbl.Visible    = true;
                    Parola.Visible         = false;
                }
                else
                {
                    Insert.Visible   = true;
                    UserName.Visible = true;
                }
                UserCodLbl.Text = farm.Cod;
                UpdateF.Visible = true;
                DeleteF.Visible = true;
            }
        }
    }
Beispiel #4
0
        public ActionResult CountryLookup()
        {
            var countries = CountyManager.GetCountries();

            return(Json(countries, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public ActionResult Edit(int id)
        {
            var client = ClientManager.GetById(id);
            var model  = new EditClientViewModel()
            {
                ID = client.ID,
                ClientFirstName     = client.ClientFirstName,
                ClientMiddleInitial = client.ClientMiddleInitial,
                ClientLastName      = client.ClientLastName,
                DateofBirth         = client.DateofBirth,
                DateofFirstContact  = client.DateofFirstContact,
                Address1            = client.Address1,
                Address2            = client.Address2,
                City    = client.City,
                Phone   = client.Phone,
                ZipCode = client.ZipCode,
                EmergencyContactName  = client.EmergencyContactName,
                EmergencyContactPhone = client.EmergencyContactPhone,
                EthnicityId           = client.EthnicityId,
                ClientNumber          = client.ClientNumber,
                CountyOfResidenceId   = client.CountyOfResidenceId,
                CountyOfIncidentId    = client.CountyOfIncidentId,
                StateId  = client.StateId,
                GenderId = client.GenderId,
                TypeId   = client.TypeId,
                StatusId = client.StatusId
            };


            var allGenders     = GenderManager.GetAll();
            var allEthnicities = EthnicityManager.GetAll();
            var allCounties    = CountyManager.GetAll();
            var allStates      = StateManager.GetAll();
            var allTypes       = TypeManager.GetAll();
            var allStatuses    = StatusManager.GetAll();


            model.Genders           = allGenders;
            model.Ethnicities       = allEthnicities;
            model.CountyOfIncident  = allCounties;
            model.CountyOfResidence = allCounties;
            model.States            = allStates;
            model.Types             = allTypes;
            model.Statuses          = allStatuses;

            var clientDemographics = DemographicManager.GetForClient(id);
            var allDemographics    = DemographicManager.GetAll();
            var checkBoxListItems  = new List <CheckBoxListItem>();

            foreach (var demographic in allDemographics)
            {
                checkBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = demographic.DemographicId,
                    Display   = demographic.DemographicName,
                    IsChecked = clientDemographics.Where(x => x.DemographicId == demographic.DemographicId).Any()
                });
            }
            ;

            model.Demographics = checkBoxListItems;

            var clientAbuseTypes           = AbuseTypeManager.GetForClient(id);
            var allAbuseTypes              = AbuseTypeManager.GetAll();
            var abuseTypeCheckBoxListItems = new List <CheckBoxListItem>();

            foreach (var abuseType in allAbuseTypes)
            {
                abuseTypeCheckBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = abuseType.AbuseTypeId,
                    Display   = abuseType.AbuseTypeName,
                    IsChecked = clientAbuseTypes.Where(x => x.AbuseTypeId == abuseType.AbuseTypeId).Any()
                });
            }
            ;

            model.AbuseTypes = abuseTypeCheckBoxListItems;

            return(View(model));
        }