Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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();
            //}
        }
Ejemplo n.º 4
0
        private void printBBBG()
        {
            try
            {
                var reportHandOver = new ReportHandOver();

                var txtNumberHandover = (TextObject)reportHandOver.Section1.ReportObjects["txtNumberHandover"];
                var ddlGaDenDi        = (TextObject)reportHandOver.Section1.ReportObjects["ddlGaDenDi"];
                var dtpHandover       = (TextObject)reportHandOver.Section1.ReportObjects["dtpHandover"];

                //Khong dung
                //var txtSummary = (TextObject)reportHandOver.Section1.ReportObjects["txtSummary"];
                var txtStatusVehicle = (TextObject)reportHandOver.Section1.ReportObjects["txtStatusVehicle"];
                var txtStatusGoods   = (TextObject)reportHandOver.Section1.ReportObjects["txtStatusGoods"];
                var txtCustoms       = (TextObject)reportHandOver.Section1.ReportObjects["txtCustoms"];
                //var txtPath = (TextObject)reportHandOver.Section1.ReportObjects["txtPath"];
                //var txtConfirmOfToStation = (TextObject)reportHandOver.Section1.ReportObjects["txtConfirmOfToStation"];
                var txtToStation   = (TextObject)reportHandOver.Section1.ReportObjects["txtToStation"];
                var txtFromStation = (TextObject)reportHandOver.Section1.ReportObjects["txtFromStation"];

                long handoverId = _handover.ID; //1L;

                tblHandover handover = TrainFactory.FindHandoverByID(handoverId);
                if (handover != null)
                {
                    if (handover.tblHandoverResources.IsLoaded == false)
                    {
                        handover.tblHandoverResources.Load();
                    }
                    List <tblHandoverResource> listTblHandoverResources = TrainFactory.FindHandoverResourceByHandoverID(handoverId);
                    //List<tblHandoverResource> listTblHandoverResources = handover.tblHandoverResources.ToList(); ;
                    List <tblToaTau> listToaTau = new List <tblToaTau>();
                    foreach (tblHandoverResource obj in listTblHandoverResources)
                    {
                        if (obj.tblToaTauReference.IsLoaded == false)
                        {
                            obj.tblToaTauReference.Load();
                        }
                        if (obj.tblToaTau != null)
                        {
                            listToaTau.Add(obj.tblToaTau);
                        }
                    }

                    DataSet1  dataset = new DataSet1();
                    DataTable dt      = dataset.tblToaTau;
                    //dt = ListToDataTable.ToDataTable(listToaTau);
                    foreach (tblToaTau toaTau in listToaTau)
                    {
                        if (toaTau.tblChuyenTauReference.IsLoaded == false)
                        {
                            toaTau.tblChuyenTauReference.Load();
                        }
                        dt.Rows.Add(toaTau.ToaTauID,
                                    toaTau.Ma_ToaTau
                                    , toaTau.So_VanTai_Don
                                    , toaTau.Ngay_VanTai_Don
                                    , toaTau.Ten_DoiTac
                                    , toaTau.Ma_DoanhNghiep
                                    , toaTau.Ten_Hang
                                    , toaTau.Trong_Luong
                                    , toaTau.Don_Vi_Tinh
                                    , toaTau.Seal_VanTai
                                    , toaTau.Seal_VanTai2
                                    , toaTau.Seal_HaiQuan
                                    , toaTau.Seal_HaiQuan2
                                    , toaTau.Ghi_Chu
                                    , toaTau.CreatedDate
                                    , toaTau.CreatedBy
                                    , toaTau.ModifiedDate
                                    , toaTau.ModifiedBy
                                    , toaTau.tblChuyenTau.TrainID);
                    }

                    reportHandOver.SetDataSource(dataset);
                    String fromStation = CustomsFacory.FindByCode(handover.CodeStation).CustomsName;
                    String toStation   = CustomsFacory.FindByCode(handover.CodeStationFromTo).CustomsName;

                    //if (handover.DateHandover != null)
                    //{
                    //    String dateString = "Hồi " + handover.DateHandover.Value.Hour + " giờ " + handover.DateHandover.Value.Minute + " phút, ngày " + handover.DateHandover.Value.Day + " tháng " + handover.DateHandover.Value.Month + " năm " + handover.DateHandover.Value.Year;
                    //    txtSummary.Text = dateString + " " + fromStation + " bàn giao cho Chi nhánh vận tải hàng hóa đường sắt Đồng Đăng" +
                    //    " lô hàng nhập khẩu chuyển cảng vận chuyển từ " + fromStation + " đến " + toStation + ".";
                    //}

                    //txtNumberHandover.Text = "Số: " + handover.NumberHandover + "/BBBG-HQGA";
                    txtNumberHandover.Text = "Số: " + handover.NumberHandover;
                    // Ten hai quan den
                    ddlGaDenDi.Text = "Kính gửi: " + toStation;
                    if (handover.DateHandover != null)
                    {
                        dtpHandover.Text = "Thời gian chuyển: hồi " + handover.DateHandover.Value.Hour + " giờ ngày " + handover.DateHandover.Value.Day + " tháng " + handover.DateHandover.Value.Month + " năm " + handover.DateHandover.Value.Year;
                    }

                    txtStatusVehicle.Text = handover.StatusVehicle;
                    txtStatusGoods.Text   = handover.StatusGoods;

                    txtCustoms.Text = fromStation.ToUpper();
                    //txtPath.Text = "Từ " + fromStation + " đến " + toStation;
                    //txtConfirmOfToStation.Text = "5. Xác nhận của " + toStation + ":";
                    txtFromStation.Text = fromStation;
                    txtToStation.Text   = toStation;
                }

                reportHandOver.Section3.SectionFormat.EnableUnderlaySection = true;
                reportHandOver.Section3.SectionFormat.EnableKeepTogether    = true;


                FrmPreviewReport frmReport = new FrmPreviewReport(reportHandOver);
                frmReport.MdiParent = this.MdiParent;
                frmReport.Show();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
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 (!Validate())
                {
                    return;
                }
                var train = TrainFactory.GetByCode(txtSoVanDon.Text.Trim());

                if (grdToaTau.RowCount == 0)
                {
                    MessageBox.Show("Bạn phải chọn ít nhất một toa tàu!");
                    return;
                }
                Nullable <DateTime> replyDate = null;
                if (cbReply.Checked)
                {
                    replyDate = dtpReplyDate.Value;
                }
                var handOver = new tblHandover
                {
                    NumberHandover    = txtNumberHandover.Text.Trim(),
                    DateHandover      = dtpHandover.Value,
                    CodeStation       = txtCodeCuaKhau.Text.Trim(),
                    CodeStationFromTo = txtCodeGaDenDi.Text.Trim(),
                    StatusGoods       = txtStatusGood.Text.Trim(),
                    StatusVehicle     = txtStatusVehicle.Text.Trim(),
                    CreatedBy         = _userInfo.UserID,
                    CreatedDate       = CommonFactory.GetCurrentDate(),
                    Type             = _type.ToString(),
                    IsReplied        = cbReply.Checked,
                    DateReply        = replyDate,
                    NoteReply        = cbReply.Checked?txtReplyNote.Text:null,
                    ReplyStatusGoods = cbReply.Checked ? txtReplyStatusGoods.Text : null,
                };
                foreach (var toaTau in listToaTau)
                {
                    var handOverResource = new tblHandoverResource
                    {
                        tblToaTau = toaTau
                    };
                    handOver.tblHandoverResources.Add(handOverResource);
                }

                var result = TrainFactory.InsertBBBG(handOver, _NumberGenerate);
                if (result > 0)
                {
                    if (cbPrint.Checked == true)
                    {
                        MessageBox.Show("Thêm mới Biên bản bàn giao thành công. Bạn hãy tắt hộp thoại này để xem bản in");
                        _handover = TrainFactory.FindHandoverByID(handOver.ID);
                        printBBBG();
                        Reset();
                    }
                    else
                    {
                        MessageBox.Show("Thêm mới Biên bản bàn giao thành công!");
                        Reset();
                    }
                }
                else
                {
                    MessageBox.Show("Thêm mới Biên bản bàn không thành công!");
                }
            }
            catch (Exception ex)
            {
                if (GlobalInfo.IsDebug)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }