📄 ufrmtaxicall_utils.pas
字号:
unit ufrmTAXICALL_Utils;
interface
uses SysUtils,uBaseDBUtils,cxTextEdit, cxControls,classes,
cxContainer,cxMemo,cxEdit,cxDropDownEdit,ComCtrls,
uBaseDBForm,uBaseDBEditForm,RzGrids,variants,TbListView,uBaseDBDefs;
type
//用户信息
Tmy_userinfo=record
user_lognname :string;
user_lognid :integer;
user_dpm :integer;
user_name :string;
user_id :integer;
user_logn_date:string;
end;
//主窗口状态信息
Pmy_parent_stateinfo =^Tmy_parent_stateinfo;
Tmy_parent_stateinfo=record
parent_stated :string; //状态中文名
parent_stateid :integer; //状态序号多用来控下一级按钮用
parent_typeid :integer; //状态序号多用来控下一级录入用
parent_recordid :integer; //当前记录id
parent_Form :TBaseDBForm;
ChildTableFieldList: TList;
parent_EditForm :TBaseDBEditForm;
parent_active :TBaseDBCommandType; //什么操作
Pnext_one :Pmy_parent_stateinfo; //下一指针
end;
TApp_Info = record
DataBaseName : string;
AppPaths : string;
AppVersion : string;
AppUpdateing : boolean;
end;
var
App_Info_Start :TApp_Info;
user_login :Tmy_userinfo;
parent_state :Tmy_parent_stateinfo;
parent_state_for_out :Tmy_parent_stateinfo;
g_app_global : PBaseDBAppGlobal;
// procedure MyFilterOfMultiRef(_sender: TObject; _master_id: Integer;
// _child_table_detail_id: Integer; var _is_filter: Boolean;view_data_list:Tlist);
//procedure GetRefOtherFieldValueByID(_cxComboBox:TcxComboBox;_field_name:string);
//var
// p_field_info_AnyField : PBaseDBFieldInfo;
// p_ref_table_FieldRefHandle : TBaseDBRefTable;
// p_field_Id : Integer;
//
//Begin
// p_field_info_AnyField := TBaseDBUtility.ExtractFieldInfoByFieldName(_field_name:string,EditFieldValueList);
// p_ref_table_FieldRefHandle := p_field_info_AnyField.RefTableInfo^;
// p_field_Id := ExtractRefComboBoxReferenceID(_cxComboBox);
// result := TBaseDBUtility.ExtractRefInforValueByFieldName(p_ref_table_FieldRefHandle,
// _field_name, p_field_Id);
//
//end;
//用户输入超过字段长度时警告并截除超出部分
procedure baseDBUtilLengthLimit(_cxComboBox:TcxComboBox;_cxTextEdit:TcxTextEdit;_cxMemo:tcxMemo;MaxLength:integer);
//删除当指定行
procedure deleteTRzStringGrid_row(TempListstring:TRzStringGrid);
//返回一个当前日期时间表字符窜------(一般用来作随机号,如一些账单号)
function DateTimeSerialNo:string;
//取得一个listview相应字段合计数
function GetListViewFieldSum(field_name:string;list_view:TTbListView):variant;
//根据值取得ComboBox的ItemIndex值
function ExtractRefComboBoxReferenceIDToItemIndex(
_combo_box: TcxComboBox;_ReferenceID:integer): Integer;
//根据值取得ComboBox的对应的中文值
function ExtractRefComboBoxReferenceIDToCh(
_combo_box: TcxComboBox;_ReferenceID:integer):string;
//判断子表是否有数据!
function IsListViewHaveData(list_view:TTbListView):boolean;
//判断表中的状态!
function IsStateIDTrue(_ListView:TTbListView;_FieldName:string;_StateID_Value,_Return_condition:integer):boolean;
implementation
function ExtractRefComboBoxReferenceIDToCh(
_combo_box: TcxComboBox;_ReferenceID:integer):string;
var
combo_box_itemindex : integer;
begin
combo_box_itemindex := ExtractRefComboBoxReferenceIDToItemIndex(_combo_box,_ReferenceID);
if combo_box_itemindex>-1 then
result := _combo_box.Properties.Items[combo_box_itemindex]
else
result :='';
end;
function ExtractRefComboBoxReferenceIDToItemIndex(
_combo_box: TcxComboBox;_ReferenceID:integer): Integer;
var
i,j : integer;
begin
// 初始化返回值
Result := -1;
if _combo_box.Properties.Items.Count - 1 < _combo_box.ItemIndex then
Exit;
for i := 0 TO _combo_box.Properties.Items.Count - 1 DO
begin
j := Integer(_combo_box.Properties.Items.Objects[i]);
if j= _ReferenceID then
begin
Result :=i;
break;
end;
end;
end;
procedure baseDBUtilLengthLimit(_cxComboBox:TcxComboBox;_cxTextEdit:TcxTextEdit;_cxMemo:tcxMemo;MaxLength:integer);
var
prompt_text,form_caption : string;
i,my_length : integer;
begin
if _cxComboBox<>nil then
begin
i := 1;
my_length := length(_cxComboBox.Text);
end;
if _cxTextEdit<>nil then
begin
i := 2;
my_length := length(_cxTextEdit.Text);
end;
if _cxMemo<>nil then
begin
i := 3;
my_length := length(_cxMemo.Text);
end;
if my_length > MaxLength then
begin
case i of
1: _cxComboBox.Text := copy(_cxComboBox.Text,1,MaxLength);
2: _cxTextEdit.Text := copy(_cxTextEdit.Text,1,MaxLength);
3: _cxMemo.Text := copy(_cxMemo.Text,1,MaxLength);
end;
prompt_text := '文字不能超过'+inttostr(MaxLength)+'字节!';
form_caption := '警告';
baseDBUtilShowMessageEx(form_caption,prompt_text,true);
end;
end;
procedure deleteTRzStringGrid_row(TempListstring:TRzStringGrid);
var
i,j:integer;
begin
if TempListstring.Row>-1 then
begin
for j:=TempListstring.row to TempListstring.RowCount-2 do
begin
for i:=1 to TempListstring.ColCount-1 do
TempListstring.Cells[i,j] :=TempListstring.Cells[i,j+1];
end;
for i:=0 to TempListstring.ColCount-1 do
TempListstring.Cells[i,(TempListstring.RowCount-1)] :='';
if TempListstring.RowCount>2 then
TempListstring.RowCount:=TempListstring.RowCount-1;
end;
end;
function DateTimeSerialNo;
begin
result := formatdatetime('yyyymmddhhmmss',now);
end;
function GetListViewFieldSum(field_name:string;list_view:TTbListView):variant;
var
j : integer;
list_item : TListItem;
mytempvar : PBaseDBFieldValue;
mytempvar1 : variant;
begin
for j := 0 to list_view.Items.Count - 1 do
begin
list_item := list_view.Items[j];
mytempvar := TBaseDBUtility.ExtractFieldValueByFieldName(field_name,TList(list_item.Data));
mytempvar1 := mytempvar1+mytempvar.Value;
end;
result :=mytempvar1;
end;
function IsListViewHaveData(list_view:TTbListView):boolean;
var
prompt_text,form_caption : string;
begin
result := false;
if list_view.Items.Count >0 then
begin
result := true;
prompt_text := '子表有数据,如果真的要删除该项,请先删除子表!';
form_caption := '警告';
baseDBUtilShowMessageEx(form_caption,prompt_text,true);
end;
end;
function IsStateIDTrue(_ListView:TTbListView;_FieldName:string;_StateID_Value,_Return_condition:integer):boolean;
var
L_CurrentStateId : integer;
L_Data_list : TList;
L_CurrentStatedCh : string;
prompt_text : string;
form_caption : string;
begin
Result := False;
if Assigned(_ListView.Selected) then
begin
L_Data_list := TList(_ListView.Selected.Data);
L_CurrentStateId := TBaseDBUtility.ExtractValueByFieldName(_FieldName,L_Data_list);
L_CurrentStatedCh:= TBaseDBUtility.ExtractReferenceStr(_FieldName,L_Data_list);
Case L_CurrentStateId of
0:
begin
if L_CurrentStateId>_StateID_Value then
Result := true;
end;
1:
begin
if L_CurrentStateId=_StateID_Value then
Result := true;
end;
2:
begin
if L_CurrentStateId<_StateID_Value then
Result := true;
end;
end;
if Result Then
begin
prompt_text := '当前状态:['+L_CurrentStatedCh+']不能删除!';
form_caption := '警告';
baseDBUtilShowMessageEx(form_caption,prompt_text,true);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -