private void ActionWithConsiderationOrder(object sender, SelectedCellsChangedEventArgs e)
        {
            var datas = (DataGrid)sender;

            if (datas.SelectedCells.Count == 0)
            {
                return;
            }
            var dialogResult = MessageBox.Show("Add order?", "Adding order to base", MessageBoxButton.YesNoCancel);

            if (dialogResult == MessageBoxResult.Yes)
            {
                if (ordersInProgress != null)
                {
                    ordersInProgress.Add(ordersForConsideration[datas.SelectedIndex]);
                }
                WindowForClient.AddToDatabase(ordersForConsideration[datas.SelectedIndex], workBook.Sheets[2]);
                SetGridOrders(ref progressGid, workBook.Sheets[2], (SelectedCellsChangedEventHandler)ActionWithOrderInProgress, ref ordersInProgress);
                RemoveOrderAt(datas.SelectedIndex, workBook.Sheets[1]);
            }
            else if (dialogResult == MessageBoxResult.No)
            {
                RemoveOrderAt(datas.SelectedIndex, workBook.Sheets[1]);
            }
            workBook.Save();
        }
        private void ActionWithOrderInProgress(object sender, SelectedCellsChangedEventArgs e)
        {
            var datas = (DataGrid)sender;

            if (datas.SelectedCells.Count == 0)
            {
                return;
            }
            var dialogResult = MessageBox.Show("Are you complete order?", "Compliting order", MessageBoxButton.YesNo);

            if (dialogResult == MessageBoxResult.Yes)
            {
                MessageBox.Show("Call to : " + ordersInProgress[datas.SelectedIndex].Client);
                WindowForClient.AddToDatabase(ordersInProgress[datas.SelectedIndex], workBook.Sheets[3]);
                RemoveOrderAt(datas.SelectedIndex, workBook.Sheets[2]);
            }
            datas.UnselectAll();
            workBook.Save();
        }
Esempio n. 3
0
        private void CheckAndLogin(string login, string password)
        {
            if (login == "" || password == "")
            {
                MessageBox.Show("Wrong login or password");
                return;
            }
            var directory  = Directory.GetCurrentDirectory() + @"\Logins.txt";
            var reader     = new StreamReader(directory);
            var dataOfUser = "";

            while (true)
            {
                dataOfUser = reader.ReadLine();
                if (dataOfUser is null)
                {
                    break;
                }
                var bytes = dataOfUser.Split(' ').Select(n => byte.Parse(n));
                var datas = Encoding.ASCII.GetString(bytes.ToArray()).Split(' ');
                if (datas[0].Equals(login))
                {
                    if (!int.Parse(datas[1]).Equals(password.GetHashCode()))
                    {
                        continue;
                    }
                    Window window;
                    if (datas.Last() == "client")
                    {
                        window = new WindowForClient(new Client(datas));
                    }
                    else
                    {
                        window = new WindowForMechanic();
                    }
                    window.Show();
                    Close();
                    return;
                }
            }
            MessageBox.Show("Wrong login or password");
            return;
        }