Beispiel #1
0
        public void GetDisciplinesTest()
        {
            //Arrange
            var serviceMock  = new Mock <IDisciplineService>();
            var serviceMock2 = new Mock <ISportService>();

            serviceMock.Setup(x => x.GetAllDisciplines()).Returns(() => new List <Discipline>()
            {
                new Discipline {
                    Id = 1, Name = "Road Running", SportId = 1
                },
                new Discipline {
                    Id = 2, Name = "Race Walking", SportId = 1
                },
                new Discipline {
                    Id = 3, Name = "Cross Country Running", SportId = 1
                }
            });
            var controller = new DisciplineController(serviceMock.Object, serviceMock2.Object);

            //Act
            //var result = controller.Index() as ViewResult;
            //var data = (List<Discipline>)result.ViewData.Model;

            //Assert
            //Assert.IsType<ViewResult>(result);
            //Assert.Equal(expected: "Race Walking", actual: data[1].Name);
            //Assert.Equal(expected: 3, actual: data.Count);
        }
 private void FormLessonsList_Load(object sender, EventArgs e)
 {
     Controller = new DisciplineController(db);
     db.Disciplines.Load();
     dataGridView.DataSource              = db.Disciplines.Local.ToBindingList();
     dataGridView.Columns[0].Visible      = false;
     dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
     comboBoxLector.DataSource            = db.Lectors.ToList();
     comboBoxLector.DisplayMember         = "FIO";
     RefreshDGVGroups(dataGridViewGroups);
 }
        private void AddCourse_Save_Btn_Click(object sender, EventArgs e)
        {
            DisciplineController disc = new DisciplineController();

            bool f = disc.DExists();

            if (f == true)
            {
                String code  = AddCourse_CourseCode_txt.Text;
                String hour  = AddCourse_CreditHours_txt.Text;
                String title = AddCourse_CourseName_txt.Text;


                if (code.Equals("") || hour.Equals("") || title.Equals(""))
                {
                    return;
                }

                if (!AddCourse_Sessional_RadioBtn.Checked && !AddCourse_Theory_RadioBtn.Checked)
                {
                    return;
                }

                bool flag = controller.CExists(code);

                if (flag == false)
                {
                    if (AddCourse_Theory_RadioBtn.Checked)
                    {
                        controller.saveCourse(code, hour, title, "");
                    }
                    if (AddCourse_Sessional_RadioBtn.Checked)
                    {
                        controller.saveCourse(code, hour, title, "yes");
                    }
                    MessageBox.Show("Course Saved");
                    AddCourse_CourseCode_txt.Text  = "";
                    AddCourse_CourseName_txt.Text  = "";
                    AddCourse_CreditHours_txt.Text = "";
                }
                else
                {
                    MessageBox.Show("Course Already Exists");
                }
            }
            else
            {
                MessageBox.Show("You have not created any Discipline yet !!!", "Warning", MessageBoxButtons.OK);
                AddCourse_CourseCode_txt.Text  = "";
                AddCourse_CourseName_txt.Text  = "";
                AddCourse_CreditHours_txt.Text = "";
            }
        }
        private void AddBatch_Save_Btn_Click(object sender, EventArgs e)
        {
            String name     = AddBatch_Batch_Txt.Text;
            String term     = AddBatch_Term_ComboBox.Text;
            String rollFrom = AddBatch_RollFrom_Txt.Text;
            String rollTo   = AddBatch_RollTo_Txt.Text;

            if (name.Equals("") || term.Equals("") || rollFrom.Equals("") || rollTo.Equals(""))
            {
                return;
            }

            DisciplineController disc = new DisciplineController();

            bool f = disc.DExists();

            if (f == true)
            {
                bool flag = bController.BExist(name);

                if (flag == false)
                {
                    bController.saveBatch(name, term, rollFrom, rollTo);
                    MessageBox.Show("Batch Inserted !");
                    AddBatch_Batch_Txt.Text     = "";
                    AddBatch_Term_ComboBox.Text = "";
                    AddBatch_RollFrom_Txt.Text  = "";
                    AddBatch_RollTo_Txt.Text    = "";
                }
                else
                {
                    MessageBox.Show("Batch Name Already Exists ! Plz Retry with another Batch Name");
                }
            }
            else
            {
                MessageBox.Show("You have not created any Discipline yet !!!", "Warning", MessageBoxButtons.OK);
                AddBatch_Batch_Txt.Text     = "";
                AddBatch_Term_ComboBox.Text = "";
                AddBatch_RollFrom_Txt.Text  = "";
                AddBatch_RollTo_Txt.Text    = "";
            }
        }
