예제 #1
0
 private void UserContrElems_Load(object sender, EventArgs e)
 {
     temp = TempOutcomesModel.SelectAll();
     ShowComboBox();
     ShowPriceTime();
     ShowTempOutcomes();
     buttonTimeCount.Visible      = false;
     buttonTimerCountStop.Visible = false;
     labelTimerCount.Visible      = false;
     labelTimeName.Visible        = false;
     textBoxTime.Visible          = false;
     buttonTimerCountStop.Enabled = false;
     buttonTimeCount.Enabled      = false;
 }
예제 #2
0
        private int InsertOutcomes()
        {
            temp = TempOutcomesModel.SelectAll();
            int count  = temp.Count;
            int lastId = -1;

            for (int i = 1; i <= count; i++)
            {
                string query = "INSERT INTO Outcomes(RoomId, NameGoods, PriceGoods, AmountGoods, DateOrder) VALUES((SELECT Name FROM Rooms WHERE Id=@roomId),  (SELECT Name FROM TempOutcomes WHERE RoomName IN (SELECT Name FROM Rooms WHERE Id=@roomId) AND Id=@id), (SELECT Price FROM TempOutcomes WHERE RoomName IN (SELECT Name FROM Rooms WHERE Id=@roomId) AND Id=@id), (SELECT Amount FROM TempOutcomes WHERE RoomName IN (SELECT Name FROM Rooms WHERE Id=@roomId) AND Id=@id), @dateOrder)";
                var    hour  = DateTime.Now.Hour;
                var    day   = DateTime.Now.Day;
                var    month = DateTime.Now.Month;
                var    year  = DateTime.Now.Year;
                if (hour >= 9 && hour <= 23)
                {
                    var date = new DateTime(year, month, day, hour, dateTimePicker1.Value.Minute, dateTimePicker1.Value.Second);
                    dateTimePicker1.Value = date;
                }
                else if (hour >= 0 && hour <= 6)
                {
                    var date = new DateTime(year, month, day - 1, hour, dateTimePicker1.Value.Minute, dateTimePicker1.Value.Second);
                    dateTimePicker1.Value = date;
                }
                else
                {
                    MessageBox.Show("Работа завершена");
                }
                try
                {
                    connection.Open();
                    command = new SQLiteCommand(query, connection);
                    command.Parameters.AddWithValue("Id", i);
                    command.Parameters.AddWithValue("@roomId", RoomId);
                    command.Parameters.AddWithValue("@dateOrder", dateTimePicker1.Value.ToString("dd-MM-yyyy HH:mm"));
                    int rowInserted = command.ExecuteNonQuery();
                    if (rowInserted > 0)
                    {
                        command.CommandText = "select last_insert_rowid()";
                        lastId = Convert.ToInt32(command.ExecuteScalar());
                    }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
                finally { connection.Close(); }
            }
            return(lastId);
        }
예제 #3
0
 private void buttonUpdate_Click(object sender, EventArgs e)
 {
     temp = TempOutcomesModel.SelectAll();
     if (temp.Count != 0)
     {
         var index = dataGridViewTempOutcomes.CurrentRow.Index;
         UpdateTempOutcomesForm update = new UpdateTempOutcomesForm();
         update.temp = temp[index];
         update.Id   = comboBoxNameGoods.SelectedIndex + 1;
         update.ShowDialog();
         TotalSum -= update.Total;
         ShowTempOutcomes();
         Show();
     }
     else
     {
         MessageBox.Show("Заказ пустой");
     }
 }
예제 #4
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     temp  = TempOutcomesModel.SelectAll();
     store = StoreModel.SelectAll();
     if (temp.Count != 0)
     {
         storeModel = new StoreModel();
         var          index  = dataGridViewTempOutcomes.CurrentRow.Index;
         int          Id     = temp[index].Id;
         DialogResult result = MessageBox.Show("Отменить Заказ?", "Отмена заказа", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             int storeId = comboBoxGoods.SelectedIndex + 1;
             storeModel.Id     = storeId;
             storeModel.Name   = temp[index].Name;
             storeModel.Price  = temp[index].Price;
             storeModel.Amount = temp[index].Amount;
             TotalSum         -= storeModel.Price * storeModel.Amount;
             bool isReset = StoreModel.ResetGoodsForName(storeModel);
             if (isReset)
             {
                 bool isDelete = TempOutcomesModel.Delete(Id);
                 if (isDelete)
                 {
                     ShowTempOutcomes();
                 }
                 else
                 {
                     MessageBox.Show("Ошибка при удаление");
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("Заказ пустой");
     }
 }
예제 #5
0
 private void UserControlBarTable_Load(object sender, EventArgs e)
 {
     temp = TempOutcomesModel.SelectAll();
     ShowStore();
     ShowTempOutcomes();
 }