Exemplo n.º 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                var listTrain = TrainFactory.SearchTrain(txtNumberTrain.Text.Trim(),
                                                         Convert.ToInt32(((ComboBoxItem)ddlTypeName.SelectedItem).Value),
                                                         dtpDateXNC.Value);
                grdTrain.AutoGenerateColumns = false;
                grdTrain.DataSource          = listTrain;


                for (var i = 0; i < grdTrain.Rows.Count; i++)
                {
                    // Add to count Column
                    grdTrain.Rows[i].Cells[0].Value = (i + 1).ToString();
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         var dr = MessageBox.Show("Các toa tàu của đoàn tàu sẽ bị xóa cùng với đoàn tàu. Các toa tàu này có thể liên kết với BBBG và Tờ khai hải quan. Các dữ liệu liên kết này sẽ bị xóa cùng với toa tàu. Bạn có muốn tiếp tục ?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             if (TrainFactory.DeleteChuyenTauByID(_train.TrainID) > 0)
             {
                 MessageBox.Show("Xóa xong");
                 this.DialogResult = DialogResult.OK;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Xóa bị lỗi");
             }
         }
     }
     catch (Exception ex)
     {
         if (GlobalInfo.IsDebug)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
Exemplo n.º 3
0
        private static string GetTrains(string f, string t)
        {
            StringBuilder       sb  = new StringBuilder();
            List <CStationInfo> csl = new List <CStationInfo>();
            List <TrainInfo>    tl  = TrainFactory.GetTrains(f, t, out csl);

            if (tl.Count > 0)
            {
                sb.AppendLine("\t找到 " + tl.Count + " 趟列车");
                sb.AppendLine(string.Format("{0,-8}\t{1,3}\t{2,3}\t{3,3}\t{4,3}\t{5,4}\t{6,4}\t{7,4}", "车次", "始发站", "终点站", "发站", "发时", "到站", "到时", "历时"));
                foreach (TrainInfo ti in tl)
                {
                    sb.AppendLine(string.Format("{0,-10}\t{1,6}\t{2,6}\t{3,6}\t{4,6}\t{5,6}\t{6,6}\t{7,6}", ti.TId, ti.FirstStation.Station, ti.EndStation.Station, ti.StartStation.Station, TrainFactory.TimeSpanToString(ti.StartStation.StartTime, "{1:00}:{2:00}"), ti.EndStation.Station, TrainFactory.TimeSpanToString(ti.EndStation.EndTime, "{1:00}:{2:00}"), TrainFactory.TimeSpanToString(ti.LastTime, "{0:00}:{1:00}", "")));
                }
            }
            else if (csl.Count > 0)
            {
                sb.AppendLine("\t无直达列车,找到中转站 " + csl.Count + " 个");
                sb.AppendLine(string.Format("{0,3}\t{1,5}\t{2,5}\t{3,5}\t{4,4}\t{5,4}", "中转站", "中转前历时", "中转后历时", "总历时", "发车数", "到站车数"));
                foreach (CStationInfo csi in csl)
                {
                    sb.AppendLine(string.Format("{0,3}\t{1,10}\t{2,10}\t{3,10}\t{4,6}\t{5,8}", csi.Station, TrainFactory.TimeSpanToString(csi.BeforeTime, "{0:00}:{1:00}"), TrainFactory.TimeSpanToString(csi.AfterTime, "{0:00}:{1:00}"), TrainFactory.TimeSpanToString(csi.TotalTime, "{0:00}:{1:00}"), csi.BeforeStations, csi.AfterStations));
                }
            }
            else
            {
                return("没找到" + f + "到" + t + "之间的列车!");
            }

            return(sb.ToString());
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {

            Console.WriteLine("Press 1 for car and 2 for Train");
            string choice = Console.ReadLine();
            Factory factory = null;
            switch(choice)
            {
                case "1" :
                    factory = new CarsFactory();
                    break;
                case "2":
                    factory = new TrainFactory();
                    break;
                default:
                    break;
            }

            if (factory == null) return;

            var product = factory.Create();
            product.TotalPassengers();

            Console.ReadKey();
        }
Exemplo n.º 5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         var dr = MessageBox.Show("Bạn có chắc là muốn xóa?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             if (TrainFactory.DeleteHandoverByID(_handover.ID) > 0)
             {
                 MessageBox.Show("Xóa xong");
                 this.DialogResult = DialogResult.OK;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Xóa bị lỗi");
             }
         }
     }
     catch (Exception ex)
     {
         if (GlobalInfo.IsDebug)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            DateTime fromDate = dtpFrom.Value;
            DateTime toDate   = dtpTo.Value;

            List <tblTrain> listTrain = TrainFactory.SearchTrain("", Convert.ToInt16(((ComboBoxItem)ddlTypeName.SelectedItem).Value),
                                                                 true, fromDate, toDate);

            try
            {
                var report  = new ReportPassengerTrain();
                var txtType = (TextObject)report.Section1.ReportObjects["txtType"];
                var txtFrom = (TextObject)report.Section1.ReportObjects["txtFrom"];
                var txtTo   = (TextObject)report.Section1.ReportObjects["txtTo"];
                txtType.Text = ("HÀNH KHÁCH " + ddlTypeName.Text + " BẰNG ĐƯỜNG SẮT").ToUpper();
                txtFrom.Text = txtFrom.Text + " " + dtpFrom.Text;
                txtTo.Text   = txtTo.Text + " " + dtpTo.Text;

                DataSet1  dataset = new DataSet1();
                DataTable dt      = dataset.tblTrain;
                foreach (tblTrain train in listTrain)
                {
                    dt.Rows.Add(train.TrainID, train.Number, train.Type, train.DateImportExport,
                                train.Jounery, train.PassengerVN, train.PassengerForegin, train.Staff,
                                train.CreatedDate, train.CreatedByName, train.ModifiedDate, train.ModifiedByName);
                }
                report.SetDataSource(dataset);
                FrmPreviewReport frmReport = new FrmPreviewReport(report);
                frmReport.MdiParent = this.MdiParent;
                frmReport.Show();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 7
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlCuaKhau.SelectedValue.ToString() == "")
                {
                    MessageBox.Show("Chưa chọn đơn vị hải quan");
                    return;
                }
                var report = new ReportListFeedback();

                var txtReceiver = (TextObject)report.Section1.ReportObjects["txtReceiver"];
                txtReceiver.Text = txtReceiver.Text + CustomsFacory.FindByCode(ddlCuaKhau.SelectedValue.ToString()).CustomsName;

                List <tblHandover> listHandover = TrainFactory.SearchBBBG(txtNumberBBBG.Text.Trim(), cbNgayXNC.Checked, dtpFrom.Value, dtpTo.Value, ddlCuaKhau.SelectedValue.ToString());

                if (listHandover == null || listHandover.Count == 0)
                {
                    MessageBox.Show("Không có dữ liệu thỏa mãn điều kiện tìm kiếm này");
                    return;
                }
                DataSet1  dataset = new DataSet1();
                DataTable dt      = dataset.tblHandover;

                foreach (tblHandover obj in listHandover)
                {
                    dt.Rows.Add(obj.ID,
                                obj.NumberHandover,
                                obj.DateHandover,
                                obj.CodeStation,
                                obj.CodeStationFromTo,
                                obj.StatusGoods,
                                obj.StatusVehicle,
                                obj.CreatedDate,
                                obj.CreatedBy,
                                obj.ModifiedDate,
                                obj.ModifiedBy,
                                obj.NumberReply,
                                obj.DateReply,
                                obj.NoteReply,
                                obj.IsDeleted,
                                obj.IsReplied,
                                obj.Note,
                                obj.Type,
                                obj.ReplyStatusGoods);
                }

                report.SetDataSource(dataset);

                FrmPreviewReport frmReport = new FrmPreviewReport(report);
                frmReport.MdiParent = this.MdiParent;
                frmReport.Show();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var dr = MessageBox.Show(ConstantInfo.CONFIRM_UPDATE, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr != DialogResult.Yes)
            {
                return;
            }

            try
            {
                if (!Validate())
                {
                    return;
                }

                //if (grdToaTau.RowCount == 0)
                //{
                //    MessageBox.Show("Bạn phải chọn ít nhất một toa tàu!");
                //    return;
                //}


                _toKhaiTau.Number          = int.Parse(txtNumberToKhai.Text.Trim());
                _toKhaiTau.DateDeclaration = dtpDeclaration.Value;
                _toKhaiTau.TypeCode        = txtTypeCode.Text.Trim();
                _toKhaiTau.CustomCode      = txtCustomsCode.Text.Trim();
                _toKhaiTau.ModifiedBy      = _userInfo.UserID;
                _toKhaiTau.ModifiedDate    = CommonFactory.GetCurrentDate();


                var result = TrainFactory.UpdateToKhaiTau(_toKhaiTau, _listToaTau);

                if (result > 0)
                {
                    MessageBox.Show(string.Format("Cập nhật Tờ khai {0} thành công!", _type == 0 ? "xuất cảnh" : "nhập cảnh"));
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Cập nhật Tờ khai không thành công!");
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            CarFactory carFactory = new CarFactory();
            var        car        = carFactory.CreateVehicle();

            car.MakeNoise();

            TrainFactory trainFactory = new TrainFactory();
            var          train        = trainFactory.CreateVehicle();

            train.MakeNoise();

            Console.ReadLine();
        }
Exemplo n.º 10
0
 private void btnAddTrain_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var trainFactory = new TrainFactory();
         var newTrain     = trainFactory.CreateTrain(GetNewTrainInfo());
         dataFacade.AddTrain(newTrain);
         dataFacade.SaveTrains();
         MessageBox.Show($"Train {newTrain.ID} added!");
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Exemplo n.º 11
0
        private void grdTrain_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            var handover = TrainFactory.FindHandoverByID(listHandOver[e.RowIndex].ID);

            var frm = new Train.frmBBBG(frmMainForm._userInfo, handover.Type, handover);

            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                search();
            }
        }
Exemplo n.º 12
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            var confirm = MessageBox.Show(ConstantInfo.CONFIRM_UPDATE, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (confirm != DialogResult.Yes)
            {
                return;
            }
            try
            {
                if (!Validate())
                {
                    return;
                }
                var trainPassenger = TrainFactory.FindTrainByID(_tblTrain.TrainID);

                trainPassenger.Number           = txtNumberTrain.Text.Trim();
                trainPassenger.Type             = (short)((ComboBoxItem)ddlTypeName.SelectedItem).Value;
                trainPassenger.DateImportExport = dtpRegisterDate.Value;
                trainPassenger.Jounery          = txtJourney.Text.Trim();
                trainPassenger.PassengerVN      = int.Parse(txtNumberPersonVN.Text);
                trainPassenger.PassengerForegin = int.Parse(txtNumberPersonForegin.Text);
                trainPassenger.Staff            = int.Parse(txtNumberStaff.Text);
                trainPassenger.CreatedBy        = _userInfo.UserID;

                if (TrainFactory.Update(trainPassenger) > 0)
                {
                    MessageBox.Show("Cập nhật thành công!");
                    if (_frmSearch != null)
                    {
                        _frmSearch.search();
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Cập nhật không thành công!");
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 13
0
        //AddBtn_Click: Attempts to add booking details entered to Bookings
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            TrainFactory factory = TrainFactory.Instance();
            Booking      booking;

            //Returns a train which matches the id entered on the form
            try
            {
                //This needs to be done otherwise Find() returns first item in list.
                if (string.IsNullOrEmpty(idTxtBox.Text))
                {
                    throw new ArgumentNullException("ID cannot be empty!");
                }
                Train train = MainWindow.Trains.Find(x => x.TrainID.Contains(idTxtBox.Text));
                if (train == null)
                {
                    throw new ArgumentNullException("Train to book on doesn't exist!");
                }

                booking = factory.CreateBooking(train, nameTxtBox.Text, departCombo.Text, arrivalCombo.Text,
                                                bool.Parse(firstclassCombo.Text), bool.Parse(cabinCombo.Text),
                                                coachCombo.Text[0], (int)seatCombo.SelectedValue);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Failure();
                return;
            }

            BookingDecorator decorator = new BookingDecorator(booking);
            //Opens a message box displaying fare and asking for user's confirmation
            MessageBoxResult result = MessageBox.Show($"Are you sure? The price will be £{decorator.Fare}", "Price Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                Failure();
                TrainFactory.Records[booking.TrainID].RemoveAt(TrainFactory.Records[booking.TrainID].Count - 1);
                return;
            }

            //Actually adds booking to Bookings
            MainWindow.Bookings.Add(booking);
            successTxtBlk.Foreground = Brushes.Green;
            successTxtBlk.Text       = "Success! Booking was added.";
            MessageBox.Show("Added!");
        }
Exemplo n.º 14
0
        private void InitData()
        {
            if (_handover == null)
            {
                return;
            }
            _handover = TrainFactory.FindHandoverByID(_handover.ID);
            txtNumberHandover.Text   = _handover.NumberHandover;
            dtpHandover.Value        = (DateTime)_handover.DateHandover;
            txtCodeCuaKhau.Text      = _handover.CodeStation;
            ddlCuaKhau.SelectedValue = _handover.CodeStation;
            txtCodeGaDenDi.Text      = _handover.CodeStationFromTo;
            ddlGaDenDi.SelectedValue = _handover.CodeStationFromTo;
            txtStatusGood.Text       = _handover.StatusGoods;
            txtStatusVehicle.Text    = _handover.StatusVehicle;
            //txtSoVanDon.Text = _handover.Ma_Chuyen_Tau;
            //txtSoVanDon.ReadOnly = true;
            cbReply.Checked = _handover.IsReplied.Value;
            if (cbReply.Checked)
            {
                dtpReplyDate.Enabled        = true;
                dtpReplyDate.Value          = _handover.DateReply.Value;
                txtReplyNote.Text           = _handover.NoteReply;
                txtReplyNote.Enabled        = true;
                txtReplyStatusGoods.Text    = _handover.ReplyStatusGoods;
                txtReplyStatusGoods.Enabled = true;
            }
            else
            {
                dtpReplyDate.Enabled        = false;
                txtReplyNote.Text           = "";
                txtReplyNote.Enabled        = false;
                txtReplyStatusGoods.Enabled = false;
                txtReplyStatusGoods.Text    = "";
            }

            if (!_handover.tblHandoverResources.IsLoaded)
            {
                _handover.tblHandoverResources.Load();
            }
            foreach (var resource in _handover.tblHandoverResources)
            {
                resource.tblToaTauReference.Load();
                listToaTau.Add(resource.tblToaTau);
            }
            BindToaTau(null);
        }
Exemplo n.º 15
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            var dr = MessageBox.Show(ConstantInfo.CONFIRM_ADD_NEW, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr != DialogResult.Yes)
            {
                return;
            }

            try
            {
                if (!ValidateChuyenTau())
                {
                    return;
                }
                var train = new tblChuyenTau
                {
                    Ma_Chuyen_Tau    = txtNumberTrain.Text.Trim(),
                    Type             = _type,
                    Ngay_XNC         = dtpDateXNC.Value,
                    IsPassengerTrain = false,
                    CreatedDate      = CommonFactory.GetCurrentDate(),
                    CreatedBy        = _userInfo.UserID
                };
                foreach (var toaTau in listToaTau)
                {
                    train.tblToaTaus.Add(toaTau);
                }
                var result = TrainFactory.InsertChuyenTau(train);
                if (result > 0)
                {
                    MessageBox.Show("Thêm mới chuyến tàu thành công!");
                    ResetChuyenTau();
                }
                else
                {
                    MessageBox.Show("Thêm mới chuyến không thành công!");
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 16
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            List <tblToaTau> listToaTau = TrainFactory.searchToaTau(_type, _handoverType, txtSoVanTaiDon.Text.Trim(), cbNgayVT.Checked, dtpFrom.Value, dtpTo.Value);

            grdToaTau.DataSource = listToaTau;
            // Bind count column
            for (var i = 0; i < grdToaTau.Rows.Count; i++)
            {
                // Add to count Column
                grdToaTau.Rows[i].Cells["Count"].Value = (i + 1).ToString();
                var toaTau = (tblToaTau)grdToaTau.Rows[i].DataBoundItem;
                //if (_listToaTau.Any(tau => tau.tblChuyenTau.TrainID == toaTau.tblChuyenTau.TrainID))
                //{
                //    grdToaTau.Rows[i].Cells["CusCheck"].Value = true;
                //}
            }
        }
Exemplo n.º 17
0
        private void Init()
        {
            if (_type == 0)
            {
                //lblDateXNK.Text = "Ngày giờ xuất cảnh";
                grdToaTau.Columns["Ten_DoiTac"].HeaderText      = "Tên người nhận";
                grdToaTau.Columns["Ten_DoanhNghiep"].HeaderText = "Tên người gửi";
            }
            else if (_type == 1)
            {
                //lblDateXNK.Text = "Ngày giờ nhập cảnh";
                grdToaTau.Columns["Ten_DoiTac"].HeaderText      = "Tên người gửi";
                grdToaTau.Columns["Ten_DoanhNghiep"].HeaderText = "Tên người nhận";
            }

            //custumize check box column
            var cusCheckbox = new DataGridViewDisableCheckBoxColumn();

            cusCheckbox.Name  = "CusCheck";
            cusCheckbox.Width = 50;
            var cbCusHeader = new DatagridViewCheckBoxHeaderCell();

            cbCusHeader.OnCheckBoxClicked += new CheckBoxClickedHandler(cbCusHeader_OnCheckBoxClicked);
            cusCheckbox.HeaderCell         = cbCusHeader;
            cusCheckbox.HeaderText         = "";
            grdToaTau.Columns.Insert(0, cusCheckbox);

            //grid Toa tau
            grdToaTau.AutoGenerateColumns = false;
            List <tblToaTau> listToaTau = TrainFactory.searchToaTau(_type, _handoverType, txtSoVanTaiDon.Text.Trim(), cbNgayVT.Checked, dtpFrom.Value, dtpTo.Value);

            grdToaTau.DataSource = listToaTau;

            // Bind count column
            for (var i = 0; i < grdToaTau.Rows.Count; i++)
            {
                // Add to count Column
                grdToaTau.Rows[i].Cells["Count"].Value = (i + 1).ToString();
                var toaTau = (tblToaTau)grdToaTau.Rows[i].DataBoundItem;
                //if (_listToaTau.Any(tau => tau.tblChuyenTau.TrainID == toaTau.tblChuyenTau.TrainID))
                //{
                //    grdToaTau.Rows[i].Cells["CusCheck"].Value = true;
                //}
            }
        }
Exemplo n.º 18
0
        private bool Validate()
        {
            var valid = techlinkErrorProvider1.Validate(this);

            if (_mode == 0) //kiem tra so BBBG trung lap khi nhap moi
            {
                tblHandover exist = TrainFactory.FindHandoverByNumber(txtNumberHandover.Text.Trim());
                if (exist != null)
                {
                    MessageBox.Show("Số BBBG này đã tồn tại, xin nhập số khác");
                    return(false);
                }
                return(valid);
            }
            else
            {
                return(valid);
            }
        }
Exemplo n.º 19
0
 private void InitData()
 {
     if (_train == null)
     {
         return;
     }
     _train = TrainFactory.GetById(_train.TrainID);
     txtNumberTrain.Text = _train.Ma_Chuyen_Tau;
     if (_train.Ngay_XNC != null)
     {
         dtpDateXNC.Value = (DateTime)_train.Ngay_XNC;
     }
     if (!_train.tblToaTaus.IsLoaded)
     {
         _train.tblToaTaus.Load();
     }
     listToaTau = _train.tblToaTaus.ToList();
     BindToaTau();
 }
Exemplo n.º 20
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Validate())
                {
                    return;
                }
                var train = new tblTrain();
                train.Number = txtNumberTrain.Text.Trim();
                train.Type   = (short)((ComboBoxItem)ddlTypeName.SelectedItem).Value;
                if (train.Type == (short)TrainType.TypeExport)
                {
                    train.IsExport   = true;
                    train.DateExport = dtpRegisterDate.Value;
                }
                else if (train.Type == (short)TrainType.TypeImport)
                {
                    train.IsImport   = true;
                    train.DateImport = dtpRegisterDate.Value;
                }
                train.NumberPartTrain = txtNumberPartofTrain.Text.Trim();

                train.CreatedBy = _userInfo.UserID;
                if (TrainFactory.Insert(train) > 0)
                {
                    MessageBox.Show("Thêm mới thành công!");
                    Reset();
                }
                else
                {
                    MessageBox.Show("Thêm mới không thành công!");
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 21
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            var confirm = MessageBox.Show(ConstantInfo.CONFIRM_ADD_NEW, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (confirm != DialogResult.Yes)
            {
                return;
            }

            try
            {
                if (!Validate())
                {
                    return;
                }
                var trainPassenger = new tblTrain();
                trainPassenger.Number           = txtNumberTrain.Text.Trim();
                trainPassenger.Type             = (short)((ComboBoxItem)ddlTypeName.SelectedItem).Value;
                trainPassenger.DateImportExport = dtpRegisterDate.Value;
                trainPassenger.Jounery          = txtJourney.Text.Trim();
                trainPassenger.PassengerVN      = int.Parse(txtNumberPersonVN.Text);
                trainPassenger.PassengerForegin = int.Parse(txtNumberPersonForegin.Text);
                trainPassenger.Staff            = int.Parse(txtNumberStaff.Text);
                trainPassenger.CreatedBy        = _userInfo.UserID;
                if (TrainFactory.Insert(trainPassenger) > 0)
                {
                    MessageBox.Show("Thêm mới thành công!");
                    Reset();
                }
                else
                {
                    MessageBox.Show("Thêm mới không thành công!");
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 22
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.grdTrain.SelectedRows.Count > 0)
                {
                    int selectedIndex = grdTrain.SelectedRows[0].Index;

                    // gets the RowID from the first column in the grid
                    Int64 trainID = Int64.Parse(grdTrain[0, selectedIndex].Value.ToString());

                    tblTrain train = TrainFactory.FindTrainByID(trainID);
                    if (train == null)
                    {
                        MessageBox.Show("Tàu khách này không còn tồn tại trong Cơ Sở Dữ Liệu. Bạn hãy kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    int delete = TrainFactory.Delete(trainID);
                    if (delete > 0)
                    {
                        MessageBox.Show("Xóa thành công");
                        search();
                    }
                    else
                    {
                        MessageBox.Show("Xóa không thành công, xin kiểm tra lại kết nối mạng");
                    }
                }
                else
                {
                    MessageBox.Show("Bạn cần chọn một bản ghi để xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 23
0
        private static string GetTrain(string p)
        {
            StringBuilder sb = new StringBuilder();
            TrainInfo     ti = TrainFactory.GetTrain(p);

            if (ti.FirstStation == null)
            {
                return("没有该趟列车!");
            }
            else
            {
                sb.AppendLine(string.Format("{0,-6}\t{1,4}\t{2,4}\t{3,4}\t{4,8}\t{5,4}\t{6,4}", "车站", "到时", "发时", "天数", "里程(km)", "平均车速", "历时"));
                foreach (StationInfo si in ti.StationList)
                {
                    sb.AppendLine(string.Format("{0,6}\t{1,6}\t{2,6}\t{3,3}\t{4,8}\t{5,8}\t{6,6}", si.Station, TimeSpanToString(si.EndTime), TimeSpanToString(si.StartTime), DayToString(si.StartTime.Days == 30 ? si.EndTime.Days : si.StartTime.Days), si.Km, si.Speed.ToString("F00"), TrainFactory.TimeSpanToString(si.LastTime, "{0:00}:{1:00}", "")));
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 24
0
        private void search()
        {
            try
            {
                String             replyType   = ((ComboBoxItem)cbType.SelectedItem).Value.ToString();
                Nullable <Boolean> replyStatus = null;
                if (((ComboBoxItem)cbReplyStatus.SelectedItem).Value != null)
                {
                    replyStatus = (Boolean)(((ComboBoxItem)cbReplyStatus.SelectedItem).Value);
                }
                List <tblHandover> listHandOver = TrainFactory.SearchBBBG(txtNumberBBBG.Text.Trim(),
                                                                          cbNgayXNC.Checked, dtpFrom.Value, dtpTo.Value, replyStatus, replyType, cbChuaTaoBangKe.Checked);
                foreach (tblHandover handover in listHandOver)
                {
                    if (handover.Type == "0")
                    {
                        handover.Type = "BBBG Đến";
                    }
                    else
                    {
                        handover.Type = "BBBG Đi";
                    }
                }

                grdHandover.AutoGenerateColumns = false;
                grdHandover.DataSource          = listHandOver;

                for (var i = 0; i < grdHandover.Rows.Count; i++)
                {
                    // Add to count Column
                    grdHandover.Rows[i].Cells["Count"].Value = i + 1;
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 25
0
        private static string GetTrains(string f, string t, string c)
        {
            StringBuilder sb = new StringBuilder();
            //List<CStationInfo> csl = new List<CStationInfo>();
            List <TrainInfo> tl = TrainFactory.GetTrains(f, c, t);

            if (tl.Count > 0)
            {
                sb.AppendLine("\t查询结果");
                sb.AppendLine("\t车次\t始发站\t终点站\t发 站\t发时\t到站\t到时");
                foreach (TrainInfo ti in tl)
                {
                    sb.AppendLine(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", ti.TId, ti.FirstStation.Station, ti.EndStation.Station, ti.StartStation.Station, TrainFactory.TimeSpanToString(ti.StartStation.StartTime, "{1:00}:{2:00}"), ti.EndStation.Station, TrainFactory.TimeSpanToString(ti.EndStation.StartTime, "{1:00}:{2:00}")));
                }
            }
            else
            {
                return(string.Format("{0} 和 {1} 之间不能直接通过 {2}中转!", f, t, c));
            }
            return(sb.ToString());
        }
Exemplo n.º 26
0
        public void search()
        {
            try
            {
                DateTime fromDate = dtpFrom.Value;
                DateTime toDate   = dtpTo.Value;

                var listTrain = TrainFactory.SearchTrain(txtNumberTrain.Text.Trim(),
                                                         Convert.ToInt16(((ComboBoxItem)ddlTypeName.SelectedItem).Value),
                                                         cbNgayXNC.Checked, fromDate, toDate);

                grdTrain.AutoGenerateColumns = false;
                grdTrain.DataSource          = listTrain;


                for (var i = 0; i < grdTrain.Rows.Count; i++)
                {
                    // Add to count Column
                    grdTrain.Rows[i].Cells[1].Value = (i + 1).ToString();
                    short type = short.Parse(grdTrain.Rows[i].Cells[4].Value.ToString());
                    if (type == (short)ChuyenTauType.TypeExport)
                    {
                        grdTrain.Rows[i].Cells[5].Value = "Xuất cảnh";
                    }
                    if (type == (short)ChuyenTauType.TypeImport)
                    {
                        grdTrain.Rows[i].Cells[5].Value = "Nhập cảnh";
                    }
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 27
0
        private void grdHandover_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 1)
            {
                return;
            }
            var handover = TrainFactory.FindHandoverByID(listHandOver[e.RowIndex].ID);

            if (handover.IsReplied != true && handover.Type == "1") //neu chua duoc hoi bao, va la loai BBBG di
            {
                var dr = MessageBox.Show("Bạn có muốn hồi báo BBBG: " + handover.NumberHandover, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    handover.IsReplied = true;
                    handover.DateReply = DateTime.Now;
                    int update = TrainFactory.UpdateHandover(handover);
                    if (update < 1)
                    {
                        MessageBox.Show("Thực hiện hồi báo không thành công, xin kiểm tra lại kết nối Cơ sở dữ liệu, hoặc BBBG này không còn tồn tại");
                    }
                    else
                    {
                        search();
                    }
                }
            }
            //if (handover.tblChuyenTauReference.IsLoaded == false)
            //{
            //    handover.tblChuyenTauReference.Load();
            //}
            //var frm = new Train.frmBBBG(frmMainForm._userInfo, (short)handover.tblChuyenTau.Type, handover);
            //frm.ShowDialog();
            //if (frm.DialogResult == DialogResult.OK)
            //{
            //    search();
            //}
        }
Exemplo n.º 28
0
        //AddBtn_Click: Attempts to add train details entered to Trains
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            TrainFactory  factory = TrainFactory.Instance();
            Train         train;
            List <string> intermediates = new List <string>();

            //Iterates over all the controls in the form, if it's a checkbox, check if its checked, if so add it to the list of intermediates
            foreach (var ctrl in detailsGrid.Children)
            {
                if (ctrl.GetType() == typeof(CheckBox))
                {
                    if (((CheckBox)ctrl).IsChecked.Value)
                    {
                        intermediates.Add(((CheckBox)ctrl).Content.ToString());
                    }
                }
            }

            try
            {
                train = factory.CreateTrain(idTxtBox.Text, typeCombo.Text,
                                            departCombo.Text, destCombo.Text, bool.Parse(firstclassCombo.Text), intermediates,
                                            TimeSpan.ParseExact(timeTxtBox.Text, @"hh\:mm", CultureInfo.InvariantCulture),
                                            dayDatePick.SelectedDate.Value.Date);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                successTxtBlk.Foreground = Brushes.Red;
                successTxtBlk.Text       = "Failure, Train was not added.";
                return;
            }
            MainWindow.Trains.Add(train);
            successTxtBlk.Foreground = Brushes.Green;
            successTxtBlk.Text       = "Success! Train was added.";
            MessageBox.Show("Added!");
        }
Exemplo n.º 29
0
        private void grdTrain_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (this.grdTrain.SelectedRows.Count > 0)
                {
                    int selectedIndex = grdTrain.SelectedRows[0].Index;

                    // gets the RowID from the first column in the grid
                    Int64 trainID = Int64.Parse(grdTrain[0, selectedIndex].Value.ToString());

                    tblTrain train = TrainFactory.FindTrainByID(trainID);
                    if (train == null)
                    {
                        MessageBox.Show("Tàu khách này không còn tồn tại trong Cơ Sở Dữ Liệu. Bạn hãy kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }


                    frmTrainPassengers form = new frmTrainPassengers(this, _userInfor, train, 1);
                    form.MdiParent = this.MdiParent;
                    form.Show();
                }
                else
                {
                    MessageBox.Show("Bạn cần chọn một bản ghi để cập nhật", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 30
0
        public void search()
        {
            try
            {
                listToKhai = TrainFactory.SearchToKhai(txtNumberTrain.Text.Trim(),
                                                       Convert.ToInt16(((ComboBoxItem)ddlTypeName.SelectedItem).Value),
                                                       cbNgayDK.Checked, dtpFrom.Value, dtpTo.Value, txtSoHieuToaTau.Text.Trim());
                grdTrain.AutoGenerateColumns = false;
                grdTrain.DataSource          = listToKhai;

                for (var i = 0; i < grdTrain.Rows.Count; i++)
                {
                    // Add to count Column
                    grdTrain.Rows[i].Cells["Count"].Value = i + 1;
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }