Esempio n. 1
0
        private void ActionDepartment(action vAction)
        {
            try
            {
                if (grdDepartment.CurrentRow == null && (vAction == action.Update || vAction == action.Delete))
                {
                    return;
                }

                switch (vAction)
                {
                case action.Normal:
                    dtDepartment             = new Select().From(LDepartment.Schema.Name).ExecuteDataSet().Tables[0];
                    grdDepartment.DataSource = dtDepartment;
                    break;

                case action.Delete:
                    if (
                        LPatientInfo.CreateQuery().WHERE(LPatientInfo.Columns.DepartmentID,
                                                         Utility.Int32Dbnull(grdDepartment.GetValue("ID"))).
                        GetRecordCount() > 0)
                    {
                        Utility.ShowMsg("Danh mục đang được sử dụng. Không được xóa");
                        return;
                    }
                    if (Utility.AcceptQuestion("Thực hiện xóa " + grdDepartment.GetValue("sName"), "Thông báo", true))
                    {
                        new Delete().From(LDepartment.Schema.Name).Where(LDepartment.Columns.Id).IsEqualTo(
                            Utility.Int32Dbnull(grdDepartment.GetValue("ID"))).Execute();
                        grdDepartment.CurrentRow.Delete();
                        grdDepartment.UpdateData();
                    }
                    dtDepartment.AcceptChanges();
                    break;

                default:
                    var oForm = new frmDepartmentList_AU();
                    oForm.vAction = vAction;
                    oForm.drList  = Utility.GetDataRow(dtDepartment, LDepartment.Columns.Id,
                                                       grdDepartment.GetValue("ID"));
                    oForm.dtList = dtDepartment;
                    oForm.ShowDialog();
                    break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Esempio n. 2
0
        private void ActionDepartment(action vAction)
        {
            try
            {
                if (grdDepartment.CurrentRow == null && (vAction == action.Update || vAction == action.Delete)) return;

                switch (vAction)
                {
                    case action.Normal:
                        dtDepartment = new Select().From(LDepartment.Schema.Name).ExecuteDataSet().Tables[0];
                        grdDepartment.DataSource = dtDepartment;
                        break;
                    case action.Delete:
                        if (
                            LPatientInfo.CreateQuery().WHERE(LPatientInfo.Columns.DepartmentID,
                                                             Utility.Int32Dbnull(grdDepartment.GetValue("ID"))).
                                GetRecordCount() > 0)
                        {
                            Utility.ShowMsg("Danh mục đang được sử dụng. Không được xóa");
                            return;
                        }
                        if (Utility.AcceptQuestion("Thực hiện xóa " + grdDepartment.GetValue("sName"), "Thông báo", true))
                        {
                            new Delete().From(LDepartment.Schema.Name).Where(LDepartment.Columns.Id).IsEqualTo(
                                Utility.Int32Dbnull(grdDepartment.GetValue("ID"))).Execute();
                            grdDepartment.CurrentRow.Delete();
                            grdDepartment.UpdateData();
                        }
                        dtDepartment.AcceptChanges();
                        break;
                    default:
                        var oForm = new frmDepartmentList_AU();
                        oForm.vAction = vAction;
                        oForm.drList = Utility.GetDataRow(dtDepartment, LDepartment.Columns.Id,
                                                          grdDepartment.GetValue("ID"));
                        oForm.dtList = dtDepartment;
                        oForm.ShowDialog();
                        break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }