Exemple #1
0
        public static void add_to_list_changing(changing entity)
        {
            if (Base.first_c == null)
            {
                Base.first_c      = Base.last_c = new changing(entity);
                Base.first_c.next = null;
                return;
            }
            changing new_change = new changing(entity);

            new_change.next  = null;
            Base.last_c.next = new_change;
            Base.last_c      = new_change;
        }
Exemple #2
0
 //
 public static void read_changing()
 {
     using (StreamReader sr = File.OpenText(constants.changing)) {
         string s = "";
         while ((s = sr.ReadLine()) != null)
         {
             string [] temp   = s.Split(new string [] { "," }, StringSplitOptions.RemoveEmptyEntries);
             string [] temp2  = temp[0].Split(new string [] { "." }, StringSplitOptions.RemoveEmptyEntries);
             DateTime  date   = new DateTime(int.Parse(temp2 [2]), int.Parse(temp2 [1]), int.Parse(temp2 [0]));
             changing  entity = new changing(date,
                                             temp[1],
                                             int.Parse(temp[2]));
             add_to_list_changing(entity);
         }
     }
 }
Exemple #3
0
        public static change view_changing(Int32 id)
        {
            Decimal profit       = 0;
            DL      temp         = new DL();
            string  name_company = temp [id].name;            //here we have a name of needed company

            //searching
            Decimal old_cost = 0;
            Entity  i        = Base.first_e;

            while (i != null)
            {
                //for each record in entity's list we should calculate profit
                if (i.name == name_company)
                {
                    //ok, this's needed company
                    //let's calculate profit
                    changing j = Base.first_c;
                    Decimal  q = i.count * i.cost;
                    while (j != null)
                    {
                        if (j.name == name_company && j.date.CompareTo(i.date) > 0)
                        {
                            q = q * (1 + (Decimal)j.change / 100);
                        }
                        j = j.next;
                    }
                    old_cost += i.cost * i.count;
                    profit   += q;
                }
                i = i.next;
            }
            change ret = new change();

            ret.new_cost = profit;
            ret.profit   = profit - old_cost;
            ret.percent  = ((float)(profit / old_cost) - 1) * 100;
            return(ret);
        }
Exemple #4
0
 public changing(changing copy)
 {
     this.change = copy.change;
     this.date   = copy.date;
     this.name   = copy.name;
 }