예제 #1
0
        public bool Can_get_sale(spisok_users.nest u, tree_sale.root s)
        {
            int time          = Convert.ToInt32(s.date);
            int user_day      = (Convert.ToInt32(u.date[0]) - 48) * 10 + (Convert.ToInt32(u.date[1]) - 48);
            int user_month    = (Convert.ToInt32(u.date[3]) - 48) * 10 + (Convert.ToInt32(u.date[4]) - 48);
            int user_year     = (Convert.ToInt32(u.date[8]) - 48) * 10 + (Convert.ToInt32(u.date[9]) - 48);
            int compare_day   = 10;
            int compare_month = 7;
            int compare_year  = 20;
            int years         = 0;

            while (time >= 12)
            {
                time -= 12;
                years++;
            }
            if (compare_year - years < user_year)
            {
                return(false);
            }
            else if (user_month + time > 12)
            {
                user_month -= 12 + time;
                user_year++;
            }
            else if (user_year + years > compare_year)
            {
                return(false);
            }
            else if ((user_day > compare_day) && (user_month >= compare_month) && (user_year + years == compare_year))
            {
                return(false);
            }
            return(true);
        }
예제 #2
0
        private void del_user_Click(object sender, EventArgs e)
        {
            spisok_users.nest a = user.find(user_del_login.Text);

            if (user_del_login.Text == "")
            {
                error_number = 1;
                message_box(error_number);
            }
            else if (user_del_login.Text.Length > 30)
            {
                error_number = 2;
                message_box(error_number);
            }
            else if (a == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else
            {
                provider.delete_user(user_del_login.Text, a.tariph.provider.title);
                user.delete(user_del_login.Text);
                error_number = 10;
                message_box(error_number);
            }
            user_del_login.Text = "";
        }
예제 #3
0
        private void button10_Click(object sender, EventArgs e)
        {
            if (user_find_login.Text == "")
            {
                error_number = 1;
                message_box(error_number);
            }
            else if (user_find_login.Text.Length > 30)
            {
                error_number = 2;
                message_box(error_number);
            }
            else if (user.find(user_find_login.Text) == null)
            {
                error_number = 3;
                message_box(error_number);
            }
            else
            {
                user.comparisons = 0;
                spisok_users.nest a          = user.find(user_find_login.Text);
                search_form_user  searchform = new search_form_user(a, this);
                searchform.Show();
            }

            user_find_login.Text = "";
        }
        private void buttonCreateReport_Click(object sender, EventArgs e)
        {
            dataGridViewSalesRep.Rows.Clear();

            if (textBoxLogin.Text == "")
            {
                error_number = 1;
                f2.message_box(error_number);
                return;
            }
            else if (textBoxLogin.Text.Length > 30)
            {
                error_number = 2;
                f2.message_box(error_number);
                return;
            }
            user = f2.user.find(textBoxLogin.Text);
            tree_sale.root sale = f2.sales.main;
            string[]       line = new string[3];
            if (user != null)
            {
                potential_sale(line, sale, user);
            }
            else
            {
                error_number = 3;
                f2.message_box(error_number);
            }
        }
예제 #5
0
        public void sale_obhod_po_skidke(tree_sale.root s, string size, string[] line)
        {
            if (s == null)
            {
                return;
            }
            int i = f2.user.compare_int(s.size, size);

            if (i == -1)
            {
                sale_obhod_po_skidke(s.right, size, line);
            }
            else if (i == 0)
            {
                for (int j = 0; j < s.tariph.provider.current_user; j++)
                {
                    spisok_users.nest u = f2.user.find(s.tariph.provider.users[j]);
                    if ((u.tariph == s.tariph) && f2.user.Can_get_sale(u, s))
                    {
                        line[0] = u.login;
                        line[1] = u.tariph.provider.title;
                        line[2] = u.tariph.name;
                        dataGridViewSaleForUsers.Rows.Add(line);
                        num++;
                    }
                }
                sale_obhod_po_skidke(s.left, size, line);
                sale_obhod_po_skidke(s.right, size, line);
            }
            else if (i == 1)
            {
                sale_obhod_po_skidke(s.left, size, line);
            }
        }
 public void potential_sale(string[] line, tree_sale.root s, spisok_users.nest u)
 {
     if (s == null)
     {
         return;
     }
     potential_sale(line, s.left, u);
     if (f2.user.Can_get_sale(u, s))
     {
         line[0] = s.size;
         line[1] = s.tariph.provider.title;
         line[2] = s.tariph.name;
         dataGridViewSalesRep.Rows.Add(line);
     }
     potential_sale(line, s.right, u);
 }
 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);
             }
         }
     }
 }
