⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zfrm_projectnewu.pas

📁 专业的评标管理系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
 输入    :
 输出    :
 描述    :
}
var
  i:integer;
  FDic:TDictionary;//字典纪录
  Str_Id:string;
begin

      for i:=0 to FDicList.Count-1 do
      begin
           FDic:=PDic(FDicList.Items[i])^;
           case FDic.ComType of
           0:
           begin
                  Query1.ParamByName('P'+FDic.FFieldName).AsString:=Trim(TEdit(FCompentList.Items[i]).Text);
           end;
           1:
           begin
                Query1.ParamByName('P'+FDic.FFieldName).AsString:=TComboBox(FCompentList.Items[i]).Text;
           end;
           2:
           begin
               Query1.ParamByName('P'+FDic.FFieldName).AsDateTime:=TDateTimePicker(FCompentList.Items[i]).DateTime;
           end;
           3:
           begin
                Query1.ParamByName('P'+FDic.FFieldName).AsString:=TMemo(FCompentList.Items[i]).Text;
           end;

           end
      end;
      if FIfInsert then
      begin
          Str_id:='ge_pi_id';
          Query1.ParamByName('PG_PI_ID').AsInteger:=zh_GetNewIdF(Str_id);
          Query1.ParamByName('Ppi_statetype').AsString:='立项';
          Query1.ParamByName('Ppi_locktype').AsString:='未锁定';
      end




end;

 //----------------------自定义函数 (end)---------------------//
procedure Tzfrm_ProjectNew.Button1Click(Sender: TObject);
begin
  // 确定
   if   SaveData then
   begin

     Application.MessageBox('保存成功','提示信息', MB_Ok+MB_ICONASTERISK);

     Close ;
   end;
  //
end;

procedure Tzfrm_ProjectNew.Button2Click(Sender: TObject);
begin
  // 取消
  Close ;
  
  //
end;

procedure Tzfrm_ProjectNew.FormShow(Sender: TObject);
var
   StrSql:String;
   i:integer;
   FDic:TDictionary; //数据字典项
begin
     //向Combobox填值
     AddListBox(ComboBox1,'Select BT_NAME from TM_PI_BIDTYPEA') ;
     AddListBox(ComboBox2,'Select ST_NAME from TM_PI_SENDTYPEA') ;
     AddListBox(ComboBox3,'Select PT_NAME from TM_PI_PROJECTTYPEA') ;
     if (ComboBox1.Items.Count=0) or (ComboBox2.Items.Count=0) or (ComboBox3.Items.Count=0) then
     begin
         Application.MessageBox('请您首先设置工程参数','提示信息', MB_OK+MB_ICONASTERISK);
         zfrm_ProjectSetup.ShowModal;
         AddListBox(ComboBox1,'Select BT_NAME from TM_PI_BIDTYPEA') ;
         AddListBox(ComboBox2,'Select ST_NAME from TM_PI_SENDTYPEA') ;
         AddListBox(ComboBox3,'Select PT_NAME from TM_PI_PROJECTTYPEA') ;


     end;
     //清空
     Pro_Clear(Self);
     //判断是新增,还是编辑
     if  Trim(Caption)='新建工程' then
     begin
          //新增
          FIfInsert:=True;
          Pro_Clear(Self);
          ComboBox1.ItemIndex:=0;
          ComboBox2.ItemIndex:=0;
          ComboBox3.ItemIndex:=0;
          FLxDate:=Now;
     end
     else
     begin
         //编辑
         FIfInsert:=False;
         with Query1 do
         begin
             StrSql:='Select * From TM_PROJECTINFO where PI_CODE='+''''+Trim(zh_ci_codeS)+'''';
             Close;
             Sql.Clear;
             Sql.Add(StrSql);
             Prepare;
             Open;
             FLXDate:=FieldByName('PI_DATETIME').AsDateTime;
            // ShowMessage('Error');
             //向各个各个控件写入值
             for i:= 0 to FDicList.Count-1 do
             begin
                 FDic:=PDic(FDicList.Items[i])^;
                 case FDic.ComType of
                 0:
                 begin
                      TEdit(FCompentList.Items[i]).Text:=Query1.FieldbyName(FDic.FFieldName).AsString;
                 end;
                 1:
                 begin
                      TComboBox(FCompentList.Items[i]).ItemIndex:=TComboBox(FCompentList.Items[i]).Items.IndexOf(Query1.FieldbyName(FDic.FFieldName).AsString);
                 end;
                 2:
                 begin
                     TDateTimePicker(FCompentList.Items[i]).DateTime:=Query1.FieldbyName(FDic.FFieldName).AsDateTime;

                 end;
                 3:
                 begin
                      TMemo(FCompentList.Items[i]).Text:=Query1.FieldbyName(FDic.FFieldName).AsString;
                 end;

                 end
             end;

         end;
     end;
end;

procedure Tzfrm_ProjectNew.BitBtn1Click(Sender: TObject);
begin
     Pro_Clear(Self);
end;

procedure Tzfrm_ProjectNew.FormCreate(Sender: TObject);
var
  FPDic:PDic;
