public IActionResult SubmitTracking(TrackingForm sub)
        {
            Guid           ident = Guid.NewGuid();
            string         id    = "'" + ident + "'";
            SqlConnection  cnn   = new SqlConnection(connectionString);
            SqlCommand     command;
            SqlDataAdapter adapter = new SqlDataAdapter();

            cnn.Open();

            //Again, makes me vomit. A list of every sql command needed to 😒
            //insert a full tracking form into the database
            //Took me two weeks
            List <string> qs = new List <String>
            {
                "INSERT INTO dbo.demographics VALUES (" + id + ")",
                "INSERT INTO dbo.accomodations VALUES (" + sub.accomGained + "," + sub.compService + ",'" + filterSqlCommand(sub.ifWhatServices) + "'," + sub.addServicesGained + "," + id + ")",
                "INSERT INTO dbo.client VALUES ('" + filterSqlCommand(sub.clientLastName) + "','" + filterSqlCommand(sub.clientFirstName) + "','" + sub.adopted + "','" + sub.clientGender + "','" + sub.clientEthnicity + "','" + sub.clientDOB + "'," + id + ",'" + sub.carePhone + "')",



                "INSERT INTO dbo.advocacy VALUES (" + sub.rearrestAdvocacy + "," + sub.courtAdvocacy + "," + sub.staffAdvocacy + "," + sub.legalAdvocacy + ",'" + filterSqlCommand(sub.legalAdvoTaken) + "'," + id + ")",
                "INSERT INTO dbo.altSchool VALUES (" + sub.altSchool + ",'" + filterSqlCommand(sub.altSchoolName) + "','" + sub.dateOfAlt + "'," + sub.timesInAlt + "," + sub.daysOwed + "," + sub.daysSinceIntake + "," + id + ")",
                "INSERT INTO dbo.bully VALUES (" + sub.bullied + "," + sub.bullyReport + ",'" + sub.dateofBully + "'," + id + ")",
                "INSERT INTO dbo.caregiver VALUES ('" + filterSqlCommand(sub.careFirstName) + "','" + filterSqlCommand(sub.careLastName) + "','" + sub.careGender + "','" + sub.careEthnicity + "'," + "'careRelationship'" + "," + id + ")",

                "INSERT dbo.ccr VALUES ('" + sub.levelOfServiceProvided + "'," + sub.caseStatus + ",'" + filterSqlCommand(sub.nonEngagementReason) + "'," + sub.remedyResolution + "," + sub.rearrestWhileRepresented + ",'" + filterSqlCommand(sub.schoolAtClosure) + "'," + id + "," + sub.intakeDate + ")",
                "INSERT INTO dbo.comp VALUES (" + sub.compService + ",'" + filterSqlCommand(sub.ifWhatServices) + "','" + sub.compTime + "'," + id + ")",

                "INSERT INTO dbo.currentStatus VALUES (" + sub.readingLevel + "," + sub.mathLevel + ",'" + "currentServices?" + "'," + sub.inPride + "," + sub.newFBA + "," + 0 + ",'" + "servicesGained" + "'," + id + ")",
                "INSERT INTO dbo.failed VALUES (" + sub.failedGrade + "," + sub.whichGradeFailed + "," + sub.failCount + "," + id + ")",
                "INSERT INTO dbo.health VALUES (" + sub.baker + "," + sub.marchman + "," + sub.asthma + "," + sub.pregnantparenting + "," + id + ")",
                "INSERT INTO dbo.household VALUES (" + sub.femHouse + "," + sub.domVio + "," + sub.adopted + "," + sub.evicted + "," + sub.incarParent + "," + sub.publicAssistance + "," + id + ")",
                "INSERT INTO dbo.iep VALUES (" + sub.iep + ",'" + filterSqlCommand(sub.iepplan1) + "','" + filterSqlCommand(sub.iepplan2) + "'," + "0" + "," + id + ")",
                "INSERT INTO dbo.legal VALUES ('" + sub.firstLegal + "','" + filterSqlCommand(sub.secondLegal) + "','" + filterSqlCommand(sub.justiceOutcome) + "'," + id + ")",
                "INSERT INTO dbo.refinfo VALUES ('" + filterSqlCommand(sub.reffname) + "','" + filterSqlCommand(sub.reflname) + "','" + sub.referralDate + "'," + id + ",'" + sub.emailOfFirstReferralSource + "')",
                "INSERT INTO dbo.school VALUES (" + id + "," + sub.currentGrade + ",'" + filterSqlCommand(sub.school) + "','" + filterSqlCommand(sub.schoolRef) + "'," + sub.reenrolled + ")",
                "UPDATE refform SET assignRef = 1 WHERE clientCode = '" + sub.refCode + "';",
                "INSERT INTO dbo.referral VALUES ('" + sub.refCode + "'," + id + ")"
            };

            //Um, this needs to be outside of that for some reason
            int totalSus = sub.iss + sub.oss;

            qs.Add("INSERT INTO dbo.suspension VALUES(" + sub.suspended + "," + sub.suspendCount + "," + totalSus + "," + sub.iss + "," + sub.oss + "," + 0 + "," + 0 + "," + id + ")");

            //We now just run through every string in the list, running it as a sql command
            foreach (string query in qs)
            {
                command = new SqlCommand(query, cnn);
                SqlDataReader reader = command.ExecuteReader();
                reader.Close();
            }

            cnn.Close();

            //TODO: Submitting the tracking form changes the related Referral form to closed (In the currStatus field)
            return(RedirectToAction("TrackingList"));
        }
        public ViewResult TrackingForm(Guid clientCode)
        {
            TrackingForm  newF   = new TrackingForm();
            var           relRef = new referralBrandi();
            SqlConnection cnn;

            cnn = new SqlConnection(connectionString);
            SqlCommand     command;
            SqlDataAdapter adapter = new SqlDataAdapter();

            cnn.Open();
            newF.ClientID = clientCode;

            string query = "select * from dbo.refform where clientCode = '" + clientCode + "'";

            command = new SqlCommand(query, cnn);
            SqlDataReader reader = command.ExecuteReader();

            //I hate this. This is just vile 😒
            //We are basically just putting a referral in the tracking model so we
            //can autopopulate values in the tracking form

            while (reader.Read())
            {
                relRef.address = reader.GetString(reader.GetOrdinal("strAddress"));

                if (!reader.IsDBNull(reader.GetOrdinal("moreInfo")))
                {
                    relRef.moreInfo = reader.GetString(reader.GetOrdinal("moreInfo"));
                }

                if (!reader.IsDBNull(reader.GetOrdinal("arrest")))
                {
                    relRef.arrest = reader.GetInt32(reader.GetOrdinal("arrest"));
                }

                if (!reader.IsDBNull(reader.GetOrdinal("currentSchool")))
                {
                    relRef.currentSchool = reader.GetString(reader.GetOrdinal("currentSchool"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("dob")))
                {
                    relRef.dOB = reader.GetDateTime(reader.GetOrdinal("dob"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("email")))
                {
                    relRef.email = reader.GetString(reader.GetOrdinal("email"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("fname")))
                {
                    relRef.fName = reader.GetString(reader.GetOrdinal("fname"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("gender")))
                {
                    relRef.gender = reader.GetString(reader.GetOrdinal("gender"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("grade")))
                {
                    relRef.guardianEmail = reader.GetString(reader.GetOrdinal("grade"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("guardianEmail")))
                {
                    relRef.guardianEmail = reader.GetString(reader.GetOrdinal("guardianEmail"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("guardianName")))
                {
                    relRef.guardianName = reader.GetString(reader.GetOrdinal("guardianName"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("guardianPhone")))
                {
                    relRef.guardianPhone = reader.GetString(reader.GetOrdinal("guardianPhone"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("dateInput")))
                {
                    relRef.dateInput = reader.GetDateTime(reader.GetOrdinal("dateInput"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("guardianRelationship")))
                {
                    relRef.guardianRelationship = reader.GetString(reader.GetOrdinal("guardianRelationship"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("issues")))
                {
                    relRef.issues = reader.GetString(reader.GetOrdinal("issues"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("lname")))
                {
                    relRef.lName = reader.GetString(reader.GetOrdinal("lname"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("meeting")))
                {
                    relRef.meeting = reader.GetInt32(reader.GetOrdinal("meeting"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("Reach")))
                {
                    relRef.reason = reader.GetString(reader.GetOrdinal("Reach"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("reason")))
                {
                    relRef.reason = reader.GetString(reader.GetOrdinal("reason"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("referralfname")))
                {
                    relRef.referralfname = reader.GetString(reader.GetOrdinal("referralfname"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("referrallname")))
                {
                    relRef.referrallname = reader.GetString(reader.GetOrdinal("referrallname"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("school")))
                {
                    relRef.school = reader.GetString(reader.GetOrdinal("school"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("currStatus")))
                {
                    relRef.status = reader.GetString(reader.GetOrdinal("currStatus"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("youthInDuvalSchool")))
                {
                    relRef.youthInDuvalSchool = reader.GetInt32(reader.GetOrdinal("youthInDuvalSchool"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("youthInSchool")))
                {
                    relRef.youthInSchool = reader.GetInt32(reader.GetOrdinal("youthInSchool"));
                }
                if (!reader.IsDBNull(reader.GetOrdinal("zip")))
                {
                    relRef.zip = reader.GetString(reader.GetOrdinal("zip"));
                }
            }


            reader.Close();
            cnn.Close();
            //We push it into the model that gets sent to the view
            newF.referralBrandi = relRef;

            return(View(newF));
        }
Ejemplo n.º 3
0
        private async Task Search(bool isFirst)
        {
            if (Form.HasError || mIsSeaching)
            {
                return;
            }
            if (isFirst != true && mIsLoadedAllData)
            {
                return;
            }
            IsPageDataLoading = !isFirst;
            mIsSeaching = true;
            if (isFirst)
            {
                mIsLoadedAllData = false;
                mCacheSearchForm = Form.Clone() as TrackingForm;
                Logs.Clear(); 
            }

            try
            {
                var jubenTypes = mCacheSearchForm.JubenTypes.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(a => (JubenType)Enum.Parse(typeof(JubenType), a)).ToArray();
                var errorTypes = mCacheSearchForm.JubenErrorTypes.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                   .Select(a => (JubenErrorType)Enum.Parse(typeof(JubenErrorType), a)).ToArray();

                var rv = await Task.Run<CombinationJubenErrorLogData>(() =>
                {
                    return mLogService.SearchLogsByMgmt(jubenTypes, errorTypes, mCacheSearchForm.StartDate,
                        mCacheSearchForm.EndDate, mCacheSearchForm.IsTimeRangeRequired, isFirst ? 0 : mLastId);
                });
                foreach(var item in rv.Items)
                {
                    this.Logs.Add(new UILog()
                    {
                        Id = item.Id,
                        CreateTime = item.CreateTime, 
                        JubenType = item.JubenType,
                        JubenErrorType = item.JubenErrorType, 
                        JubenName = item.JubenName,
                        Logs = item.Logs,
                        Xiake = item.Xiake,
                        XiakeId = item.XiakeId
                    });
                }

                if (rv.Items.Count > 0)
                {
                    mLastId = rv.Items[rv.Items.Count - 1].Id;
                }
                mIsLoadedAllData = rv.IsLoadedAllData;
                if (isFirst)
                {
                    LogView.View.MoveCurrentToFirst();
                    TotalCount = rv.TotalCount;
                }
            }
            catch (Exception e)
            {
                e.Show();
            }
            finally
            {
                mIsSeaching = false;
                IsPageDataLoading = false;
            }

        }