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

📄 cxunit.~pas

📁 帮朋友编写的幼儿教育的管理平台
💻 ~PAS
字号:
unit CXUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, DB, ExtCtrls, DBCtrls, Mask, ExcelXP,
  OleServer;

type
  TCX_Form = class(TForm)
    DBGrid1: TDBGrid;
    Button1: TButton;
    DD_List: TComboBox;
    DataSource1: TDataSource;
    Button2: TButton;
    ZHIXIAN: TGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label3: TLabel;
    L_SX: TEdit;
    L_SY: TEdit;
    L_L: TEdit;
    L_D: TEdit;
    L_DS: TEdit;
    My_Image: TImage;
    Left_Wall: TImage;
    Button3: TButton;
    DS_Image: TGroupBox;
    D_Image: TImage;
    Label2: TLabel;
    Label4: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    BLJ_CJLD: TDBText;
    DBNavigator1: TDBNavigator;
    BLJ_CJRD: TDBText;
    BLKD: TDBText;
    BLJKD: TDBText;
    GDKD: TDBText;
    L_CJ: TDBText;
    R_CJ: TDBText;
    ExcelWorksheet1: TExcelWorksheet;
    ExcelWorkbook1: TExcelWorkbook;
    ExcelApplication1: TExcelApplication;
    Button4: TButton;
    Pic_Name: TDBText;
    Button5: TButton;
    DD_06_Image: TGroupBox;
    Label1: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    GDZC_06: TDBText;
    BLZK_06: TDBText;
    BLKD_06: TDBText;
    BLGD_06: TDBText;
    Label15: TLabel;
    YTGD_06: TDBText;
    Label16: TLabel;
    BLGD: TDBText;
    YTGD: TDBText;
    Label17: TLabel;
    HXSR_06: TDBText;
    Image_D_06: TImage;
    Label18: TLabel;
    XC: TDBText;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
    procedure Button4Click(Sender: TObject);
    procedure DD_ListChange(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  CX_Form: TCX_Form;

implementation

uses DataM;

{$R *.dfm}

procedure TCX_Form.Button1Click(Sender: TObject);
Var SQLString:String;
Var DS_NUM_Find :integer ;
begin
{DM.DD_Query.Close ;
DM.DD_Query.SQL.Clear ;
SQLString := 'select * from OrderTbl where OrderNum='''+DD_List.Text+''' order by NUM,Sub_Num' ;
DM.DD_Query.SQL.Add(SQLString) ;
DM.DD_Query.Open ;
if DM.DD_Query.FieldByName('XC').AsString='06' then
begin
  DM.DD_Query.First ;
  DBGrid1.Refresh ;

  DD_06_Image.Visible := True ;
  DD_06_Image.Caption := '第'+DM.DD_Query.FieldByName('NUM').AsString+'段 第'+DM.DD_Query.FieldByName('Sub_NUM').AsString +'节 (06)型材切割说明' ;
  if ((DM.DD_Query.FieldByName('ClassType').AsString<>'L') and (DM.DD_Query.FieldByName('XC').AsString='06')) then
  begin
    HXSR_06.DataField := 'SR' ;
    GDZC_06.DataField := '' ;
    BLZK_06.DataField := '' ;
    BLKD_06.DataField := '' ;
  end
  else
  begin
    GDZC_06.DataField := 'GDZC' ;
    BLZK_06.DataField := 'BLZK' ;
    BLKD_06.DataField := 'BLKD' ;
  end ;
  BLGD_06.DataField := 'BLGD' ;
  YTGD_06.DataField := 'YTGD' ;
end
else
begin
  Button4.Click ;
  DM.DD_Query.First ;
  DBGrid1.Refresh ;
///
  DS_Image.Caption := '第'+DM.DD_Query.FieldByName('NUM').AsString+'段 第'+DM.DD_Query.FieldByName('Sub_NUM').AsString +'节' ;
  DS_Image.Visible := True ;
  My_Image.Visible := False ;
  BLJ_CJLD.DataField := 'BLJ_CJLD' ;
  BLJ_CJRD.DataField := 'BLJ_CJRD' ;
  L_CJ.DataField := 'L_CJ' ;
  R_CJ.DataField := 'R_CJ' ;
  BLKD.DataField := 'BLKD' ;
  BLJKD.DataField := 'BLJKD' ;
  BLGD.DataField := 'BLGD' ;
  YTGD.DataField := 'YTGD' ;
  if  (DM.DD_Query.FieldByName('ClassType').AsString ='L') then    GDKD.DataField := 'LGDKD' else GDKD.DataField := 'GDKD' ;
  Pic_Name.DataField := 'Pic_Name' ;
  D_Image.Picture.LoadFromFile(GetCurrentDir+'\IMAGES\'+DM.DD_Query.FieldByName('Pic_Name').AsString+'.bmp') ;
  D_Image.Show ;//
end ;  }
end;

procedure TCX_Form.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//DM.DD_Query.Close ;
end;

procedure TCX_Form.FormShow(Sender: TObject);
begin
{DM.DD_Query.Close ;
DM.DD_Query.SQL.Clear ;
DM.DD_Query.SQL.Add('select Distinct OrderNum from OrderTbl order by OrderNum') ;
DM.DD_Query.Open ;
if DM.DD_Query.RecordCount > 0 then
begin
  DM.DD_Query.First ;
  DD_List.Items.Clear ;
  while not DM.DD_Query.Eof do
  begin
    DD_List.Items.Add(DM.DD_Query.FieldByName('OrderNum').AsString );
    DM.DD_Query.Next ;
  end ;
  DD_List.ItemIndex := 1 ;
end ;
DM.DD_Query.Close ;     }
end;

procedure TCX_Form.Button2Click(Sender: TObject);
Var X1,X2,Y1,Y2:integer ;
Var L,D,Q,D_Total:Double ;
begin
{DS_Image.Visible :=False ;
DD_06_Image.Visible := False ;
My_Image.Visible := true ;
My_Image.Canvas.pen.width := 2 ;
if DM.DD_Query.RecordCount >0 then
begin
DM.DD_Query.First ;
D_Total:= 0.00 ;
while (not DM.DD_Query.Eof)  do
begin
  X1:=StrToInt(L_SX.Text) ;
  Y1:=StrToInt(L_SY.Text) ;
  L:=DM.DD_Query.FieldByName('BLKD').AsFloat  ;
  D:=DM.DD_Query.FieldByName('JD').AsFloat ;
//  DS:=StrToInt(L_DS.Text) ;
  D_Total:=D_Total+D ;
  Q:=D_Total*Pi/180 ;
  X2:=X1+Round(L*Cos(Q)/10) ;
  Y2:=Y1-Round(L*Sin(Q)/10) ;
  //Draw
  My_Image.Canvas.MoveTo(X1,Y1);
  My_Image.Canvas.LineTo(X2,Y2);

  L_SX.Text :=IntToStr(X2) ;
  L_SY.Text :=IntToStr(Y2) ;
  DM.DD_Query.Next ;
end ;
end ;
//调用更新完成切角说明
 }
end;

procedure TCX_Form.Button3Click(Sender: TObject);
var map:Tbitmap;
Var idx:integer ;
    SQLString :String ;
begin
{ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=True;
ExcelApplication1.Caption := '金和阳光无框门窗数据计算结果输出'+DD_List.Text ;

ExcelApplication1.Workbooks.Open(GetCurrentDir+'\shuchu.xls',EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,0) ;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets[1] as _WorkSheet);
DM.DD_Query.First ;
FOR idx := 1 to DM.DD_Query.RecordCount DO
BEGIN
if (DM.DD_Query.FieldByName('XC').AsString ='06') then
begin
  ExcelWorksheet1.Cells.Item[3+idx,1] := IntToStr(idx) ;
  ExcelWorksheet1.Cells.Item[3+idx,2] := DM.DD_Query.FieldByName('OrderNum').AsString ;
  ExcelWorksheet1.Cells.Item[3+idx,3]:= DM.DD_Query.FieldByName('Num').AsString  ;
//  ExcelWorksheet1.Cells.Item[3+idx,9]:= DM.DD_Query.FieldByName('BLJKD').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,10]:= DM.DD_Query.FieldByName('BLKD').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,11]:= DM.DD_Query.FieldByName('BLGD').AsString  ;
  if  (DM.DD_Query.FieldByName('ClassType').AsString ='L') then
  begin
    ExcelWorksheet1.Cells.Item[3+idx,12]:= DM.DD_Query.FieldByName('LGDKD').AsString  ;
    ExcelWorksheet1.Cells.Item[3+idx,14]:= '直线' ;
  end
  else
  begin
    ExcelWorksheet1.Cells.Item[3+idx,12]:= DM.DD_Query.FieldByName('GDKD').AsString  ;
    if (DM.DD_Query.FieldByName('ClassType').AsString ='W') then
      ExcelWorksheet1.Cells.Item[3+idx,14]:= '外凸'
    else
      ExcelWorksheet1.Cells.Item[3+idx,14]:= '内凹' ;
  end ;
  ExcelWorksheet1.Cells.Item[3+idx,13]:= DM.DD_Query.FieldByName('SR').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,15]:= DM.DD_Query.FieldByName('XC').AsString  ;
end
else
begin
  ExcelWorksheet1.Cells.Item[3+idx,1] := IntToStr(idx) ;
  ExcelWorksheet1.Cells.Item[3+idx,2] := DM.DD_Query.FieldByName('OrderNum').AsString ;
  ExcelWorksheet1.Cells.Item[3+idx,3]:= DM.DD_Query.FieldByName('Num').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,4]:= DM.DD_Query.FieldByName('Sub_Num').AsString  ;
  if DM.DD_Query.FieldByName('L_CJ').AsString ='L' then  ExcelWorksheet1.Cells.Item[3+idx,5]:= '不切' ;
  if DM.DD_Query.FieldByName('L_CJ').AsString ='N' then  ExcelWorksheet1.Cells.Item[3+idx,5]:= '内切' ;
  if DM.DD_Query.FieldByName('L_CJ').AsString ='W' then  ExcelWorksheet1.Cells.Item[3+idx,5]:= '外切' ;
  if DM.DD_Query.FieldByName('R_CJ').AsString ='L' then  ExcelWorksheet1.Cells.Item[3+idx,6]:= '不切' ;
  if DM.DD_Query.FieldByName('R_CJ').AsString ='N' then  ExcelWorksheet1.Cells.Item[3+idx,6]:= '内切' ;
  if DM.DD_Query.FieldByName('R_CJ').AsString ='W' then  ExcelWorksheet1.Cells.Item[3+idx,6]:= '外切' ;
  ExcelWorksheet1.Cells.Item[3+idx,7]:= DM.DD_Query.FieldByName('BLJ_CJLD').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,8]:= DM.DD_Query.FieldByName('BLJ_CJRD').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,9]:= DM.DD_Query.FieldByName('BLJKD').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,10]:= DM.DD_Query.FieldByName('BLKD').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,11]:= DM.DD_Query.FieldByName('BLGD').AsString  ;
  if  (DM.DD_Query.FieldByName('ClassType').AsString ='L') then
  begin
    ExcelWorksheet1.Cells.Item[3+idx,12]:= DM.DD_Query.FieldByName('LGDKD').AsString  ;
    ExcelWorksheet1.Cells.Item[3+idx,14]:= '直线' ;
  end
  else
  begin
    ExcelWorksheet1.Cells.Item[3+idx,12]:= DM.DD_Query.FieldByName('GDKD').AsString  ;
    if (DM.DD_Query.FieldByName('ClassType').AsString ='W') then
      ExcelWorksheet1.Cells.Item[3+idx,14]:= '外凸'
    else
      ExcelWorksheet1.Cells.Item[3+idx,14]:= '内凹' ;
  end ;
  ExcelWorksheet1.Cells.Item[3+idx,13]:= DM.DD_Query.FieldByName('SR').AsString  ;
  ExcelWorksheet1.Cells.Item[3+idx,15]:= DM.DD_Query.FieldByName('XC').AsString  ;
end ;
  DM.DD_Query.Next ;
END ;
//ShowMessage( 'Total is '+String(ExcelWorksheet1.Cells.Item[31,2]) );
//ExcelWorksheet1.Range['A5','G5'].Merge(True) ; //合并单元格 合并A5-G5
//ExcelApplication1.Save(GetCurrentDir+'\OUTPUT\GSM月统计表'+YueFen.Text+'.xls',0) ;
ExcelWorksheet1.SaveAs(GetCurrentDir+'\金和阳光输出'+DD_List.Text+'.xls') ;
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
//}
{map:=Tbitmap.create;
map.Width := My_Image.width;
map.Height := My_Image.height;
map.PixelFormat := pf24bit;
map.Assign(My_Image.Picture.Bitmap);
map.SaveToFile('d:\'+FormatDateTime('YYYYMMDDHHMMSS',now())+'bit24.bmp') ;
}
end;

procedure TCX_Form.DBNavigator1Click(Sender: TObject;
  Button: TNavigateBtn);
begin
{if DM.DD_Query.FieldByName('XC').AsString='06' then
begin
  DD_06_Image.Visible := True ;
  DD_06_Image.Caption := '第'+DM.DD_Query.FieldByName('NUM').AsString+'段 第'+DM.DD_Query.FieldByName('Sub_NUM').AsString +'节 (06)型材切割说明' ;
  if ((DM.DD_Query.FieldByName('ClassType').AsString<>'L') and (DM.DD_Query.FieldByName('XC').AsString='06')) then
  begin
    HXSR_06.DataField := 'SR' ;
    GDZC_06.DataField := '' ;
    BLZK_06.DataField := '' ;
    BLKD_06.DataField := '' ;
  end
  else
  begin
    GDZC_06.DataField := 'GDZC' ;
    BLZK_06.DataField := 'BLZK' ;
    BLKD_06.DataField := 'BLKD' ;
  end ;
  BLGD_06.DataField := 'BLGD' ;
  YTGD_06.DataField := 'YTGD' ;
  Image_D_06.Picture.LoadFromFile(GetCurrentDir+'\IMAGES\'+DM.DD_Query.FieldByName('ClassType').AsString+'.bmp') ;
  Image_D_06.Show ;
end
else
begin
  DS_Image.Caption := '第'+DM.DD_Query.FieldByName('NUM').AsString+'段 第'+DM.DD_Query.FieldByName('Sub_NUM').AsString +'节' ;
  DS_Image.Visible := True ;
  My_Image.Visible := False ;
  BLJ_CJLD.DataField := 'BLJ_CJLD' ;
  BLJ_CJRD.DataField := 'BLJ_CJRD' ;
  L_CJ.DataField := 'L_CJ' ;
  R_CJ.DataField := 'R_CJ' ;
  BLKD.DataField := 'BLKD' ;
  BLJKD.DataField := 'BLJKD' ;
  BLGD.DataField := 'BLGD' ;
  YTGD.DataField := 'YTGD' ;
  XC.DataField := 'XC' ;

  if  (DM.DD_Query.FieldByName('ClassType').AsString ='L') then    GDKD.DataField := 'LGDKD' else GDKD.DataField := 'GDKD' ;
  Pic_Name.DataField := 'Pic_Name' ;
  D_Image.Picture.LoadFromFile(GetCurrentDir+'\IMAGES\'+DM.DD_Query.FieldByName('Pic_Name').AsString+'.bmp') ;
  D_Image.Show ;
end ;  }
end;

procedure TCX_Form.Button4Click(Sender: TObject);
begin
{DM.DD_Query.First ;
while (not DM.DD_Query.Eof ) do
BEGIN
  DM.DD_Query.Edit ;
if DM.DD_Query.FieldByName('L_CJ').AsString = 'W' THEN ///外
BEGIN
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'W') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'WC';
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'L') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'LWC';
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'N') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'LWRN';
END ;
if DM.DD_Query.FieldByName('L_CJ').AsString = 'N' THEN    //内
BEGIN
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'W') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'LNRW';
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'L') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'LNC';
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'N') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'NC';
END ;
if DM.DD_Query.FieldByName('L_CJ').AsString = 'L' THEN   //直
BEGIN
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'W') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'RWC';
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'L') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'BC';
  if (DM.DD_Query.FieldByName('R_CJ').AsString = 'N') THEN DM.DD_Query.FieldByName('Pic_Name').AsString := 'RNC';
END ;
  DM.DD_Query.Post ;
  DM.DD_Query.Next ;
END ;
//call    Button5Click
Button5.Click ;
//end call    Button5Click   }
end;

procedure TCX_Form.DD_ListChange(Sender: TObject);
begin
Button1.Click ;
end;

procedure TCX_Form.Button5Click(Sender: TObject);
Var LGDKD:Double;
begin
//修正直线部分;
//DM.DD_Query ;
{LGDKD :=0.00 ;
while (not DM.DD_Query.Bof )do
BEGIN
  if (DM.DD_Query.FieldByName('ClassType').AsString = 'L') then
  begin
    LGDKD := DM.DD_Query.FieldByName('GDZC').AsFloat ;
    DM.DD_Query.Edit ;
    if (DM.DD_Query.FieldByName('Sub_Num').AsInteger = 1) then
    begin
      DM.DD_Query.FieldByName('LGDKD').AsFloat:= LGDKD;
      LGDKD :=0.00 ;
    end
    else
    begin
      DM.DD_Query.FieldByName('LGDKD').AsFloat:= 0.00;
    end ;
    DM.DD_Query.Post ;
  end;
  DM.DD_Query.Prior ;
END ;
///      }
end;

end.

⌨️ 快捷键说明

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