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());
                }
            }
        }
Beispiel #2
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());
                }
            }
        }
Beispiel #3
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Validate())
                {
                    return;
                }
                var train = new tblTrain();
                train.Number = txtNumberTrain.Text.Trim();
                var type = (short)((ComboBoxItem)ddlTypeName.SelectedItem).Value;
                train.Type = type;
                if (type == (short)TrainType.TypeExport || type == (short)TrainType.TypeExportChange || type == (short)TrainType.TypeExportNormal)
                {
                    train.IsExport   = true;
                    train.DateExport = CommonFactory.GetCurrentDate();
                }
                else
                {
                    train.IsImport   = true;
                    train.DateImport = CommonFactory.GetCurrentDate();
                }
                if (type == (short)TrainType.TypeExportChange || type == (short)TrainType.TypeImportChange)
                {
                    train.NumberHandover    = txtNumberHandover.Text.Trim();
                    train.DateHandover      = dtpHandover.Value;
                    train.CodeStation       = txtCodeCuaKhau.Text.Trim();
                    train.CodeStationFromTo = txtCodeGaDenDi.Text.Trim();
                    train.StatusVehicle     = txtStatusVehicle.Text.Trim();
                    train.StatusGoods       = txtStatusGood.Text.Trim();
                }

                train.CreatedBy = _userInfo.UserID;
                if (TrainFactory.Insert(train) > 0)
                {
                    //insert tờ khai
                    if (type == (short)TrainType.TypeExportNormal || type == (short)TrainType.TypeImportNormal)
                    {
                        var declare = new tblToKhaiTau()
                        {
                            Number          = Convert.ToInt32(txtExportNumber.Text.Trim()),
                            DateDeclaration = dtpDeclaration.Value,
                            TypeCode        = txtTypeExport.Text.Trim(),
                            CustomCode      = txtCustomsCode.Text.Trim(),
                            CreatedBy       = _userInfo.UserID,
                            //TrainID = train.TrainID
                        };
                        TrainFactory.InsertToKhai(declare);
                    }
                    //insert toa tàu
                    if (grdToaTau.Rows.Count > 0)
                    {
                        var listToaTau = new List <tblToaTau>();
                        for (int i = 0; i < grdToaTau.Rows.Count; i++)
                        {
                            var toaTau = (tblToaTau)grdToaTau.Rows[i].DataBoundItem;
                            toaTau.CreatedBy = _userInfo.UserID;
                            //toaTau.TrainID = train.TrainID;
                            listToaTau.Add(toaTau);
                        }
                        TrainFactory.InsertToaTau(listToaTau);
                    }

                    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());
                }
            }
        }