Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void Insert(DirectEventArgs e)
        {
            try
            {
                foreach (var itemRow in chkEmployeeRowSelection.SelectedRows)
                {
                    var model = new TrainingHistoryModel()
                    {
                        RecordId          = Convert.ToInt32(itemRow.RecordID),
                        TrainingName      = txtDTTenKhoaDaoTao.Text.Trim(),
                        Reason            = txtDTLyDoDaoTao.Text.Trim(),
                        TrainingPlace     = txtDTNoiDaoTao.Text.Trim(),
                        Note              = txtDTGhiChu.Text.Trim(),
                        SponsorDepartment = txtSponsorDepartment.Text,
                        DecisionMaker     = txtDecisionMaker.Text,
                        SourceDepartment  = txtSourceDepartment.Text,
                        MakerPosition     = hdfIsMakerPosition.Text == @"0" ? cbxMakerPosition.Text : cbxMakerPosition.SelectedItem.Text,
                        CreatedBy         = CurrentUser.User.UserName,
                        CreatedDate       = DateTime.Now,
                        EditedDate        = DateTime.Now,
                        EditedBy          = CurrentUser.User.UserName
                    };

                    if (!string.IsNullOrEmpty(hdfNationIdMany.Text))
                    {
                        model.NationId = Convert.ToInt32(hdfNationIdMany.Text);
                    }

                    if (!DatetimeHelper.IsNull(dfDTTuNgay.SelectedDate))
                    {
                        model.StartDate = dfDTTuNgay.SelectedDate;
                    }

                    if (!DatetimeHelper.IsNull(dfDTDenNgay.SelectedDate))
                    {
                        model.EndDate = dfDTDenNgay.SelectedDate;
                    }

                    //create
                    TrainingHistoryController.Create(model);
                }

                wdTraining.Hide();
                gpTrainingHistory.Reload();
            }
            catch (Exception ex)
            {
                Dialog.Alert("Có lỗi xảy ra trong quá trình thêm mới: {0}".FormatWith(ex.Message));
            }
        }