예제 #1
0
        private void find_provider_Click(object sender, EventArgs e)
        {
            if (provider_find_title.Text == "")
            {
                error_number = 1;
                message_box(error_number);
            }
            else if (provider_find_title.Text.Length > 30)
            {
                error_number = 2;
                message_box(error_number);
            }
            else if (provider.find(provider_find_title.Text) == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else
            {
                tree_providers.root a          = provider.find(provider_find_title.Text);
                searchform_provider searchform = new searchform_provider(a, this);

                searchform.Show();
            }
            provider_find_title.Text = "";
        }
예제 #2
0
        public nest find(string name, tree_providers.root provider)
        {
            int hash = getkey(name, provider.title);
            int j    = 0;

            //int tar_checked = 0;
            //nest curr = first;
            while (true)
            {
                int curr_hash = (gethash_1(hash) + j * gethash_2(hash)) % max_elements;
                // if (tar_checked == num_of_elements)
                //   return null;

                /* while (curr.hash != curr_hash)
                 * {
                 *   curr = curr.next;
                 * }*/
                //tar_checked++;
                if (free(mas[curr_hash]))
                {
                    return(null);
                }
                if ((mas[curr_hash].name == name) && (mas[curr_hash].provider == provider) && (!mas[curr_hash].deleted))
                {
                    comparisons++;
                    return(mas[curr_hash]);
                }
                else
                {
                    comparisons++;
                }
                j++;
            }
        }
예제 #3
0
 /*        private void to_file_Click(object sender, EventArgs e)
  *      {
  *          StreamWriter out_file = new StreamWriter(@"c:\курсач\курсач\output_user.txt"); //(@"c:\курсач\курсач\output_user.txt"); @"c:\gitjub\курсач\output_user.txt"
  *          spisok_users.nest a = user.first;
  *          spisok_users.nest temp = a.chain_next;
  *          string output;
  *          while (true)
  *          {
  *              output = "";
  *              output += a.login;
  *              output += "/";
  *              output += a.date;
  *              output += "/";
  *              output += a.tariph.name;
  *              out_file.WriteLine(output);
  *              while (temp != a)
  *              {
  *                  output = "";
  *                  output += temp.login;
  *                  output += "/";
  *                  output += temp.date;
  *                  output += "/";
  *                  output += temp.tariph.name;
  *                  out_file.WriteLine(output);
  *                  temp = temp.chain_next;
  *
  *              }
  *              a = a.next;
  *              if (a == null)
  *                  break;
  *              temp = a.chain_next;
  *          }
  *          out_file.WriteLine("//");
  *          output_for_sales(out_file, sales.main);
  *          out_file.Close();
  *
  *      }
  *      private void from_file_button_Click(object sender, EventArgs e)
  *      {
  *
  *
  *      }
  */
 public void output_for_provider(StreamWriter file, tree_providers.root pr)
 {
     if (pr == null)
     {
         return;
     }
     file.WriteLine(pr.title);
     // file.Write("\n");
     for (int i = 0; i < pr.current_tariph; i++)
     {
         string temp = "";
         temp += pr.arr[i].name;
         temp += "/";
         temp += pr.arr[i].cost.ToString();
         spisok_tariph.nest a = tariph.find(pr.arr[i].name, pr);
         temp += "/";
         temp += a.type.ToString();
         temp += "/";
         temp += a.speed.ToString();
         file.WriteLine(temp);
         // file.Write("\n");
     }
     file.WriteLine("//");
     output_for_provider(file, pr.left);
     output_for_provider(file, pr.right);
 }
예제 #4
0
        private void button9_Click(object sender, EventArgs e)
        {
            tree_providers.root check1 = provider.find(sale_find_provider.Text);
            spisok_tariph.nest  check  = null;
            if (check1 != null)
            {
                check = tariph.find(sale_find_tariph.Text, provider.find(sale_find_provider.Text));
            }

            if (sale_find_tariph.Text == "" || sale_find_provider.Text == "" || sale_find_size.Text == "")
            {
                error_number = 1;
                message_box(error_number);
            }
            else if (!sale_check(sale_find_size.Text) || sale_find_provider.Text.Length > 30 || sale_find_tariph.Text.Length > 30)
            {
                error_number = 2;
                message_box(error_number);
            }
            else if (check == null || check1 == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else
            {
                tree_sale.root  s          = sales.find(sale_find_size.Text, tariph.find(sale_find_tariph.Text, provider.find(sale_find_provider.Text)));
                searchform_sale searchform = new searchform_sale(s, this);
                searchform.Show();
            }

            sale_find_provider.Text = sale_find_size.Text = sale_find_tariph.Text = "";
        }
예제 #5
0
 public nest()
 {
     name     = "";
     type     = 0;
     speed    = 0;
     provider = null;
     deleted  = false;
 }
예제 #6
0
 private void buttonCreateReport_Click(object sender, EventArgs e)
 {
     dataGridViewTypeRep.Rows.Clear();
     pr   = f2.provider.find(textBoxProvider.Text);
     type = 0;
     if ((checkBoxAddTariphInternet.Checked) && (checkBoxAddTariphTV.Checked))
     {
         type = 2;
     }
     else if (checkBoxAddTariphTV.Checked)
     {
         type = 3;
     }
     else if (checkBoxAddTariphInternet.Checked)
     {
         type = 2;
     }
     if (type == 0)
     {
         error_number = 1;
         f2.message_box(error_number);
     }
     else if (textBoxProvider.Text == "")
     {
         error_number = 1;
         f2.message_box(error_number);
     }
     else if (pr == null)
     {
         error_number = 3;
         f2.message_box(error_number);
     }
     else if (textBoxProvider.Text.Length > 30)
     {
         error_number = 2;
         f2.message_box(error_number);
     }
     else
     {
         string name = "";
         for (int i = 0; i < pr.current_tariph; i++)
         {
             spisok_tariph.nest a = f2.tariph.find(pr.arr[i].name, pr);
             if (a.type == type)
             {
                 name = a.name;
                 dataGridViewTypeRep.Rows.Add(name);
             }
         }
     }
 }
예제 #7
0
        public void delete(string name, tree_providers.root provider)
        {
            nest curr = find(name, provider);

            if (curr != null)
            {
                //num_of_elements;
                curr.deleted = true;
            }
            else
            {
                //error
            }
        }
예제 #8
0
        public bool add(string name, int type, int speed, tree_providers.root provider)
        {
            if (num_of_elements == max_elements)
            {
                resize(false);
            }
            int j = 0;
            //bool added = false;
            //int hash_1 = gethash_different(name);
            int curr_hash = gethash_different(name);

            //int hash_2 = gethash_2(getkey(name, ""));
            while (true)
            {
                /*while (curr.hash != curr_hash)
                 * {
                 *  curr = curr.next;
                 * }*/

                if (free(mas[curr_hash]))
                {
                    if (mas[curr_hash].deleted == false)
                    {
                        num_of_elements++;
                    }
                    mas[curr_hash].name     = name;
                    mas[curr_hash].type     = type;
                    mas[curr_hash].speed    = speed;
                    mas[curr_hash].provider = provider;
                    mas[curr_hash].deleted  = false;
                    mas[curr_hash].hash     = curr_hash;

                    return(true);
                }
                else if ((mas[curr_hash].name == name) && (mas[curr_hash].provider == provider))
                {
                    return(false);
                }
                else
                {
                    collisions++;
                    curr_hash = (curr_hash + 1) % max_elements;
                }
            }
        }
예제 #9
0
        public void get_provider_info(string[] line, tree_providers.root pr)
        {
            if (pr == null)
            {
                return;
            }
            line[0] = pr.title;
            if (pr.current_tariph == 0)
            {
                line[1] = "Нет тарифов";
                line[2] = "";
                dataGridViewProviders.Rows.Add(line);
            }
            else
            {
                for (int i = 0; i < pr.current_tariph; i++)
                {
                    line[1] = pr.arr[i].name;
                    line[2] = pr.arr[i].cost.ToString();
                    dataGridViewProviders.Rows.Add(line);
                }
            }

            /*switch (a.type)
             * {
             *  case 1:
             *      line[3] = "Интеренет";
             *      break;
             *  case 2:
             *      line[3] = "Интернет и ТВ";
             *      break;
             *  case 3:
             *      line[3] = "ТВ";
             *      break;
             * }
             * //line[3] = a.type.ToString();
             * line[4] = a.speed.ToString();
             * line[5] = pr.arr[i].cost.ToString();
             *
             * }*/

            get_provider_info(line, pr.left);
            get_provider_info(line, pr.right);
        }
예제 #10
0
 private void button6_Click(object sender, EventArgs e)
 {
     tree_providers.root check1 = provider.find(tariph_del_provider.Text);
     spisok_tariph.nest  check  = null;
     if (check1 != null)
     {
         check = tariph.find(tariph_del_title.Text, check1);
     }
     spisok_tariph.nest a = check;
     if (tariph_del_title.Text == "" || tariph_del_provider.Text == "")
     {
         error_number = 1;
         message_box(error_number);
     }
     else if (tariph_del_title.Text.Length > 30 || tariph_del_provider.Text.Length > 30)
     {
         error_number = 2;
         message_box(error_number);
     }
     else if (check == null || check1 == null)
     {
         error_number = 3;
         message_box(error_number);
     }
     else
     {
         for (int i = 0; i < a.provider.current_user; i++)
         {
             if (user.find(a.provider.users[i]).tariph == a)
             {
                 user.delete(a.provider.users[i]);
                 provider.delete_user(a.provider.users[i], a.provider.title);
             }
         }
         sales.delete_tariph(a, sales.main);
         provider.del_tariph(a.name, a.provider);
         tariph.delete(a.name, check1);
         error_number = 10;
         message_box(error_number);
     }
     tariph_del_title.Text = tariph_del_provider.Text = "";
 }
 private void buttonCreateReport_Click(object sender, EventArgs e)
 {
     dataGridViewUsersRep.Rows.Clear();
     if (textBoxProvider.Text == "")
     {
         error_number = 1;
         f2.message_box(error_number);
     }
     else if (textBoxProvider.Text.Length > 30)
     {
         error_number = 2;
         f2.message_box(error_number);
     }
     pr = f2.provider.find(textBoxProvider.Text);
     string[] line = new string[2];
     for (int i = 0; i < pr.current_user; i++)
     {
         spisok_users.nest u = f2.user.find(pr.users[i]);
         if (u == null)
         {
             error_number = 3;
             f2.message_box(error_number);
         }
         else
         {
             tree_sale.root s = f2.user.check_for_sale(u.tariph, f2.sales.main, u);
             if (s == null)
             {
                 line[0] = u.login;
                 line[1] = "0";
                 dataGridViewUsersRep.Rows.Add(line);
             }
             else
             {
                 line[0] = u.login;
                 line[1] = s.size;
                 dataGridViewUsersRep.Rows.Add(line);
             }
         }
     }
 }
예제 #12
0
        private void add_sale_Click(object sender, EventArgs e)
        {
            tree_providers.root check1 = provider.find(sale_provider.Text);
            spisok_tariph.nest  check  = null;
            if (check1 != null)
            {
                check = tariph.find(sale_tariph.Text, check1);
            }

            if (sale_num.Text == "" || sale_length.Text == "" || sale_provider.Text == "" || sale_tariph.Text == "")
            {
                error_number = 1;
                message_box(error_number);
            }
            else if (check == null || check1 == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else if (!sale_check(sale_num.Text) || !check_for_int(sale_length.Text) || sale_length.Text.Length > 3 || sale_provider.Text.Length > 30 || sale_tariph.Text.Length > 30)
            {
                error_number = 2;
                message_box(error_number);
            }
            else if (sales.find(sale_num.Text, check) != null)
            {
                error_number = 4;
                message_box(error_number);
            }
            else
            {
                //spisok_tariph.nest a = tariph.find(sale_tariph.Text, provider.find(sale_provider.Text));
                sales.add_sale(sale_num.Text, sale_length.Text, check);//, a.provider);

                error_number = 0;
                message_box(error_number);
            }
            sale_num.Text = sale_tariph.Text = sale_provider.Text = sale_length.Text = "";
        }
예제 #13
0
        private void button8_Click(object sender, EventArgs e)
        {
            tree_providers.root check1 = provider.find(user_provider.Text);
            spisok_tariph.nest  check  = null;
            if (check1 != null)
            {
                check = tariph.find(user_tariph.Text, check1);
            }

            if (user_login.Text == "" || user_provider.Text == "" || user_tariph.Text == "" || user_date.Text == "")
            {
                error_number = 1;
                message_box(error_number);
            }
            else if (!date_check(user_date.Text) || user_login.Text.Length > 30 || user_provider.Text.Length > 30 || user_tariph.Text.Length > 30)
            {
                error_number = 2;
                message_box(error_number);
            }
            else if (check == null || check1 == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else if (user.find(user_login.Text) != null)
            {
                error_number = 4;
                message_box(error_number);
            }
            else
            {
                user.add(/*user.get_hash(user_login.Text),*/ user_login.Text, user_date.Text, tariph.find(user_tariph.Text, provider.find(user_provider.Text)));
                provider.add_user(user_login.Text, user_provider.Text);
                error_number = 0;
                message_box(error_number);
            }

            user_login.Text = user_date.Text = user_tariph.Text = user_provider.Text = "";
        }//
예제 #14
0
 private void button5_Click(object sender, EventArgs e)
 {
     tree_providers.root pr = provider.find(provider_del_title.Text);
     if (provider_del_title.Text == "")
     {
         error_number = 1;
         message_box(error_number);
     }
     else if (provider_del_title.Text.Length > 30)
     {
         error_number = 2;
         message_box(error_number);
     }
     else if (pr == null)
     {
         error_number = 3;
         message_box(error_number);
     }
     else
     {
         while (pr.current_user > 0)
         {
             user.delete(pr.users[0]);
             provider.delete_user(pr.users[0], pr.title);
         }
         while (pr.current_tariph > 0)
         {
             sales.delete_tariph(tariph.find(pr.arr[0].name, pr), sales.main);
             tariph.delete(pr.arr[0].name, pr);
             provider.del_tariph(pr.arr[0].name, pr);
         }
         provider.delete(provider_del_title.Text);
         error_number = 10;
         message_box(error_number);
     }
     provider_del_title.Text = "";
 }
예제 #15
0
        private void button11_Click(object sender, EventArgs e)
        {
            tree_providers.root check1 = provider.find(sale_del_provider.Text);
            spisok_tariph.nest  check  = null;
            if (check1 != null)
            {
                check = tariph.find(sale_del_tar.Text, provider.find(sale_del_provider.Text));
            }

            if (sale_del_size.Text == "" || sale_del_tar.Text == "" || sale_del_provider.Text == "")
            {
                error_number = 1;
                message_box(error_number);
            }
            else if (!sale_check(sale_del_size.Text) || sale_del_tar.Text.Length > 30 || sale_find_provider.Text.Length > 30)
            {
                error_number = 2;
                message_box(error_number);
            }
            else if (check1 == null || check == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else if (sales.find(sale_del_size.Text, check) == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else
            {
                sales.delete(sale_del_size.Text, tariph.find(sale_del_tar.Text, provider.find(sale_del_provider.Text)));
                error_number = 10;
                message_box(error_number);
            }
            sale_del_tar.Text = sale_del_size.Text = sale_del_provider.Text = "";
        }
 public searchform_provider(tree_providers.root a, Form2 f2)
 {
     InitializeComponent();
     pr      = a;
     this.f2 = f2;
 }
예제 #17
0
        public bool add(int k, string name, int type, int speed, tree_providers.root provider)// добавление нового элемента
        {
            if (num_of_elements == max_elements)
            {
                resize(true);
                //k = getkey(name, provider.title);
                k = getkey(name, "");
            }
            int j = 0;
            //bool added = false;
            int hash_1 = gethash_1(k);
            int hash_2 = gethash_2(k);

            while (true)
            {
                int curr_hash = (hash_1 + j * hash_2) % max_elements;

                /*while (curr.hash != curr_hash)
                 * {
                 *  curr = curr.next;
                 * }*/

                if (free(mas[curr_hash]))
                {
                    if (mas[curr_hash].deleted == false)
                    {
                        num_of_elements++;
                    }
                    mas[curr_hash].name     = name;
                    mas[curr_hash].type     = type;
                    mas[curr_hash].speed    = speed;
                    mas[curr_hash].provider = provider;
                    mas[curr_hash].deleted  = false;
                    mas[curr_hash].hash     = curr_hash;

                    return(true);
                }
                else if ((mas[curr_hash].name == name) && (mas[curr_hash].provider == provider))
                {
                    return(false);
                }
                else
                {
                    collisions++;
                    j++;
                }

                /*if (free(curr))
                 * {
                 *  curr.name = name;
                 *  curr.type = type;
                 *  curr.speed = speed;
                 *  added = true;
                 *  if(curr.deleted == false)
                 *  num_of_elements++;
                 *  curr.provider = provider;
                 *  curr.deleted = false;
                 *  return true;
                 * }
                 * else if ((curr.name == name)  && (curr.provider == provider))
                 *  return false;
                 * else
                 *  j++;*/
            }
        }