Exemplo n.º 1
0
 public addEquipmentForm(cEquipment equipment)
 {
     InitializeComponent();
     initType();
     currentEquip = equipment;
     iniEquipment();
 }
Exemplo n.º 2
0
        private void editEquipmentButton_Click(object sender, EventArgs e)
        {
            cEquipment       currentEquioment = new cEquipment((equipmentDGV.Rows[equipmentDGV.SelectedCells[0].RowIndex].DataBoundItem as cEquipment).id_equipment);
            addEquipmentForm AEF = new addEquipmentForm(currentEquioment);

            AEF.Owner = this;
            AEF.ShowDialog();
            viewEquipment();
        }
Exemplo n.º 3
0
 private void delEquipmentButton_Click(object sender, EventArgs e)
 {
     if (equipmentDGV.SelectedCells.Count > 0)
     {
         currentEquip = equipmentDGV.Rows[equipmentDGV.SelectedCells[0].RowIndex].DataBoundItem as cEquipment;
         currentEquip.delInContract(currentHire.equipment_in_contract);
         currentEquip.addStock();
         IsSaved = false;
         viewEquipmentContract(currentClient.id_client);
     }
 }
Exemplo n.º 4
0
 private void delEquipment_Click(object sender, EventArgs e)
 {
     if (equipmentDGV.SelectedCells.Count > 0)
     {
         cEquipment   currentEquioment = new cEquipment((equipmentDGV.Rows[equipmentDGV.SelectedCells[0].RowIndex].DataBoundItem as cEquipment).id_equipment);
         DialogResult result           = MessageBox.Show("Вы действительно хотите удалить это?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             currentEquioment.delete();
             viewEquipment();
         }
     }
 }
Exemplo n.º 5
0
 private void chooseEquipButton_Click(object sender, EventArgs e)
 {
     if (equipmentDGV.SelectedCells.Count > 0)
     {
         currentEquip = equipmentDGV.Rows[equipmentDGV.SelectedCells[0].RowIndex].DataBoundItem as cEquipment;
         if (currentEquip.addToContract(currentEquiomentInContract))
         {
             winterRentalForm frm = (winterRentalForm)this.Owner;
             frm.viewEquipmentContract(frm.currentClient.id_client);
             frm.IsSaved = false;
         }
     }
     viewEquipments();
 }
Exemplo n.º 6
0
        public void getEquipmentList(string searchByAllFields = "", int inStock = -2, int type = 0)
        {
            db db;
            SQLiteDataReader dbRdr;
            cEquipment       e;

            equipments.Clear();
            string        query  = "SELECT * FROM equipments ";
            List <string> wheres = new List <string>();

            if (searchByAllFields != "")
            {
                wheres.Add(String.Format("(brand || model || color || size || number) like '%{0}%'", searchByAllFields));
            }
            if (inStock != -2)
            {
                wheres.Add(String.Format("in_stock >= '{0}'", inStock));
            }
            if (type != 0)
            {
                wheres.Add(String.Format("type = '{0}'", type));
            }
            if (wheres.Count > 0)
            {
                query += "WHERE " + string.Join(" AND ", wheres.ToArray());
            }
            db = new db();
            try
            {
                if (!db.dbOpen())
                {
                    throw new Exception("Ошибка подключения к БД.");
                }
                dbRdr = db.getReader(query);
                while (dbRdr.Read())
                {
                    e = new cEquipment();
                    e.setEquipment(dbRdr);
                    equipments.Add(e);
                }
                dbRdr.Close();
                db.dbClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка чтения из базы данных: " + ex.Message, "Ошибка базы данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally { db.dbClose(); }
        }
Exemplo n.º 7
0
        private void winterRental_FormClosing(object sender, FormClosingEventArgs e)
        {
            //При закрыт формы
            if (!IsSaved && equipmentDGV.Rows.Count > 0)
            {
                foreach (DataGridViewRow i in equipmentDGV.Rows)
                {
                    currentEquip = i.DataBoundItem as cEquipment;
                    currentEquip.addStock();
                }
                currentHire.delete();
            }

            if (equipmentDGV.Rows.Count == 0)
            {
                currentHire.delete();
            }
        }
Exemplo n.º 8
0
        public List <cEquipment> getEquipment()
        {
            List <cEquipment> equipList = new List <cEquipment>();
            db db;
            SQLiteDataReader dbRdr;
            cEquipment       equip;

            equipList.Clear();
            string query = "SELECT * FROM equipments ";

            query += "INNER JOIN equioments_in_contract ON equipments.id_equipment = equioments_in_contract.id_equipment ";
            query += String.Format("WHERE equioments_in_contract.equioment_in_contract = {0} ", equipment_in_contract);
            db     = new db();
            try
            {
                if (!db.dbOpen())
                {
                    throw new Exception("Ошибка подключения к БД.");
                }
                dbRdr = db.getReader(query);
                while (dbRdr.Read())
                {
                    equip = new cEquipment();
                    equip.setEquipment(dbRdr);
                    equipList.Add(equip);
                }
                dbRdr.Close();
                db.dbClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка чтения из базы данных: " + ex.Message, "Ошибка базы данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally { db.dbClose(); }


            return(equipList);
        }