Ejemplo n.º 1
0
        public List <Loss> GetLosesToPersonalArea(Person person)
        {
            SqlCommand    cmd        = ConnectSql(string.Format("Select * From Loss Where LoseID = '{0}'", person.PersonID));
            SqlDataReader reader     = cmd.ExecuteReader();
            List <Loss>   resultLoss = new List <Loss>();
            Loss          loss       = new Loss();

            while (reader.Read())
            {
                resultLoss.Add(loss.Initialization(reader));
            }
            connection.DisConnectSql();
            int x = resultLoss.Count();

            return(resultLoss);
        }
Ejemplo n.º 2
0
        public List <Loss> SearchLosses(Signs signs)
        {
            SqlCommand    cmd          = ConnectSql("Select * From Loss");
            SqlDataReader reader       = cmd.ExecuteReader();
            List <Loss>   resultLosses = new List <Loss>();
            Loss          loss         = new Loss();

            while (reader.Read())
            {
                resultLosses.Add(loss.Initialization(reader));
            }
            connection.DisConnectSql();

            int flag, i, j;

            for (i = resultLosses.Count() - 1; i >= 0; i--)
            {
                flag = 0;
                if (resultLosses[i].LossDate.CompareTo(signs.Date.Subtract(TimeSpan.FromDays(7))) >= 0)
                {
                    if (resultLosses[i].CategoryCode == signs.Category)
                    {
                        flag += 30;
                    }
                    if (signs.Description != " ")
                    {
                        string[] description = signs.Description.Split(' ');
                        j = 0;
                        foreach (string word in description)
                        {
                            string[] FoundDesc = resultLosses[i].LossDesc.Split(' ');
                            foreach (string desc in FoundDesc)
                            {
                                j += word.Contains(desc) == true ? 1 : 0;
                            }
                        }
                        if (j != 0)
                        {
                            flag += 20;
                        }
                    }
                    else
                    {
                        flag += 10;
                    }
                    if (GetRelevantColors(signs.Color).Contains(resultLosses[i].LossColor.ToString()))
                    {
                        flag += 15;
                    }
                    if (signs.Remarks != " ")
                    {
                        string[] remarks = signs.Remarks.Split(' ');
                        j = 0;
                        foreach (string word in remarks)
                        {
                            string[] FoundRemark = resultLosses[i].Remarks.Split(' ');
                            foreach (string remark in FoundRemark)
                            {
                                j += word.Contains(remark) == true ? 1 : 0;
                            }
                        }
                        if (j != 0)
                        {
                            flag += 20;
                        }
                    }
                    else
                    {
                        flag += 10;
                    }
                }
                if (flag <= 60)
                {
                    resultLosses.Remove(resultLosses[i]);
                }
            }

            return(resultLosses);
        }