112 lines
4.1 KiB
C#
112 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Linq;
|
|
using Datalib.Linq;
|
|
using Datalib.DatabaseSpecific;
|
|
using Datalib.EntityClasses;
|
|
using Datalib.HelperClasses;
|
|
using SD.LLBLGen.Pro.ORMSupportClasses;
|
|
|
|
namespace Omega.Forms
|
|
{
|
|
public partial class frmDirectories : Omega.BasicForms.frmCommon
|
|
{
|
|
public EntityCollection<TblSubjectEntity> SubjectList { get; set; }
|
|
public EntityCollection<TblTrainingTypeEntity> TrainingTypes { get; set; }
|
|
public EntityCollection<TblFieldEntity> Fields { get; set; }
|
|
public CurrencyManager FieldsMan;
|
|
|
|
public frmDirectories()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public override void LoadData()
|
|
{
|
|
SubjectList = new EntityCollection<TblSubjectEntity>();
|
|
TrainingTypes = new EntityCollection<TblTrainingTypeEntity>();
|
|
Fields = new EntityCollection<TblFieldEntity>();
|
|
adapter.FetchEntityCollection(SubjectList, null);
|
|
adapter.FetchEntityCollection(TrainingTypes, null);
|
|
adapter.FetchEntityCollection(Fields, null);
|
|
|
|
|
|
this.grdTrainingType.DataSource = TrainingTypes;
|
|
this.gridField.DataSource = Fields;
|
|
this.repoSubject.DataSource = SubjectList;
|
|
this.grdSubjects.DataSource = SubjectList;
|
|
FieldsMan = (CurrencyManager)this.BindingContext[Fields];
|
|
FieldsMan.PositionChanged += FieldsMan_PositionChanged;
|
|
}
|
|
|
|
void FieldsMan_PositionChanged(object sender, EventArgs e)
|
|
{
|
|
if (Fields[FieldsMan.Position].IsNew)
|
|
{
|
|
Fields[FieldsMan.Position].UniqueId = Guid.NewGuid().ToString("N");
|
|
|
|
}
|
|
}
|
|
|
|
private void frmDirectories_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Save_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
adapter.SaveEntityCollection(this.TrainingTypes, true, true);
|
|
adapter.SaveEntityCollection(this.SubjectList, true, true);
|
|
adapter.SaveEntityCollection(this.Fields, true, true);
|
|
}
|
|
|
|
private void btnSubjectDesView_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
frmViewOpenXMLContent frm = new frmViewOpenXMLContent();
|
|
frm.View = SubjectView;
|
|
frm.Column = colSubjectDes;
|
|
frm.LoadData();
|
|
frm.Show();
|
|
}
|
|
|
|
private void tbnFieldDesView_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
frmViewOpenXMLContent frm = new frmViewOpenXMLContent();
|
|
frm.View = FieldDesView;
|
|
frm.Column = colDescription;
|
|
frm.LoadData();
|
|
frm.Show();
|
|
}
|
|
|
|
private void barDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
if (MessageBox.Show("Bạn có muốn xóa bản ghi này?", "Chương trình quản lý đề thi", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
|
|
int index = Directories.SelectedTabPageIndex;
|
|
switch(index)
|
|
{
|
|
case 0:
|
|
TblSubjectEntity sub = (TblSubjectEntity)SubjectList[this.BindingContext[SubjectList].Position];
|
|
adapter.DeleteEntity(sub);
|
|
SubjectList.Remove(sub);
|
|
break;
|
|
case 1:
|
|
TblTrainingTypeEntity train = (TblTrainingTypeEntity)this.TrainingTypes[this.BindingContext[TrainingTypes].Position];
|
|
adapter.DeleteEntity(train);
|
|
TrainingTypes.Remove(train);
|
|
break;
|
|
case 2:
|
|
TblFieldEntity field = (TblFieldEntity)this.Fields[this.BindingContext[Fields].Position];
|
|
adapter.DeleteEntity(field);
|
|
Fields.Remove(field);
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|