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

📄 fin_product_kc.pas

📁 服装厂管理系统源程序压缩包, 请耐心阅读提供的文件包含的内容
💻 PAS
字号:
unit Fin_Product_KC;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBCtrls, ComCtrls, StdCtrls, Grids, DBGrids, Mask, Buttons,
  ExtCtrls, DB, ADODB;

type
  TForm_Fin_Product_KC = class(TForm)
    PageControl1: TPageControl;
    TabSheet2: TTabSheet;
    Panel4: TPanel;
    DBGrid2: TDBGrid;
    Panel5: TPanel;
    Label22: TLabel;
    Label23: TLabel;
    Label25: TLabel;
    Bevel1: TBevel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    OKBtn: TBitBtn;
    CancelBtn: TBitBtn;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    ComboBox3: TComboBox;
    Edit2: TEdit;
    ComboBox2: TComboBox;
    TabSheet1: TTabSheet;
    Panel1: TPanel;
    ADOV_KC_Fin: TADOQuery;
    ADOV_KC_Finord_id: TStringField;
    ADOV_KC_Fincostume_name: TStringField;
    ADOV_KC_Fincust_name: TStringField;
    ADOV_KC_Finclo_name: TStringField;
    ADOV_KC_Finnum: TIntegerField;
    ADOV_KC_Finunit: TStringField;
    ADOV_KC_Finsize_1: TIntegerField;
    ADOV_KC_Finsize_2: TIntegerField;
    ADOV_KC_Finsize_3: TIntegerField;
    ADOV_KC_Finsize_4: TIntegerField;
    ADOV_KC_Finsize_5: TIntegerField;
    ADOV_KC_Finsize_6: TIntegerField;
    DS_KC_Fin_V: TDataSource;
    Label1: TLabel;
    DBEdit1: TDBEdit;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Label3: TLabel;
    DBEdit3: TDBEdit;
    Label4: TLabel;
    DBEdit4: TDBEdit;
    Label5: TLabel;
    DBEdit5: TDBEdit;
    Label6: TLabel;
    DBEdit6: TDBEdit;
    ComboBox_ordid: TComboBox;
    ComboBox_custname: TComboBox;
    ComboBox_costume: TComboBox;
    ComboBox_cloth: TComboBox;
    Label16: TLabel;
    Label11: TLabel;
    Label10: TLabel;
    Label9: TLabel;
    Label8: TLabel;
    Label7: TLabel;
    DBEdit7: TDBEdit;
    DBEdit8: TDBEdit;
    DBEdit9: TDBEdit;
    DBEdit10: TDBEdit;
    DBEdit11: TDBEdit;
    DBEdit12: TDBEdit;
    Bevel2: TBevel;
    Label17: TLabel;
    adoQ_temp: TADOQuery;
    Panel2: TPanel;
    RefreshBtn: TBitBtn;
    DetailBtn: TBitBtn;
    LocateBtn: TBitBtn;
    BtnExport: TBitBtn;
    ExtBtn: TBitBtn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure DetailBtnClick(Sender: TObject);
    procedure RefreshBtnClick(Sender: TObject);
    procedure LocateBtnClick(Sender: TObject);
    procedure CancelBtnClick(Sender: TObject);
    procedure OKBtnClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure DBGrid2DblClick(Sender: TObject);
    procedure BtnExportClick(Sender: TObject);
  private
    { Private declarations }
    procedure refreshdb;
    procedure add_combox_item;
  public
    { Public declarations }
  end;

var
  Form_Fin_Product_KC: TForm_Fin_Product_KC;

implementation
uses sharevar, sharefun, data, Main;

{$R *.dfm}

procedure TForm_Fin_Product_KC.refreshdb;
begin
  with ADOV_KC_Fin do
  begin
    sql.Strings[1]:='';
    sql.Strings[2]:='order by clo_name,cust_name,ord_id';
    try
      execsql;
      open;
    except
      msgErr(handle,'刷新数据库失败!(View_RK_Fin)');
    end;
  end;
end;

procedure TForm_Fin_Product_KC.add_combox_item;
begin
  with adoQ_temp do
  begin
    close; sql.Clear;
    sql.Add('select ord_id,costume_name from order_msg');
    open; First;
    ComboBox_ordid.Clear;
    ComboBox_costume.Clear;
    ComboBox_ordid.Items.Add(' ');
    ComboBox_costume.Items.Add(' ');
    while not eof do
    begin
      ComboBox_ordid.Items.Add(fieldvalues['ord_id']);
      ComboBox_costume.Items.Add(fieldvalues['costume_name']);
      next;
    end;

    close; sql.Clear;
    sql.Add('select cust_name from customer');
    open ; First;
    ComboBox_custname.Items.Clear;
    ComboBox_custname.Items.Add(' ');
    while not eof do
    begin
      ComboBox_custname.Items.Add(fieldvalues['cust_name']);
      next;
    end;

    close; sql.Clear;
    sql.Add('select clo_name from clothing');
    open ; First;
    ComboBox_cloth.Items.Clear;
    ComboBox_cloth.Items.Add(' ');
    while not eof do
    begin
      ComboBox_cloth.Items.Add(fieldvalues['clo_name']);
      next;
    end;
    close; 
  end;
end;

procedure TForm_Fin_Product_KC.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  if ADOV_KC_Fin.Active then ADOV_KC_Fin.Close;
  action:=cafree;
end;

procedure TForm_Fin_Product_KC.DetailBtnClick(Sender: TObject);
begin
  if PageControl1.ActivePageIndex<>1 then PageControl1.ActivePageIndex:=1;
end;

procedure TForm_Fin_Product_KC.RefreshBtnClick(Sender: TObject);
begin
  if not ADOV_KC_Fin.Active then exit;
  refreshdb;
end;

procedure TForm_Fin_Product_KC.LocateBtnClick(Sender: TObject);
begin
  if PageControl1.ActivePageIndex<>0 then PageControl1.ActivePageIndex:=0;
  if not panel5.Visible then
  begin
    ComboBox_ordid.Text:='';
    ComboBox_custname.text:='';
    ComboBox_costume.text:='';
    ComboBox_cloth.ItemIndex:=0;
    edit1.Clear; edit2.Clear;
    panel5.Enabled:=true;
    panel5.Visible:=true;
    ExtBtn.Cancel:=false;
    CancelBtn.cancel:=true;
  end;
end;

procedure TForm_Fin_Product_KC.CancelBtnClick(Sender: TObject);
begin
    panel5.Visible:=false;
    panel5.Enabled:=false;
    ExtBtn.Cancel:=true;
    CancelBtn.cancel:=false;
end;

procedure TForm_Fin_Product_KC.OKBtnClick(Sender: TObject);
label Get_sqltext;
var
tmpnum, ordid, custname, clothing,
costume, strwhere: string;
Len_tmpnum: integer;
begin
  ordid:=trim(ComboBox_ordid.text);
  custname:=trim(ComboBox_custname.text);
  costume:=trim(ComboBox_costume.text);
  clothing:=trim(ComboBox_cloth.text);

  tmpnum:=Getquery_char(ComboBox1.Text,trim(Edit1.Text),trim(ComboBox2.Text),ComboBox3.Text,trim(Edit2.Text),'num');

  //得到查询的条件语句
  begin
        if ordid<>'' then ordid:='(ord_id = '+''''+ordid+''''+')';
        if custname<>'' then custname:='(cust_name = '+''''+custname+''''+')';
        if clothing<>'' then clothing:='(clo_name = '+''''+clothing+''''+')';
        if costume<>'' then costume:='(costume_name = '+''''+costume+''''+')';

        if ordid<>'' then
        begin
          strwhere:='where '+ordid;
          if custname<>'' then strwhere:=strwhere+' and '+custname;
          if clothing<>'' then strwhere:=strwhere+' and '+clothing;
          if costume<>'' then strwhere:=strwhere+' and '+costume;
          goto Get_sqltext;
        end;

        if custname<>'' then
        begin
          strwhere:='where '+custname;
          if ordid<>'' then strwhere:=strwhere+' and '+ordid;
          if clothing<>'' then strwhere:=strwhere+' and '+clothing;
          if costume<>'' then strwhere:=strwhere+' and '+costume;
          goto Get_sqltext;
        end;

        if clothing<>'' then
        begin
          strwhere:='where '+clothing;
          if custname<>'' then strwhere:=strwhere+' and '+custname;
          if ordid<>'' then strwhere:=strwhere+' and '+ordid;
          if costume<>'' then strwhere:=strwhere+' and '+costume;
          goto Get_sqltext;
        end;

        if costume<>'' then
        begin
          strwhere:='where '+costume;
          if ordid<>'' then strwhere:=strwhere+' and '+ordid;
          if custname<>'' then strwhere:=strwhere+' and '+custname;
          if clothing<>'' then strwhere:=strwhere+' and '+clothing;
          goto Get_sqltext;
        end;
             
        Get_sqltext:
        if (ordid<>'') or (custname<>'') or (clothing<>'') or (costume<>'')
        then strwhere:=(strwhere + tmpnum)
        else if tmpnum<>'' then
        begin
          Len_tmpnum:=length(tmpnum);
          strwhere:='where '+copy(tmpnum,5,Len_tmpnum);
        end;
  end;
//  if strwhere='' then exit;
  with ADOV_KC_Fin do
  begin
      try
         close;
         sql.Strings[1]:=strwhere;
         sql.Strings[2]:='order by clo_name,cust_name,ord_id';
         strwhere:=sql.Text;
         execsql;
         open;
      except
         MsgErr(handle,'数据库检索失败(Fin_product_KC_V)!');
         refreshdb;
         exit;
      end;
      BtnExport.Enabled:=recordcount>0;
  end;               
  panel5.Visible:=false;
  panel5.Enabled:=false;
  ExtBtn.Cancel:=true;
  CancelBtn.cancel:=false;    
end;

procedure TForm_Fin_Product_KC.FormShow(Sender: TObject);
begin
  add_combox_item;
end;

procedure TForm_Fin_Product_KC.FormCreate(Sender: TObject);
begin
    ComboBox_ordid.Text:='';
    ComboBox_custname.text:='';
    ComboBox_costume.text:='';
    ComboBox_cloth.ItemIndex:=0;
end;

procedure TForm_Fin_Product_KC.Edit1KeyPress(Sender: TObject;
  var Key: Char);
begin
  if not (key in ['0'..'9',#13, #8]) then abort;
end;

procedure TForm_Fin_Product_KC.DBGrid2DblClick(Sender: TObject);
begin
  if not ADOV_KC_Fin.Active then exit;
  if ADOV_KC_Fin.RecordCount<=0 then exit;
  PageControl1.ActivePageIndex:=1;
end;

procedure TForm_Fin_Product_KC.BtnExportClick(Sender: TObject);
begin
  Form_main.WriteIntoExcel(DBGrid2,datetostr(date),'成品库存信息报表');
end;

end.

⌨️ 快捷键说明

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