Ejemplo n.º 1
0
        public List <BookingTranLayer> GetBookings()
        {
            List <BookingTranLayer> allBookings = new List <BookingTranLayer>();

            cmSelectAll.Connection  = cn;
            cmSelectAll.CommandText = "Select facilityid,slotid,customerid,issuedate from BookingTran where Status = 1";//show only booked transactions and not cancelled transactions
            cn.Open();
            rd = cmSelectAll.ExecuteReader();

            while (rd.Read())
            {
                BookingTranLayer bookingTrans = new BookingTranLayer();
                //find the customer name through id
                bookingTrans.CustomerID = Convert.ToInt32(rd["CustomerID"].ToString());
                //CustomerBook c = new CustomerBook();
                //c.GetCustomer(bookingTrans.CustomerID);
                bookingTrans.FacilityId = rd["FacilityId"].ToString();
                bookingTrans.Issuedate  = Convert.ToDateTime(rd["IssueDate"].ToString());
                bookingTrans.SlotID     = rd["SlotId"].ToString();

                allBookings.Add(bookingTrans);
            }

            return(allBookings);
        }
        //do the validation method of the usecase
        //string errMessage = "";
        //do try - catch

        //public void BookedToCustomer(CustomerBook cb,FacilityBooking fb,SlotBooking sb,BookingTranLayer bt)
        public void BookedToCustomer(BookingTranLayer bt)
        {
            bt.Status = true;

            using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
            {
                BookingTranBroker bookingbroker = new BookingTranBroker();
                bookingbroker.Insert(bt);
                ts.Complete();
            }
        }
Ejemplo n.º 3
0
        public void Insert(BookingTranLayer bt)
        {
            SqlParameter pFacilityId = new SqlParameter("@FacilityId", SqlDbType.NVarChar, 5);
            SqlParameter pSlotId     = new SqlParameter("@SlotId", SqlDbType.NVarChar, 5);
            SqlParameter pCustomerId = new SqlParameter("@CustomerId", SqlDbType.Int);
            SqlParameter pIssueDate  = new SqlParameter("@IssueDate", SqlDbType.DateTime);
            SqlParameter pStatus     = new SqlParameter("@Status", SqlDbType.Bit);

            cmInsert.Parameters.AddRange(new SqlParameter[] { pFacilityId, pSlotId, pCustomerId, pIssueDate, pStatus });
            //cmInsert.Parameters.AddRange(new SqlParameter[] { pFacilityId, pSlotId, pCustomerId, pIssueDate });

            pFacilityId.Value = bt.FacilityId;
            pSlotId.Value     = bt.SlotID;
            pCustomerId.Value = bt.CustomerID;
            pIssueDate.Value  = bt.Issuedate;
            pStatus.Value     = bt.Status;

            cn.Open();
            cmInsert.ExecuteNonQuery();
            cn.Close();
        }
Ejemplo n.º 4
0
        public List <BookingTranLayer> GetSearchBookings(string facId, int cusID, DateTime idate)
        {
            List <BookingTranLayer> SearchBookingsList = new List <BookingTranLayer>();

            cmSelectSearch.Connection = cn;


            SqlParameter pFacId1 = new SqlParameter("@FacId1", SqlDbType.NVarChar, 5);
            //SqlParameter pSlotId = new SqlParameter("@SlotId", SqlDbType.NVarChar, 5);
            SqlParameter pCusId1   = new SqlParameter("@CustId1", SqlDbType.Int);
            SqlParameter pIssDate1 = new SqlParameter("@IssDate1", SqlDbType.DateTime);

            //SqlParameter pStatus = new SqlParameter("@Status", SqlDbType.Bit);

            cmSelectSearch.Parameters.AddRange(new SqlParameter[] { pFacId1, pCusId1, pIssDate1 });

            pFacId1.Value   = facId;
            pCusId1.Value   = cusID;
            pIssDate1.Value = idate;

            cmSelectSearch.CommandText = "Select facilityid,slotid,customerid,issuedate from BookingTran where Status = 1 and customerid = @CustId1 and facilityid = @Facid1 and issuedate = @IssDate1";//show only booked transactions and not cancelled transactions
            cn.Open();
            rd = cmSelectSearch.ExecuteReader();

            while (rd.Read())
            {
                BookingTranLayer bookingTrans = new BookingTranLayer();
                bookingTrans.CustomerID = Convert.ToInt32(rd["CustomerID"].ToString());
                bookingTrans.FacilityId = rd["FacilityId"].ToString();
                bookingTrans.Issuedate  = Convert.ToDateTime(rd["IssueDate"].ToString());
                bookingTrans.SlotID     = rd["SlotId"].ToString();

                SearchBookingsList.Add(bookingTrans);
            }

            return(SearchBookingsList);
        }