unit U_ZJManage;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, cxStyles, cxCustomData, cxGraphics,
  cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxTextEdit,
  cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxClasses, cxControls, cxGridCustomView, cxGrid, MovePanel, ADODB;

type
  TfrmZJManage = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    ScrollBox1: TScrollBox;
    SpeedButton13: TSpeedButton;
    SpeedButton14: TSpeedButton;
    SpeedButton15: TSpeedButton;
    SpeedButton16: TSpeedButton;
    SpeedButton17: TSpeedButton;
    SpeedButton18: TSpeedButton;
    SpeedButton19: TSpeedButton;
    SpeedButton20: TSpeedButton;
    SpeedButton21: TSpeedButton;
    SpeedButton22: TSpeedButton;
    SpeedButton23: TSpeedButton;
    SpeedButton24: TSpeedButton;
    SpeedButton25: TSpeedButton;
    SpeedButton26: TSpeedButton;
    SpeedButton27: TSpeedButton;
    SpeedButton28: TSpeedButton;
    SpeedButton29: TSpeedButton;
    SpeedButton30: TSpeedButton;
    SpeedButton31: TSpeedButton;
    SpeedButton32: TSpeedButton;
    SpeedButton33: TSpeedButton;
    SpeedButton34: TSpeedButton;
    SpeedButton35: TSpeedButton;
    SpeedButton36: TSpeedButton;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    MovePanel1: TMovePanel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Edit50: TEdit;
    Button4: TButton;
    Button5: TButton;
    Edit51: TEdit;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    tv2CDType: TcxGridDBColumn;
    tv2CDWZ: TcxGridDBColumn;
    v2Column2: TcxGridDBColumn;
    Tv2CDQty: TcxGridDBColumn;
    Tv2CDReason: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    cxStyleRepository5: TcxStyleRepository;
    cxStyle6: TcxStyle;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxGrid3: TcxGrid;
    Tv3: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    Panel5: TPanel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    SpeedButton12: TSpeedButton;
    SpeedButton49: TSpeedButton;
    Button6: TButton;
    Panel6: TPanel;
    Panel1: TPanel;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Edit12: TEdit;
    Edit13: TEdit;
    Panel2: TPanel;
    Edit14: TEdit;
    Edit15: TEdit;
    Edit16: TEdit;
    Edit17: TEdit;
    Edit18: TEdit;
    Edit19: TEdit;
    Edit20: TEdit;
    Edit21: TEdit;
    Edit22: TEdit;
    Edit23: TEdit;
    Edit24: TEdit;
    Edit25: TEdit;
    Panel3: TPanel;
    Edit26: TEdit;
    Edit27: TEdit;
    Edit28: TEdit;
    Edit29: TEdit;
    Edit30: TEdit;
    Edit31: TEdit;
    Edit32: TEdit;
    Edit33: TEdit;
    Edit34: TEdit;
    Edit35: TEdit;
    Edit36: TEdit;
    Edit37: TEdit;
    Panel4: TPanel;
    Edit38: TEdit;
    Edit39: TEdit;
    Edit40: TEdit;
    Edit41: TEdit;
    Edit42: TEdit;
    Edit43: TEdit;
    Edit44: TEdit;
    Edit45: TEdit;
    Edit46: TEdit;
    Edit47: TEdit;
    Edit48: TEdit;
    Edit49: TEdit;
    Panel7: TPanel;
    Panel10: TPanel;
    Button7: TButton;
    Button8: TButton;
    Panel8: TPanel;
    Edit52: TEdit;
    Edit53: TEdit;
    Edit54: TEdit;
    Edit55: TEdit;
    Edit56: TEdit;
    Edit57: TEdit;
    Edit58: TEdit;
    Edit59: TEdit;
    Edit60: TEdit;
    Edit61: TEdit;
    Edit62: TEdit;
    Edit63: TEdit;
    Edit64: TEdit;
    Label7: TLabel;
    Button9: TButton;
    Label8: TLabel;
    ComboBox1: TComboBox;
    ADOQueryTemp: TADOQuery;
    procedure Edit38Click(Sender: TObject);
    procedure Edit64Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton12Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure SpeedButton49Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }
    procedure ClearSpenndHit();
    procedure VisbleControl(Panel55:TWinControl;XS:Boolean;SXCount:Integer);
    function ChkEditNULL(panel55:TWinControl):Boolean;
  public
    { Public declarations }
  end;

var
  frmZJManage: TfrmZJManage;

implementation
uses
U_DataLink,U_Fun,U_ZDYHelp,U_iniParam,AES,ElAES;

{$R *.dfm}

procedure TfrmZJManage.Edit38Click(Sender: TObject);
begin
  if Trim(TcxTextEdit(Sender).Text)='' then
  begin
    TcxTextEdit(Sender).Text:='√';
  end else
  begin
    TcxTextEdit(Sender).Text:='';
  end;
end;

procedure TfrmZJManage.Edit64Click(Sender: TObject);
var
  i:Integer;
