private void additembutton_Click(object sender, EventArgs e)
 {
     if (reservationId == 0)
     {
         MessageBox.Show("Please check available date");
     }
     else
     {
         if (itemnametextBox.Text.Length == 0 || itemunitpricetextBox.Text.Length == 0)
         {
             MessageBox.Show("Please check input field");
         }
         else
         {
             ReservationIteminformation aIteminformation = new ReservationIteminformation();
             aIteminformation.ItemName = itemnametextBox.Text;
             aIteminformation.UnitPrice = Convert.ToDouble(itemunitpricetextBox.Text);
             string sr = aPartyReservationDao.InsertUtilityItemInformation(aIteminformation, reservationId);
             MessageBox.Show(sr);
             if (sr == "ItemInsertSucessfully")
             {
                 itemnametextBox.Text = "";
                 itemunitpricetextBox.Text = "";
             }
             LoadItemInformation();
         }
     }
 }
Exemple #2
0
        public string InsertUtilityItemInformation(ReservationIteminformation aIteminformation, int reservationId)
        {
            string result = "";
            try
            {
                this.OpenConnection();
                string sqlCommand = string.Format(SqlQueries.GetQuery(Query.InsertUtilityItemInformation), aIteminformation.ItemName, aIteminformation.UnitPrice,
                    reservationId);
                this.ExecuteNonQuery(sqlCommand);
                result = "ItemInsertSucessfully";

            }
            catch (Exception ex)
            {
                result = "Couldn't save sucessfully";
            }
            finally
            {
                this.CloseConnection();
            }

            return result;
        }
Exemple #3
0
        private ReservationIteminformation ReaderToUtility(IDataReader oReader)
        {
            ReservationIteminformation aIteminformation = new ReservationIteminformation();
            try
            {
                aIteminformation.ItemName = oReader["itemname"].ToString();
            }
            catch (Exception)
            {
            }
            try
            {
                aIteminformation.ItemId = Convert.ToInt32(oReader["itemid"]);
            }
            catch (Exception)
            {
            }

            try
            {
                aIteminformation.TotalPrice = Convert.ToDouble(oReader["price"]);
            }
            catch (Exception)
            {
            }
            aIteminformation.Delete = "Delete";

            return aIteminformation;
        }
Exemple #4
0
        public List<ReservationIteminformation> GetUtilityIteminformationByreservationId(int reservationId)
        {
            List<ReservationIteminformation> aIteminformations = new List<ReservationIteminformation>();
            try
            {
                this.OpenConnection();
                string sqlCommand = string.Format(SqlQueries.GetQuery(Query.GetUtilityIteminformationByreservationId), reservationId);
                IDataReader oReader = this.ExecuteReader(sqlCommand);
                if (oReader != null)
                {
                    while (oReader.Read())
                    {
                        ReservationIteminformation aIteminformation = new ReservationIteminformation();
                        aIteminformation = ReaderToUtility(oReader);
                        aIteminformations.Add(aIteminformation);
                    }
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                this.CloseConnection();
            }
            return aIteminformations;
        }