Delphi Dev Express TcxDBTimeEdit and how to handle nulls?

Delphi Dev Express TcxDBTimeEdit and how to handle nulls ?

I’m trying to use Dev Express TcxDBTimeEdit component in Delphi and I’m keen for user to be able to use mouse to select all and delete key to clear and for this to store a null in the associated database column field value.

I’m not sure how to achieve this.

I have tried this, but it doesn’t work, in the component Exit event:

    if
       (cxDBTimeEdit1.Text = '00:00 AM')
       or (cxDBTimeEdit1.Text = '12:00 AM')
       or (cxDBTimeEdit1.Text = '')
    then dmClaimLine.qryClaimLineTimeOfService.AsString:='';

I’m also using an old version of Delphi .. Delphi 2007 and also old version of Dev Express components .. version 6.50 from April 2009.

Am connecting via Devart SDAC 8.2.9 to MS SQL Server 2017 DB

I did finally get this working with some quite unusual events code:

procedure TfrmC420201ClaimLine.tedTimeOfServiceKeyDown(Sender: TObject;
      var Key: Word; Shift: TShiftState);
    begin
      inherited;
      //This code allows the operator to select the time and press the delete key to return the DB col value to NULL
      //The SetFocus on another control and unassign and then reassign DataField is required to achieve this. Looks odd but works.
      if Key = VK_DELETE then
      begin
        tedTimeOfService.DataBinding.DataField:='';
        with dmClaimLine do
        begin
            if (FMode <> 'Assess') then Exit;
            ClaimLineEditable;
            dmClaimLine.qryClaimLineTimeOfService.Clear;
            dmClaimLine.qryClaimLineTimeOfService.AsString:='';
        end;
        edtMediTimeDuration.SetFocus;
        tedTimeOfService.DataBinding.DataField:='TimeOfService';
      end;
    
    end;

procedure TfrmC420201ClaimLine.tedTimeOfServiceEnter(Sender: TObject);
begin
    inherited;

    with dmClaimLine do
    begin
        if (FMode <> 'Assess') then Exit;
        ClaimLineEditable;
        dmClaimLine.qryClaimLineTimeOfService.AsDateTime := tedTimeOfService.Time        
    end;

end;

procedure TfrmC420201ClaimLine.tedTimeOfServicePropertiesChange(Sender: TObject);
var EditValueStr, TimeStr: string;
begin
    inherited;
    if VarIsNull(tedTimeOfService.EditValue) then EditValueStr  := 'Null' else EditValueStr  := TimeToStr(tedTimeOfService.Time);
    if VarIsNull(tedTimeOfService.Time) then TimeStr := 'Null' else TimeStr := TimeToStr(tedTimeOfService.Time);

    with dmClaimLine do
    begin
        if (FMode <> 'Assess') then Exit;
        if (dmClaimLine.qryClaimLineTimeOfService.AsString = '')
        and (EditValueStr = 'Null') then exit;
        if dmClaimLine.qryClaimLineTimeOfService.AsDateTime <> tedTimeOfService.Time
        then
        begin
            ClaimLineEditable;
            dmClaimLine.qryClaimLineTimeOfService.AsDateTime := tedTimeOfService.Time
        end;
    end;
end;

4

Your code is working directly with the control state instead of the database state.

You should instead try to handle things using the actual underlying field in the underlying dataset.

The fact that your control is a cxDBTimeEdit is not even important to your question.

dmClaimLine.qryClaimLineTimeOfService.AsString:='';

^^ Whatever you think this does, it probably doesn’t do it.^^

If you are using a dataset to directly edit row values you need to specify how you’re doing that. how you do that differs depending on the component set you use to access a database, and the database you’re connecting to, you haven’t specified either one.

You’re coding against the visual controls [cxDBTimeEdit1.Text], when you should be reading the field values from the database access components (DAC). If you were using ADO, for instance, and you had an ADOTable named ClaimLine, you might be needing to do this

ClaimLine.Edit;
ClaimLineTimeOfService.Clear; // make a field null
ClaimLine.Post;

If you were instead updating with an SQL update statement you might do something like this

UpdateClaimEntry.ParamByName('timeofservice').Clear;
UpdateClaimEntry.ExecSQL;

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật