Exemple #1
0
        private TripDetailCollection GetItemCollection()
        {
            TripDetailCollection tripDetailCollection = new TripDetailCollection();

            if (NewEditExit.BtnNewText == "&Save")
            {
                for (int i = 1; i <= totalseat; i++)
                {
                    TripDetailInfo tripDetailInfo = new TripDetailInfo();

                    tripDetailInfo.TripDetailID = string.Empty;
                    tripDetailInfo.TripID       = string.Empty;
                    if (i < 10)
                    {
                        tripDetailInfo.SeatNo = "0" + i.ToString();
                        tripDetailInfo.Status = "A";
                    }
                    else
                    {
                        tripDetailInfo.SeatNo = i.ToString();
                        tripDetailInfo.Status = "A";
                    }
                    tripDetailCollection.Add(tripDetailInfo);
                }
            }

            else if (NewEditExit.BtnNewText == "&Update")
            {
                for (int i = 1; i <= totalseat; i++)
                {
                    TripDetailInfo tripDetailInfo = new TripDetailInfo();

                    tripDetailInfo.TripDetailID = string.Empty;
                    tripDetailInfo.TripID       = recordID;
                    if (i < 10)
                    {
                        tripDetailInfo.SeatNo = "0" + i.ToString();
                        tripDetailInfo.Status = "A";
                    }
                    else
                    {
                        tripDetailInfo.SeatNo = i.ToString();
                        tripDetailInfo.Status = "A";
                    }
                    tripDetailCollection.Add(tripDetailInfo);
                }
            }
            return(tripDetailCollection);
        }
        private void BindAvailableSeat()
        {
            TripInfo             tripInfo   = new TripInfo();
            TripDetailController controller = new TripDetailController();
            TripDetailCollection collection = controller.SelectDetailByTripID(lblTripID.Text);

            int a = 0;

            for (int i = 0; i < collection.Count; i++)
            {
                if (collection[i].Status == "A")
                {
                    a++;
                }
            }
            txtAvailableSeats.Text = Convert.ToString(a);
        }
Exemple #3
0
        public TripDetailCollection SelectDetailByTripID(string tripID)
        {
            TripInfo             tripInfo   = new TripInfo();
            string               TripID     = Convert.ToString(tripInfo.TripID);
            IDataReader          Reader     = DataAccess.SelectDetailByTripID(tripID);
            TripDetailCollection collection = new TripDetailCollection();

            while (Reader.Read())
            {
                TripDetailInfo tripDeatilInfo = new TripDetailInfo();
                tripDeatilInfo.TripID = TripID;
                tripDeatilInfo.SeatNo = Convert.ToString(Reader["SeatNo"]);
                tripDeatilInfo.Status = Convert.ToString(Reader["Status"]);
                collection.Add(tripDeatilInfo);
            }
            Reader.Close();
            return(collection);
        }
        public void Insert(TripInfo tripInfo, TripDetailCollection tripDetailCollection)
        {
            try
            {
                DataControlBaseDataAccess.StartTransaction();

                string TripID = DataAccess.Insert(tripInfo.TripID, tripInfo.TripCode, tripInfo.TripDate, tripInfo.TimeID, tripInfo.RouteID, tripInfo.Driver1ID, tripInfo.Driver2ID, tripInfo.BusID, tripInfo.Price);

                foreach (TripDetailInfo tripDetailInfo in tripDetailCollection)
                {
                    TripDetailDataAccess.InsertDetail(tripDetailInfo.TripDetailID, TripID, tripDetailInfo.SeatNo, tripDetailInfo.Status);
                }
                DataControlBaseDataAccess.CommitTransaction();
            }
            catch (Exception ex)
            {
                DataControlBaseDataAccess.RollBackTransaction();
                throw ex;
            }
        }
Exemple #5
0
        public void BindSeat()
        {
            TripInfo             tripInfo            = new TripInfo();
            string               TripID              = Convert.ToString(tripInfo.TripID);
            TripDetailController tripDetailContoller = new TripDetailController();
            TripDetailCollection collections         = tripDetailContoller.SelectDetailByTripID(lblGetTripID.Text);

            pnlSeat.Controls.Clear();

            int backSeat       = collections.Count - 5;
            int backSeatNumber = (collections.Count % 2);

            for (int i = 0, x = 0, y = 0; i < collections.Count; i++)
            {
                Label lbl = new Label();

                if (collections[i].Status == "A")
                {
                    if (!string.IsNullOrEmpty(lblSeatSelectList.Text))
                    {
                        string[] arr = lblSeatSelectList.Text.Split(',');
                        string   no  = "";
                        for (int j = 0; j < arr.Length; j++)
                        {
                            no = arr[j];
                            if (no.Contains(collections[i].SeatNo))
                            {
                                lbl.Image = global::BTS.UI.Properties.Resources.sbs4;
                                lbl.Name  = "lbl" + Convert.ToString(i);


                                break;
                            }
                            else
                            {
                                lbl.Image = global::BTS.UI.Properties.Resources.sa1;
                                lbl.Name  = "Xlbl" + Convert.ToString(i);
                            }
                        }
                    }
                    else
                    {
                        lbl.Image = global::BTS.UI.Properties.Resources.sa1;
                        lbl.Name  = "Xlbl" + Convert.ToString(i);
                    }
                }
                else
                {
                    if (collections[i].Status == "S")
                    {
                        lbl.Image = global::BTS.UI.Properties.Resources.ss2;
                    }
                    else
                    {
                        lbl.Image = global::BTS.UI.Properties.Resources.sb3;
                    }
                }


                if (i >= backSeat && backSeatNumber != 0)
                {
                    lbl.Location    = new System.Drawing.Point(x, (41 * y));
                    lbl.AutoSize    = false;
                    lbl.BorderStyle = System.Windows.Forms.BorderStyle.None;
                    lbl.Size        = new System.Drawing.Size(40, 40);
                    lbl.Text        = Convert.ToString(Convert.ToInt32(i + 1));
                    lbl.Name        = "Xlbl" + Convert.ToString(i);
                    lbl.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
                    lbl.TabIndex    = 1;
                    lbl.TabStop     = false;
                    if (collections[i].Status == "A")
                    {
                        lbl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lblSeat_MouseClick);
                    }
                    pnlSeat.Controls.Add(lbl);
                    y++;

                    if (y == 5)
                    {
                        y = 0;
                        x = x + 45;
                    }
                }
                else
                {
                    if (y == 2 || y == 3 || y == 4)
                    {
                        lbl.Location = new System.Drawing.Point(x, (46 * y) + 25);
                    }
                    else
                    {
                        lbl.Location = new System.Drawing.Point(x, (46 * y));
                    }
                    lbl.AutoSize    = false;
                    lbl.BorderStyle = System.Windows.Forms.BorderStyle.None;
                    lbl.Size        = new System.Drawing.Size(40, 40);
                    if (i < 9)
                    {
                        lbl.Text = "0" + Convert.ToString(Convert.ToInt32(i + 1));
                    }
                    else
                    {
                        lbl.Text = Convert.ToString(Convert.ToInt32(i + 1));
                    }

                    lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                    lbl.TabIndex  = 1;
                    lbl.TabStop   = false;
                    if (collections[i].Status == "A")
                    {
                        lbl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lblSeat_MouseClick);
                    }
                    pnlSeat.Controls.Add(lbl);
                    y++;

                    if (y == 4)
                    {
                        y = 0;
                        x = x + 45;
                    }
                }
            }
        }
Exemple #6
0
        private void NewEditExit_NewClick(object sender, EventArgs e)
        {
            try
            {
                switch (NewEditExit.BtnNewText)
                {
                case "&New":
                    this.EnableDisableControls(true);
                    this.VisibleControls(false);
                    this.BindComboBox(false);
                    this.InitializeControls();
                    this.txtTripCode.Focus();
                    break;

                case "&Save":
                    if (this.CheckRequiredFields())
                    {
                        TripController       tripController       = new TripController();
                        TripInfo             tripInfo             = new TripInfo();
                        TripDetailCollection tripDetailCollection = new TripDetailCollection();

                        GetHeaderInfo(tripInfo);
                        tripDetailCollection = GetItemCollection();

                        tripController.Insert(tripInfo, tripDetailCollection);

                        string log = "Form-TripPlan;Item-TripCode:" + this.txtTripCode.Text + ";action-Save";
                        userAction.Log(log);

                        Globalizer.ShowMessage(MessageType.Information, "Saved Successfully");
                        this.ResetControl();
                    }
                    break;

                case "&Update":
                    if (this.CheckRequiredFields())
                    {
                        TripController       tripController       = new TripController();
                        TripInfo             tripInfo             = new TripInfo();
                        TripDetailCollection tripDetailCollection = new TripDetailCollection();

                        recordID = this.cboTripCode.SelectedValue.ToString();
                        GetHeaderInfo(tripInfo);
                        tripDetailCollection = GetItemCollection();

                        tripController.UpdateByTripID(tripInfo, tripDetailCollection);

                        string log = "Form-TripPlan;Item-TripCode:" + this.cboTripCode.Text + ";action-Update";
                        userAction.Log(log);

                        Globalizer.ShowMessage(MessageType.Information, "Updated Successfully");
                        this.ResetControl();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Globalizer.ShowMessage(MessageType.Critical, ex.Message);
            }
        }