Example #1
0
        public int AddVist(Vist vist)
        {
            int result = -1;

            using (sQLiteConnection)
            {
                OpenConnection();
                using (SQLiteCommand cmd = new SQLiteCommand(sQLiteConnection))
                {
                    cmd.CommandText = "INSERT INTO TA_Vists(Name, Price, Date, Emplyees, Notes, Vist_Id, Hotel_Id) VALUES (@name, @price, @date, @emp, @not, @vistId, @hotilId)";
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@name", vist.Name);
                    cmd.Parameters.AddWithValue("@price", vist.Price);
                    cmd.Parameters.AddWithValue("@date", vist.Date);
                    cmd.Parameters.AddWithValue("@not", vist.Notes);
                    cmd.Parameters.AddWithValue("@emp", vist.Emplyees);
                    cmd.Parameters.AddWithValue("@vistId", vist.Vist_Id);
                    cmd.Parameters.AddWithValue("@hotilId", vist.Hotel_Id);
                    try
                    {
                        result = cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException e)
                    {
                    }
                }
                CloseConnection();
            }
            return(result);
        }
Example #2
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (comboBoxHotelName.SelectedIndex == -1)
            {
                MessageBox.Show("يجب اختيار فندق");
                return;
            }
            VistsData vistsData = new VistsData();

            Hotel ht = hotelsList[comboBoxHotelName.SelectedIndex];

            int.TryParse(textBoxPrice.Text, out int price);

            Vist vist = new Vist()
            {
                Name     = ht.Name,
                Hotel_Id = ht.Id,
                Date     = pickerVistDate.SelectedDate ?? DateTime.Now,
                Price    = price,
                Emplyees = empsIds,
                Vist_Id  = "0",
                Notes    = textBoxNotes.Text
            };

            vistsData.AddVist(vist);

            MessageBox.Show("تم الحفظ");
        }
Example #3
0
        public List <Vist> GetAllVists()
        {
            List <Vist> data = new List <Vist>();

            try
            {
                using (SQLiteConnection conn = new SQLiteConnection(sQLiteConnection))
                {
                    conn.Open();
                    string sql = "SELECT * FROM TA_Vists ";

                    using (SQLiteCommand cmd = new SQLiteCommand(sql, conn))
                    {
                        using (SQLiteDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Vist vist = new Vist();
                                vist.Name  = reader["Name"].ToString();
                                vist.Price = float.Parse(reader["Price"].ToString());
                                vist.Notes = reader["Notes"].ToString();
                                DateTime.TryParse(reader["Date"].ToString(), out DateTime date_);
                                vist.Date     = date_;
                                vist.Id       = Convert.ToInt32(reader["Id"]);
                                vist.Hotel_Id = Convert.ToInt32(reader["Hotel_Id"]);
                                vist.Emplyees = reader["Emplyees"].ToString();
                                data.Add(vist);
                            }
                        }
                    }
                    conn.Close();
                }
            }
            catch (SQLiteException e)
            {
            }
            return(data);
        }
Example #4
0
        private void VistsGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (e.AddedCells.Count > 0)
            {
                if (e.AddedCells[0].Column.Header.ToString() == "Delete")
                {
                    Vist vist = e.AddedCells[0].Item as Vist;
                    if (MessageBox.Show($" حذف {vist.Name}", "تأكيد الحذف", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.OK)
                        == MessageBoxResult.OK)
                    {
                        Vists.Remove(vist);
                        CalcTotal(Vists);
                        MessageBox.Show($" تم حذف {vist.Name}");

                        VistsGrid.ItemsSource = null;
                        VistsGrid.ItemsSource = Vists;
                        VistsGrid.Items.Refresh();

                        data.Delete(vist.Id, "TA_Vists");
                    }
                }
            }
        }