begin
    //0 Tedit 1:TComboBox 2:TdatePicker 3:tmemo
    //将数据字典写入一个 FDicList
    //同时将每个字段的对应 控件写入 FCompentList
    FCompentList:=TList.Create;
    FDicList:=TList.Create;
    New(FPDic);
    FPDic^.FIsNull:=False;
    FPDic^.FFieldName:='pi_code';
    FPDic^.ChinName:='工程代码';
    FPDic^.ComType:=0;
    FDicList.Add(FPDic);
    FCompentList.Add(Edit1);
    //创建新的字典项目
    New(FPDic);
    FPDic^.FIsNull:=False;
    FPDic^.FFieldName:='pi_name';
    FPDic^.ChinName:='工程名称';
    FPDic^.ComType:=0;
    FDicList.Add(FPDic);
    FCompentList.Add(Edit2);

    New(FPDic);
    FPDic^.FIsNull:=False;
    FPDic^.FFieldName:='pi_bidunit';
    FPDic^.ChinName:='招标单位';
    FPDic^.ComType:=0;
    FDicList.Add(FPDic);
    FCompentList.Add(Edit3);

    New(FPDic);
    FPDic^.FIsNull:=True;
    FPDic^.FFieldName:='pi_bidtype';
    FPDic^.ChinName:='招标形式';
    FPDic^.ComType:=1;
    FDicList.Add(FPDic);
    FCompentList.Add(combobox1);

    New(FPDic);
    FPDic^.FIsNull:=True;
    FPDic^.FFieldName:='pi_cost';
    FPDic^.ChinName:='标底造价';
    FPDic^.ComType:=0;
    FDicList.Add(FPDic);
    FCompentList.Add(Edit4);

    New(FPDic);
    FPDic^.FIsNull:=False;
    FPDic^.FFieldName:='pi_sendtype';
    FPDic^.ChinName:='发包方式';
    FPDic^.ComType:=1;
    FDicList.Add(FPDic);
    FCompentList.Add(combobox2);

    New(FPDic);
    FPDic^.FIsNull:=true;
    FPDic^.FFieldName:='pi_timelimit';
    FPDic^.ChinName:='标底工期';
    FPDic^.ComType:=0;
    FDicList.Add(FPDic);
    FCompentList.Add(Edit5);

    New(FPDic);
    FPDic^.FIsNull:=False;
    FPDic^.FFieldName:='pi_projecttype';
    FPDic^.ChinName:='工程类型';
    FPDic^.ComType:=1;
    FDicList.Add(FPDic);
    FCompentList.Add(combobox3);

    New(FPDic);
    FPDic^.FIsNull:=true;
    FPDic^.FFieldName:='pi_quality';
    FPDic^.ChinName:='工程质量';
    FPDic^.ComType:=0;
    FDicList.Add(FPDic);
    FCompentList.Add(Edit6);

    New(FPDic);
    FPDic^.FIsNull:=False;
    FPDic^.FFieldName:='pi_opendate';
    FPDic^.ChinName:='开标时间';
    FPDic^.ComType:=2;
    FDicList.Add(FPDic);
    FCompentList.Add(Datetimepicker1);

    New(FPDic);
    FPDic^.FIsNull:=true;
    FPDic^.FFieldName:='PI_BUILDAREA';
    FPDic^.ChinName:='建筑面积';
    FPDic^.ComType:=0;
    FDicList.Add(FPDic);
    FCompentList.Add(Edit7);

    New(FPDic);
    FPDic^.FIsNull:=true;
    FPDic^.FFieldName:='pi_describe';
    FPDic^.ChinName:='工程描述';
    FPDic^.ComType:=3;
    FDicList.Add(FPDic);
    FCompentList.Add(Memo1);
end;

procedure Tzfrm_ProjectNew.FormDestroy(Sender: TObject);
var
   i:integer;
begin
    //释放数据字典
    for i:=0 to FDicList.Count-1 do
    begin
        Freemem(FDicList.Items[i]);
    end;
    FDicList.Free;
    FCompentList.Free;

end;

procedure Tzfrm_ProjectNew.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   //处理按键,进行回车跳转
   if Self.ActiveControl<>Memo1 then
   begin
       If (Key = Vk_Return)  Then
       Begin
          Perform(WM_NextDlgCtl, 0, 0);
          key := vk_Tab;
       End;
   end;

end;

procedure Tzfrm_ProjectNew.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
    //判断输入的是否位数字
    if (not (Key in PriNumeric)) and (Key<>#8) then

        Key:=#0;
    if (Pos('.',(SenDer As TEdit).Text)>0) and (Key='.') then
    begin
        Key:=#0;
    end;
end;

procedure Tzfrm_ProjectNew.Edit4Exit(Sender: TObject);
 var
   fmtStr:String;
begin
     if Trim((Sender As TEdit).Text)='' then (Sender As TEdit).Text := '0';


      if (Sender = Edit5) then
         fmtStr:='0'
      else
         fmtStr:='0.00';

      (Sender As TEdit).Text:=FormatFloat(fmtStr,StrToFloat((Sender As TEdit).Text))
end;

procedure Tzfrm_ProjectNew.FormActivate(Sender: TObject);
begin
         if (ComboBox1.Items.Count=0) or (ComboBox1.Items.Count=0) or (ComboBox1.Items.Count=0) then
              PostMessage(Handle,WM_CLOSE,0,0);
end;

procedure Tzfrm_ProjectNew.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
    if ( (Key in InValideChar))  then
    begin
        Application.MessageBox(PChar('不能输入['+Key+']'),'提示信息', MB_OK+MB_ICONASTERISK);
        Key:=#0;
    end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -