Esempio n. 1
0
        public bool delInContract(int equipment_in_contract)
        {
            db db = new db();
            SQLiteDataReader dbRdr;

            if (!db.dbOpen())
            {
                return(false);
            }
            List <int> id_equip_in_contr = new List <int>();

            dbRdr = db.getReader(String.Format("SELECT id_equioment_in_contract FROM equioments_in_contract WHERE  id_equipment = {0} AND equioment_in_contract = {1};", id_equipment, equipment_in_contract));
            while (dbRdr.Read())
            {
                int id_equioment_in_contract = Convert.ToInt32(dbRdr["id_equioment_in_contract"]);
                id_equip_in_contr.Add(id_equioment_in_contract);
            }
            dbRdr.Close();
            string query = String.Format("DELETE FROM equioments_in_contract WHERE id_equipment = {0} AND equioment_in_contract = {1} AND id_equioment_in_contract = {2}; ", id_equipment, equipment_in_contract, id_equip_in_contr[0]);

            if (!db.executeParamQuery(query,
                                      new DictionaryEntry("@in_stock", in_stock + 1)
                                      ))
            {
                db.dbClose(); return(false);
            }
            db.dbClose();
            return(true);
            // "UPDATE equipments SET in_stock = @in_stock WHERE id_equipment = {0} "
        }
Esempio n. 2
0
        public bool addToContract(int equioment_in_contract)
        {
            db db = new db();

            if (!db.dbOpen())
            {
                return(false);
            }

            string saveQuery = string.Format("INSERT INTO equioments_in_contract(equioment_in_contract, id_equipment) "
                                             + "VALUES (@equioment_in_contract, @id_equipment); UPDATE equipments SET in_stock = @in_stock  WHERE id_equipment = {0}", id_equipment);

            if (!db.executeParamQuery(saveQuery,
                                      new DictionaryEntry("@equioment_in_contract", equioment_in_contract),
                                      new DictionaryEntry("@id_equipment", id_equipment),
                                      new DictionaryEntry("@in_stock", in_stock - 1)
                                      ))
            {
                db.dbClose(); return(false);
            }

            /* if (id_equipment < 0)
             * {
             *   id_equipment = Convert.ToInt32(db.executeScalar("SELECT last_insert_rowid()"));
             * }*/
            db.dbClose();

            return(true);
        }
Esempio n. 3
0
        public bool save()
        {
            db db = new db();

            if (!db.dbOpen())
            {
                return(false);
            }

            string saveQuery = "";

            if (id_equipment < 0)
            {
                saveQuery = getQuery("i");
            }
            else
            {
                saveQuery = getQuery("u");
            }

            if (!db.executeParamQuery(saveQuery,
                                      new DictionaryEntry("@brand", brand),
                                      new DictionaryEntry("@model", model),
                                      new DictionaryEntry("@color", color),
                                      new DictionaryEntry("@size", size),
                                      new DictionaryEntry("@number", number),
                                      new DictionaryEntry("@cost", cost),
                                      new DictionaryEntry("@in_stock", in_stock),
                                      new DictionaryEntry("@type", type)

                                      ))
            {
                db.dbClose(); return(false);
            }
            if (id_equipment < 0)
            {
                id_equipment = Convert.ToInt32(db.executeScalar("SELECT last_insert_rowid()"));
            }
            db.dbClose();

            return(true);
        }
Esempio n. 4
0
        public bool save()
        {
            db db = new db();

            if (!db.dbOpen())
            {
                return(false);
            }

            string saveQuery = "";

            if (id_contract_hire < 0)
            {
                saveQuery = getQuery("i");
            }
            else
            {
                saveQuery = getQuery("u");
            }

            if (!db.executeParamQuery(saveQuery,
                                      new DictionaryEntry("@id_client", id_client),
                                      new DictionaryEntry("@equipment_in_contract", equipment_in_contract),
                                      new DictionaryEntry("@object_of_pledge", object_of_pledge),
                                      new DictionaryEntry("@rent", rent),
                                      new DictionaryEntry("@start_time", start_time),
                                      new DictionaryEntry("@end_time", end_time),
                                      new DictionaryEntry("@returned", returned)
                                      ))
            {
                db.dbClose(); return(false);
            }
            if (id_contract_hire < 0)
            {
                id_contract_hire = Convert.ToInt32(db.executeScalar("SELECT last_insert_rowid()"));
            }
            db.dbClose();

            return(true);
        }
Esempio n. 5
0
        public bool reduceStock()
        {
            db db = new db();

            if (!db.dbOpen())
            {
                return(false);
            }

            string saveQuery = string.Format("UPDATE equipments SET in_stock = @in_stock  WHERE id_equipment = {0}", id_equipment);


            if (!db.executeParamQuery(saveQuery,
                                      new DictionaryEntry("@in_stock", in_stock - 1)
                                      ))
            {
                db.dbClose(); return(false);
            }
            db.dbClose();

            return(true);
        }
Esempio n. 6
0
        public bool save()
        {
            db db = new db();

            if (!db.dbOpen())
            {
                return(false);
            }

            string saveQuery = "";

            if (id_client < 0)
            {
                saveQuery = getQuery("i");
            }
            else
            {
                saveQuery = getQuery("u");
            }

            if (!db.executeParamQuery(saveQuery,
                                      new DictionaryEntry("@fio", fio),
                                      new DictionaryEntry("@phone", phone),
                                      new DictionaryEntry("@address", address),
                                      new DictionaryEntry("@passport", passport)

                                      ))
            {
                db.dbClose(); return(false);
            }
            if (id_client < 0)
            {
                id_client = Convert.ToInt32(db.executeScalar("SELECT last_insert_rowid()"));
            }
            db.dbClose();

            return(true);
        }
Esempio n. 7
0
        public bool addStock()
        {
            db db = new db();

            if (!db.dbOpen())
            {
                return(false);
            }
            in_stock = Convert.ToInt32(db.executeScalar(string.Format("SELECT in_stock FROM equipments WHERE id_equipment = {0}", id_equipment)));

            string saveQuery = string.Format("UPDATE equipments SET in_stock = @in_stock  WHERE id_equipment = {0}", id_equipment);


            if (!db.executeParamQuery(saveQuery,
                                      new DictionaryEntry("@in_stock", in_stock + 1)
                                      ))
            {
                db.dbClose(); return(false);
            }
            db.dbClose();

            return(true);
        }