begin
  Panel5.Visible:=True;
  with Panel5 do
  begin
    for i:=0 to ControlCount-1 do
    begin
      if Controls[i] is TSpeedButton then
      begin
        TSpeedButton(Controls[i]).Hint:=Trim(TEdit(Sender).Name);
      end;
    end;
  end;
end;
procedure TfrmZJManage.ClearSpenndHit();
var
  i:Integer;
begin
  with Panel5 do
  begin
    for i:=0 to ControlCount-1 do
    begin
      if Controls[i] is TSpeedButton then
      begin
        TSpeedButton(Controls[i]).Hint:='';
      end;
    end;
  end;
end;
procedure TfrmZJManage.VisbleControl(Panel55:TWinControl;XS:Boolean;SXCount:Integer);
var
  i:Integer;
begin
  with Panel55 do
  begin
    for i:=0 to SXCount-1 do
    begin
      Controls[i].Visible:=XS;
    end;
  end;
end;

procedure TfrmZJManage.SpeedButton1Click(Sender: TObject);
var
  fsj:string;
begin
  fsj:=Trim(TSpeedButton(Sender).Hint);
  if Trim(fsj)='' then Exit;
  fsj:=Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text);
  TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text:=fsj+Trim(TSpeedButton(Sender).Caption);
  TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll;
end;

procedure TfrmZJManage.SpeedButton12Click(Sender: TObject);
var
  fsj:string;
begin
  fsj:=Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text);
  if Trim(fsj)='' then Exit;
  TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text:=Copy(fsj,1,Length(fsj)-1);
  TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll;
end;

procedure TfrmZJManage.Button2Click(Sender: TObject);
begin
  Panel7.Visible:=True;
end;

procedure TfrmZJManage.Button8Click(Sender: TObject);
begin
  Panel7.Visible:=False;
  Edit64.Text:='';
  ComboBox1.ItemIndex:=-1;
  ComboBox1.Enabled:=False;
  VisbleControl(Panel8,False,Panel8.ControlCount);
end;

procedure TfrmZJManage.Button9Click(Sender: TObject);
var
  mm,mm2:string;
begin
  with ADOQueryTemp do
  begin
    sql.Clear;
    sql.add('SELECT userid,username,password FROM SY_User WHERE userid='+''''+trim(DCode)+'''');
    Open;
    mm:=Trim(Fields[2].AsString);
    if Trim(mm)<>'' then
      mm2:=Trim(DecryptString(Trim(mm),'ljb^0122!@#*&^%$',kb128))
    else
    begin
      Application.MessageBox('密码不能为空！','提示',0);
      Exit;
    end;
    close;
  end;

  if (mm2=trim(Edit64.text))  then
  begin
    ComboBox1.Enabled:=True;
    ComboBox1.SetFocus;
    ComboBox1.DroppedDown:=True;
    ClearSpenndHit();
  end
  else
    Application.MessageBox('密码错误！', '信息提示', MB_OK or MB_ICONinformation);
end;

procedure TfrmZJManage.SpeedButton49Click(Sender: TObject);
begin
  Panel5.Visible:=false;
end;

procedure TfrmZJManage.ComboBox1Change(Sender: TObject);
var
  i,FCont:Integer;
begin
  if Trim(ComboBox1.Text)='' then
  begin
    VisbleControl(Panel8,False,Panel8.ControlCount);
  end else
  begin
    VisbleControl(Panel8,False,Panel8.ControlCount);
    FCont:=StrToInt(ComboBox1.Text);
    VisbleControl(Panel8,True,FCont);
  end;

end;

procedure TfrmZJManage.Button7Click(Sender: TObject);
begin
  if Trim(ComboBox1.Text)='' then
  begin
    Application.MessageBox('分切个数未选择！','提示',0);
    Exit;
  end;
  if ChkEditNULL(Panel8)=False then
  begin
    Application.MessageBox('数据不全，请填写完整！','提示',0);
    Exit;
  end;
  Panel7.Visible:=False;
  VisbleControl(Panel1,False,Panel1.ControlCount);
  VisbleControl(Panel1,True,StrToInt(ComboBox1.Text));
  VisbleControl(Panel2,False,Panel2.ControlCount);
  VisbleControl(Panel2,True,StrToInt(ComboBox1.Text));
  VisbleControl(Panel3,False,Panel3.ControlCount);
  VisbleControl(Panel3,True,StrToInt(ComboBox1.Text));
  VisbleControl(Panel4,False,Panel4.ControlCount);
  VisbleControl(Panel4,True,StrToInt(ComboBox1.Text));
  ComboBox1.ItemIndex:=-1;
  VisbleControl(Panel8,False,Panel8.ControlCount);
  Edit64.Text:='';

end;

function TfrmZJManage.ChkEditNULL(panel55:TWinControl):Boolean;
var
  i:Integer;
begin
  Result:=False;
  with panel55 do
  begin
    for i:=0 to panel55.ControlCount-1 do
    begin
      if Controls[i].Visible=True then
      begin
        if Trim(TEdit(Controls[i]).Text)='' then
        begin
          Result:=False;
          Break;
        end else
        begin
          Result:=True;
        end;
      end;

    end;
  end;

end;

end.