예제 #8
0
 public search_form_user(spisok_users.nest a, Form2 f2)
 {
     InitializeComponent();
     u       = a;
     this.f2 = f2;
 }
예제 #9
0
 public tree_sale.root check_for_sale(spisok_tariph.nest tar, tree_sale.root s, spisok_users.nest u)
 {
     if (s == null)
     {
         return(null);
     }
     tree_sale.root s1 = check_for_sale(tar, s.left, u);
     tree_sale.root s2 = check_for_sale(tar, s.right, u);
     if ((u.tariph == s.tariph) && (Can_get_sale(u, s)))
     {
         if (s2 != null)
         {
             if (s2.size.Length > s.size.Length)
             {
                 return(s2);
             }
             else if (s2.size[0] > s.size[0])
             {
                 return(s2);
             }
             else if (s2.size[1] > s.size[1])
             {
                 return(s2);
             }
         }
         else
         {
             return(s);
         }
     }
     else
     if ((s1 != null) || (s2 != null))
     {
         if (s2 != null)
         {
             return(s2);
         }
         else
         {
             return(s1);
         }
     }
     return(null);
 }
예제 #10
0
        private void refresh_users_Click(object sender, EventArgs e)
        {
            dataGridViewUsers.Rows.Clear();
            dataGridViewSales.Rows.Clear();
            string[] sale = new string[3];
            string[] us   = new string[4];
            sale_out(sale, sales.main);

            int it = 0;

            //spisok_users.nest temp = user.table[it];

            while (it < user.max_elements)
            {
                if (user.table[it] != null)
                {
                    us[0] = user.table[it].login;
                    us[1] = it.ToString();//temp.hash.ToString();
                    us[2] = user.table[it].tariph.name;
                    us[3] = user.table[it].date;
                    dataGridViewUsers.Rows.Add(us);

                    spisok_users.nest curr = user.table[it].next;
                    //spisok_users.nest start = user.table[it];
                    while (curr != user.table[it])
                    {
                        us[0] = curr.login;
                        us[1] = it.ToString();//curr.hash.ToString();
                        us[2] = curr.tariph.name;
                        us[3] = curr.date;
                        dataGridViewUsers.Rows.Add(us);
                        curr = curr.next;
                    }
                }
                it++;
            }


            /*if (temp == null)
             *  return;
             * spisok_users.nest curr = temp.chain_next;
             * if (!tariph.free(temp.tariph))
             * {
             *  us[0] = temp.login;
             *  us[1] = temp.hash.ToString();
             *  us[2] = temp.tariph.name;
             *  us[3] = temp.date;
             *  dataGridViewUsers.Rows.Add(us);
             * }
             * while (curr != null)
             * {
             *  if (!tariph.free(curr.tariph))
             *  {
             *      us[0] = curr.login;
             *      us[1] = curr.hash.ToString();
             *      us[2] = curr.tariph.name;
             *      us[3] = curr.date;
             *      dataGridViewUsers.Rows.Add(us);
             *  }
             *  curr = curr.chain_next;
             * }
             * temp = temp.next;
             * curr = temp.chain_next;
             * while (temp != user.first)
             * {
             *  if (!tariph.free(temp.tariph))
             *  {
             *
             *      us[0] = temp.login;
             *      us[1] = temp.hash.ToString();
             *      us[2] = temp.tariph.name;
             *      us[3] = temp.date;
             *      dataGridViewUsers.Rows.Add(us);
             *  }
             *  while (curr != null)
             *  {
             *      if (!tariph.free(curr.tariph))
             *      {
             *
             *          us[0] = curr.login;
             *          us[1] = curr.hash.ToString();
             *          us[2] = curr.tariph.name;
             *          us[3] = curr.date;
             *          dataGridViewUsers.Rows.Add(us);
             *      }
             *      curr = curr.chain_next;
             *  }
             *  temp = temp.next;
             *  curr = temp.chain_next;
             * }*/
        }