예제 #1
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());
                }
            }
        }