Пример #1
0
        /// <summary>
        /// This takes control of the input of new wares
        /// </summary>
        /// <param name="wares">Input a wares object</param>
        /// <returns>output a bool</returns>
        public bool NewWares(Wares ware1)
        {
            bool wareMade = false;

            Wares        ware   = new Wares();
            List <Wares> wares  = new List <Wares>();
            int          lastid = dBa.GetLastId("Wares");

            ware1.waresID = lastid < 0 ? 1 : lastid + 1;

            /// <summary>
            /// Stored procedure InsertWare with parameters  @wareName varchar(255), @volume float, @volumeType int
            /// </summary>
            if (dBa.NewOrUpdateDB("CALL InsertWare (Name = '" + ware1.wareName + "', Volume = ' " + ware1.volume + "' , VolumeType = '" + ware1.volumeType + "');") &&

                /// <summary>
                /// Stored procedure InsertBoughtWare with parameters  @boughtprice float, @volume int, @volumeType int, @waresID int
                /// </summary>
                dBa.NewOrUpdateDB("CALL InsertBoughtWare (Boughtprice = '" + ware1.buyPrice + "', Volume = ' " + ware1.volume + "' , VolumeType = '"
                                  + ware1.volumeTypeID + "', WaresID = '" + ware1.waresID + "',BoughtDate = '" + "" + "');"))
            {
                wareMade = true;
            }

            return(wareMade);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="ware"></param>
        /// <returns></returns>
        public bool updateWares(int id, Wares ware)
        {
            bool updated = false;
            int  volume  = dBa.GetWareVolume(id);

            /// <summary>
            /// Stored procedure UpdateWare with parameters @id int, @volume int
            /// </summary>
            volume = volume + ware.volume;
            if (dBa.NewOrUpdateDB("CALL UpdateWare (Id = '" + id + "', Volume = '" + volume + "');"))
            {
                updated = true;
            }

            return(updated);
        }
Пример #3
0
 /// <summary>
 /// Method to insert new wares than already exists in the database
 /// </summary>
 /// <param name="ware"></param>
 /// <returns></returns>
 public bool NewBoughtWare(Wares ware)
 {
     /// <summary>
     /// Stored procedure InsertBoughtWare with parameters  @boughtprice float, @volume int, @volumeType int, @waresID int
     /// </summary>
     try
     {
         if (dBa.NewOrUpdateDB("CALL InsertBoughtWare (Boughtprice = '" + ware.buyPrice + "', Volume = ' " + ware.volume + "' , VolumeType = '"
                               + ware.volumeTypeID + "', WaresID = '" + ware.waresID + "',BoughtDate = '" + "" + "');"))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch { return(false); throw new ArgumentException("Insert bought ware failed", "original"); }
 }