Beispiel #5
0
        protected T GetController <T>() where T : PluginController
        {
            PluginController controller;

            if (typeof(T) == typeof(DisciplineController))
            {
                controller = new DisciplineController(this.DisciplineStorage);
            }
            else if (typeof(T) == typeof(ChapterController))
            {
                controller = new ChapterController(this.DisciplineStorage);
            }
            else if (typeof(T) == typeof(TopicController))
            {
                controller = new TopicController(this.DisciplineStorage);
            }
            else if (typeof(T) == typeof(CurriculumController))
            {
                controller = new CurriculumController(this.CurriculumStorage);
            }
            else if (typeof(T) == typeof(CurriculumChapterController))
            {
                controller = new CurriculumChapterController(this.CurriculumStorage);
            }
            else if (typeof(T) == typeof(CurriculumChapterTopicController))
            {
                controller = new CurriculumChapterTopicController(this.CurriculumStorage);
            }
            else
            {
                throw new NotImplementedException();
            }

            var mocks = new ContextMocks(controller);

            mocks.RouteData.Values["action"]     = "Index";
            mocks.RouteData.Values["controller"] = typeof(T).Name;
            return((T)controller);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtDisciplineName.Text == "")
            {
                MessageBox.Show("Discipline TextBox is Empty!");
                txtDisciplineName.Focus();
            }
            else if (txtAcademicSesssion.Text == "")
            {
                MessageBox.Show("Academic Sesssion TextBox is Empty!");
                txtAcademicSesssion.Focus();
            }

            else
            {
                DisciplineController dscontrol = new DisciplineController();
                if (dscontrol.saveDiscipline(txtDisciplineName.Text, txtAcademicSesssion.Text))
                {
                    MessageBox.Show("Discipline saved successfully");
                }
            }
        }
        protected void InitWindowEditRewardOrDiscipline(object sender, DirectEventArgs e)
        {
            int id;

            if (!int.TryParse(hdfRecordId.Text, out id))
            {
                return;
            }
            if (hdfTypePage.Text.Equals("KhenThuong"))
            {
                var hs = RewardController.GetById(id);
                if (hs != null)
                {
                    txtKhenThuongSoQuyetDinh.Text = hs.DecisionNumber;
                    tgf_KhenThuong_NguoiRaQD.Text = hs.DecisionMaker;
                    if (hs.DecisionDate != null)
                    {
                        dfKhenThuongNgayQuyetDinh.SelectedDate = (DateTime)hs.DecisionDate;
                    }
                    if (hs.EffectiveDate != null)
                    {
                        dfKhenThuongNgayHieuLuc.SelectedDate = (DateTime)hs.EffectiveDate;
                    }
                    cbHinhThucKhenThuong.Text      = hs.FormRewardName;
                    cbLyDoKhenThuong.Text          = hs.Reason;
                    cbxCapKhenThuong.Text          = hs.LevelRewardName;
                    txtKhenThuongGhiChu.Text       = hs.Note;
                    txtUpdateSourceDepartment.Text = hs.SourceDepartment;
                    cbxUpdateMakerPosition.Text    = hs.MakerPosition;
                    txtUpdateMoneyAmount.Text      = hs.MoneyAmount.ToString(CultureInfo.InvariantCulture);
                    if (!string.IsNullOrEmpty(hs.AttachFileName))
                    {
                        var pos = hs.AttachFileName.LastIndexOf('/');
                        if (pos != -1)
                        {
                            var tenTt = hs.AttachFileName.Substring(pos + 1);
                            fufKhenThuongTepTinDinhKem.Text = tenTt;
                        }

                        hdfKhenThuongTepTinDinhKem.Text = hs.AttachFileName;
                    }
                }

                dfUpdateExpireDate.Hidden   = true;
                txtUpdateMoneyAmount.Hidden = false;
                wdKhenThuong.Show();
            }
            else
            {
                var hs = DisciplineController.GetById(id);
                if (hs != null)
                {
                    txtKhenThuongSoQuyetDinh.Text = hs.DecisionNumber;
                    tgf_KhenThuong_NguoiRaQD.Text = hs.DecisionMaker;
                    if (hs.DecisionDate != null)
                    {
                        dfKhenThuongNgayQuyetDinh.SelectedDate = (DateTime)hs.DecisionDate;
                    }
                    cbHinhThucKhenThuong.Text      = hs.FormDisciplineName;
                    cbLyDoKhenThuong.Text          = hs.Reason;
                    cbxCapKhenThuong.Text          = hs.LevelDisciplineName;
                    txtKhenThuongGhiChu.Text       = hs.Note;
                    txtUpdateSourceDepartment.Text = hs.SourceDepartment;
                    cbxUpdateMakerPosition.Text    = hs.MakerPosition;
                    if (hs.ExpireDate != null)
                    {
                        dfUpdateExpireDate.SetValue(hs.ExpireDate);
                    }
                    if (!string.IsNullOrEmpty(hs.AttachFileName))
                    {
                        var pos = hs.AttachFileName.LastIndexOf('/');
                        if (pos != -1)
                        {
                            var tenTt = hs.AttachFileName.Substring(pos + 1);
                            fufKhenThuongTepTinDinhKem.Text = tenTt;
                        }

                        hdfKhenThuongTepTinDinhKem.Text = hs.AttachFileName;
                    }
                }

                dfUpdateExpireDate.Hidden   = false;
                txtUpdateMoneyAmount.Hidden = true;
                wdKhenThuong.Show();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void Create(DirectEventArgs e)
        {
            try
            {
                var path = string.Empty;
                if (fufTepTinHangLoat.HasFile)
                {
                    path = UploadFile(fufTepTinHangLoat,
                                      hdfTypePage.Text.Equals("KhenThuong") ? Constant.PathReward : Constant.PathDiscipline);
                }

                foreach (var itemRow in chkEmployeeRowSelection.SelectedRows)
                {
                    if (hdfTypePage.Text.Equals("KhenThuong"))
                    {
                        string reasonReward;
                        if (hdfIsDanhMuc2.Text == @"0")
                        {
                            var reason = new cat_ReasonReward {
                                Name = cbbLyDoHangLoat.Text
                            };
                            cat_ReasonRewardServices.Create(reason);
                            reasonReward = cbbLyDoHangLoat.Text;
                        }
                        else
                        {
                            reasonReward = cbbLyDoHangLoat.SelectedItem.Text;
                        }

                        if (string.IsNullOrEmpty(reasonReward))
                        {
                            Dialog.Alert("Thông báo", "Không tìm thấy lý do khen thưởng. Vui lòng thử lại!");
                            return;
                        }

                        if (txtSoQuyetDinhHangLoat.Text == "")
                        {
                            GenerateRewardDecisionNumber();
                        }

                        var record = new RewardModel
                        {
                            RecordId         = Convert.ToInt32(itemRow.RecordID),
                            DecisionNumber   = txtSoQuyetDinhHangLoat.Text.Trim(),
                            DecisionMaker    = tgfNguoiQuyetDinhHangLoat.Text.Trim(),
                            FormRewardId     = int.Parse(hdfHinhThucHangLoat.Text),
                            LevelRewardId    = int.Parse(hdfLevelManyId.Text),
                            Reason           = reasonReward,
                            SourceDepartment = txtSourceDepartment.Text,
                            Note             = txtGhuChuHangLoat.Text.Trim()
                        };
                        var makerPosition = hdfIsMakerPosition.Text == @"0"
                            ? cbxMakerPosition.Text
                            : cbxMakerPosition.SelectedItem.Text;
                        record.MakerPosition = makerPosition;
                        if (!string.IsNullOrEmpty(txtMoneyAmount.Text))
                        {
                            record.MoneyAmount = decimal.Parse("0" + txtMoneyAmount.Text);
                        }
                        record.CreatedDate = DateTime.Now;
                        record.CreatedBy   = CurrentUser.User.UserName;
                        record.EditedDate  = DateTime.Now;
                        record.EditedBy    = CurrentUser.User.UserName;
                        if (!DatetimeHelper.IsNull(dfNgayQuyetDinhHangLoat.SelectedDate))
                        {
                            record.DecisionDate = dfNgayQuyetDinhHangLoat.SelectedDate;
                        }

                        if (!DatetimeHelper.IsNull(dfNgayHieuLuc.SelectedDate))
                        {
                            record.EffectiveDate = dfNgayHieuLuc.SelectedDate;
                        }

                        record.AttachFileName = path != "" ? path : hdfTepDinhKemHangLoat.Text;
                        RewardController.Create(record);
                    }
                    else
                    {
                        string reasonDiscipline;
                        if (hdfIsDanhMuc2.Text == @"0")
                        {
                            var reason = new cat_ReasonDiscipline()
                            {
                                Name = cbbLyDoHangLoat.Text
                            };
                            cat_ReasonDisciplineServices.Create(reason);
                            reasonDiscipline = cbbLyDoHangLoat.Text;
                        }
                        else
                        {
                            reasonDiscipline = cbbLyDoHangLoat.SelectedItem.Text;
                        }

                        if (string.IsNullOrEmpty(reasonDiscipline))
                        {
                            Dialog.Alert("Thông báo", "Không tìm thấy lý do khen thưởng. Vui lòng thử lại!");
                            return;
                        }

                        if (txtSoQuyetDinhHangLoat.Text == "")
                        {
                            GenerateRewardDecisionNumber();
                        }

                        var record = new DisciplineModel
                        {
                            RecordId          = Convert.ToInt32(itemRow.RecordID),
                            DecisionNumber    = txtSoQuyetDinhHangLoat.Text.Trim(),
                            DecisionMaker     = tgfNguoiQuyetDinhHangLoat.Text.Trim(),
                            FormDisciplineId  = int.Parse(hdfHinhThucHangLoat.Text),
                            LevelDisciplineId = int.Parse(hdfLevelManyId.Text),
                            Reason            = reasonDiscipline,
                            SourceDepartment  = txtSourceDepartment.Text,
                            Note = txtGhuChuHangLoat.Text.Trim()
                        };
                        var makerPosition = hdfIsMakerPosition.Text == @"0"
                            ? cbxMakerPosition.Text
                            : cbxMakerPosition.SelectedItem.Text;
                        record.MakerPosition = makerPosition;
                        record.CreatedDate   = DateTime.Now;
                        record.CreatedBy     = CurrentUser.User.UserName;
                        record.EditedDate    = DateTime.Now;
                        record.EditedBy      = CurrentUser.User.UserName;

                        if (!DatetimeHelper.IsNull(dfNgayQuyetDinhHangLoat.SelectedDate))
                        {
                            record.DecisionDate = dfNgayQuyetDinhHangLoat.SelectedDate;
                        }

                        if (!DatetimeHelper.IsNull(dfExpireDate.SelectedDate))
                        {
                            record.ExpireDate = dfExpireDate.SelectedDate;
                        }
                        record.AttachFileName = path != "" ? path : hdfTepDinhKemHangLoat.Text;
                        DisciplineController.Create(record);
                    }
                }

                grp_KhenThuongKyLuat.Reload();
                ResetForm();
                wdKhenThuongKyLuatHangLoat.Hide();
            }
            catch (Exception ex)
            {
                Dialog.Alert("Có lỗi xảy ra trong quá trình tạo quyết định: {0}".FormatWith(ex.Message));
            }
        }