Пример #1
0
        private void ActionDevice(action vAction)
        {
            try
            {
                if (grdDevice.CurrentRow == null && (vAction == action.Update || vAction == action.Delete))
                {
                    return;
                }

                switch (vAction)
                {
                case action.Normal:
                    dtDevice =
                        new Select(DDeviceList.Schema.Name + ".*", TTestTypeList.Columns.TestTypeName,
                                   LManufacture.Columns.SName)
                        .From(DDeviceList.Schema.Name).
                        LeftOuterJoin(TTestTypeList.TestTypeIdColumn, DDeviceList.TestTypeIdColumn).
                        LeftOuterJoin(LManufacture.IdColumn, DDeviceList.ManufactureIdColumn).
                        ExecuteDataSet().Tables[0];
                    grdDevice.DataSource = dtDevice;
                    break;

                case action.Delete:
                    if (
                        DDataControl.CreateQuery().WHERE(DDataControl.Columns.DeviceId, Utility.Int32Dbnull(grdDevice.GetValue("Device_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 " + grdDevice.GetValue("Device_Name"), "Thông báo",
                                               true))
                    {
                        new Delete().From(DDeviceList.Schema.Name).Where(DDeviceList.Columns.DeviceId).IsEqualTo(
                            Utility.Int32Dbnull(grdDevice.GetValue("Device_ID"))).Execute();
                        grdDevice.CurrentRow.Delete();
                        grdDevice.UpdateData();
                    }
                    dtDevice.AcceptChanges();
                    break;

                default:
                    var oForm = new frmDeviceList_AU();
                    oForm.vAction = vAction;
                    oForm.drList  = Utility.GetDataRow(dtDevice, DDeviceList.Columns.DeviceId,
                                                       grdDevice.GetValue("Device_ID"));
                    oForm.dtList = dtDevice;
                    oForm.ShowDialog();
                    break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Пример #2
0
        private void ActionDevice(action vAction)
        {
            try
            {
                if (grdDevice.CurrentRow == null && (vAction == action.Update || vAction == action.Delete)) return;

                switch (vAction)
                {
                    case action.Normal:
                        dtDevice =
                            new Select(DDeviceList.Schema.Name + ".*", TTestTypeList.Columns.TestTypeName,
                                       LManufacture.Columns.SName)
                                .From(DDeviceList.Schema.Name).
                                LeftOuterJoin(TTestTypeList.TestTypeIdColumn, DDeviceList.TestTypeIdColumn).
                                LeftOuterJoin(LManufacture.IdColumn, DDeviceList.ManufactureIdColumn).
                                ExecuteDataSet().Tables[0];
                        grdDevice.DataSource = dtDevice;
                        break;
                    case action.Delete:
                        if (
                            DDataControl.CreateQuery().WHERE(DDataControl.Columns.DeviceId,Utility.Int32Dbnull(grdDevice.GetValue("Device_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 " + grdDevice.GetValue("Device_Name"), "Thông báo",
                                                   true))
                        {
                            new Delete().From(DDeviceList.Schema.Name).Where(DDeviceList.Columns.DeviceId).IsEqualTo(
                                Utility.Int32Dbnull(grdDevice.GetValue("Device_ID"))).Execute();
                            grdDevice.CurrentRow.Delete();
                            grdDevice.UpdateData();
                        }
                        dtDevice.AcceptChanges();
                        break;
                    default:
                        var oForm = new frmDeviceList_AU();
                        oForm.vAction = vAction;
                        oForm.drList = Utility.GetDataRow(dtDevice, DDeviceList.Columns.DeviceId,
                                                          grdDevice.GetValue("Device_ID"));
                        oForm.dtList = dtDevice;
                        oForm.ShowDialog();
                        break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }