Exemplo n.º 1
0
        private void PerformAction(action vAction)
        {
            try
            {
                if (grdTestGroup.CurrentRow == null && (vAction == action.Update || vAction == action.Delete))
                {
                    return;
                }

                switch (vAction)
                {
                case action.Delete:
                    if (Utility.AcceptQuestion("Thực hiện xóa " + grdTestGroup.GetValue("TestGroup_Name"), "Thông báo",
                                               true))
                    {
                        new Delete().From(TTestgroupList.Schema.Name).Where(TTestgroupList.Columns.TestGroupId).IsEqualTo(
                            Utility.Int32Dbnull(grdTestGroup.GetValue("TestGroup_ID"))).Execute();
                        new Delete().From(TTestgroupDtl.Schema.Name).Where(TTestgroupDtl.Columns.TestGroupId).IsEqualTo(
                            Utility.Int32Dbnull(grdTestGroup.GetValue("TestGroup_ID"))).Execute();
                        grdTestGroup.CurrentRow.Delete();
                        grdTestGroup.UpdateData();
                    }
                    break;

                default:
                    var oForm = new frmTestGroupList_AU();
                    if (vAction == action.Update)
                    {
                        oForm.txtID.Text = Utility.sDbnull(grdTestGroup.GetValue("TestGroup_ID"));
                    }
                    oForm.dtList  = dtTestGroup;
                    oForm.grdList = grdTestGroup;
                    oForm.ShowDialog();
                    if (grdTestGroup.CurrentRow != null)
                    {
                        grdTestGroup_SelectionChanged(new object(), new EventArgs());
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void PerformAction(action vAction)
        {
            try
            {
                if (grdTestGroup.CurrentRow == null && (vAction == action.Update || vAction == action.Delete))
                    return;

                switch (vAction)
                {
                    case action.Delete:
                        if (Utility.AcceptQuestion("Thực hiện xóa " + grdTestGroup.GetValue("TestGroup_Name"), "Thông báo",
                                                   true))
                        {
                            new Delete().From(TTestgroupList.Schema.Name).Where(TTestgroupList.Columns.TestGroupId).IsEqualTo(
                                Utility.Int32Dbnull(grdTestGroup.GetValue("TestGroup_ID"))).Execute();
                            new Delete().From(TTestgroupDtl.Schema.Name).Where(TTestgroupDtl.Columns.TestGroupId).IsEqualTo(
                                Utility.Int32Dbnull(grdTestGroup.GetValue("TestGroup_ID"))).Execute();
                            grdTestGroup.CurrentRow.Delete();
                            grdTestGroup.UpdateData();
                        }
                        break;
                    default:
                        var oForm = new frmTestGroupList_AU();
                        if (vAction == action.Update) oForm.txtID.Text = Utility.sDbnull(grdTestGroup.GetValue("TestGroup_ID"));
                        oForm.dtList = dtTestGroup;
                        oForm.grdList = grdTestGroup;
                        oForm.ShowDialog();
                        if (grdTestGroup.CurrentRow !=null)
                            grdTestGroup_SelectionChanged(new object(), new EventArgs());
                        break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }