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

📄 lmdfxmainmain.pas

📁 线性规划CAI应用程序及原代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit lmdfxmainmain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Grids, ComCtrls,lpmain;

type
  Tlmdmain = class(TForm)
    Label7: TLabel;
    Label8: TLabel;
    agrid1: TStringGrid;
    cxbGrid1: TStringGrid;
    xiGrid1: TStringGrid;
    bdaGrid1: TStringGrid;
    czGrid1: TStringGrid;
    objedit1: TEdit;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    ComboBox3: TComboBox;
    StatusBar1: TStatusBar;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Button1: TButton;
    Label12: TLabel;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormHide(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure calculateclmd(a:integer);
    procedure calculateblmd(a:integer);
    function  getclmd(a,b:string):string;
    procedure getresultalmd(a,b:integer);
    procedure get_ij(a:string);
    procedure findbasenumc(a:integer);
    procedure findbasenumb(a:integer);
    procedure ComboBox3Change(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
    lmdmain: Tlmdmain;
    cnum,bnum,anum:integer;
    clmd,blmd,almd:string;
    basenum:integer;
    blmdmax,blmdmin:extended;
    clmdmax,clmdmin:extended;
    get_i,get_j:integer;
    save_hang:integer;
    save_hang1:integer;
    save_result_array:array[0..100]of extended;
    function judgeifisbasevar(i:integer):boolean;
    procedure findmin;
    procedure findminb;
    procedure getresultclmd;
    procedure getresultblmd;
    function judge_basevar(i:integer):boolean;
    function b_is_over(i:integer):boolean;

//    procedure getresultalmd(a,b:integer);
    procedure calculatealmd(a:string);
implementation

uses lpdchxing;

{$R *.DFM}


procedure Tlmdmain.FormShow(Sender: TObject);
var i,j:integer;
begin
     lmdmain.AutoScroll :=false;
     agrid1.RowCount :=afterleashnum;
     cxbgrid1.rowcount:=afterleashnum+1;//dchxingform.cxbgrid1.RowCount ;
     xigrid1.RowCount :=2;//dchxingform.xigrid1.Rowcount;
     czgrid1.RowCount :=2;//dchxingform.czgrid1.RowCount ;
     bdagrid1.RowCount :=afterleashnum+1;//dchxingform.bdaGrid1.RowCount ;

     agrid1.colCount :=afteraddvarnum;//dchxingform.agrid1.colCount;
     cxbgrid1.colcount:=3;//dchxingform.cxbgrid1.colCount ;
     xigrid1.colCount :=afteraddvarnum;//dchxingform.xigrid1.colcount;
     czgrid1.colCount :=afteraddvarnum;//dchxingform.czgrid1.colCount ;
     bdagrid1.colCount :=1;//dchxingform.bdaGrid1.colCount ;

     agrid1.width :=dchxingform.agrid1.width;//(agrid1.ColWidths[0]+1)*agrid1.ColCount ;
     cxbgrid1.width:=dchxingform.cxbgrid1.width;//(agrid1.ColWidths[0]+1)*3;
     xigrid1.width :=dchxingform.xigrid1.width;//(agrid1.ColWidths[0]+1)*xigrid1.ColCount ;
     czgrid1.Width  :=dchxingform.czgrid1.width;//(agrid1.ColWidths[0]+1)*czgrid1.ColCount ;
     bdagrid1.width :=dchxingform.bdagrid1.width;//(agrid1.ColWidths[0]+1)*1;

     agrid1.Height  :=dchxingform.agrid2.height;//(agrid1.RowHeights [0]+1)*agrid1.rowCount ;
     cxbgrid1.height:=dchxingform.cxbgrid1.height;//(agrid1.RowHeights [0]+1)*cxbgrid1.rowCount ;
     xigrid1.height :=dchxingform.xigrid1.height;//(agrid1.RowHeights [0]+1)*2;
     czgrid1.height :=dchxingform.czgrid1.height;//(agrid1.RowHeights [0]+1)*2;
     bdagrid1.height :=dchxingform.bdagrid1.height;//(agrid1.RowHeights [0]+1)*bdagrid1.rowCount ;

     agrid1.left :=dchxingform.agrid1.left;//150;
     cxbgrid1.left:=dchxingform.cxbgrid1.left;//agrid1.Left-cxbgrid1.Width ;
     xigrid1.left :=dchxingform.xigrid1.left;//agrid1.left;
     czgrid1.left:=dchxingform.czgrid1.left;//agrid1.left;
     bdagrid1.left :=dchxingform.bdagrid1.left;//aGrid1.left+agrid1.Width ;

     agrid1.top:=dchxingform.agrid1.top;//label12.top+60;
     cxbgrid1.top:=dchxingform.cxbgrid1.top;//agrid1.top-agrid1.RowHeights[0]-1;
     xigrid1.top:=dchxingform.xigrid1.top;//agrid1.top-xigrid1.Height ;
     czgrid1.top:=dchxingform.czgrid1.top;//agrid1.top+agrid1.Height ;
     bdagrid1.top:=dchxingform.bdagrid1.top;//cxbgrid1.top;

     objedit1.Left :=dchxingform.objedit1.left;//czgrid1.left-objedit1.Width ;
     objedit1.Top :=dchxingform.objedit1.top;//czgrid1.top+5;

     label7.Left :=dchxingform.label7.left;//objedit1.left-80;
     label7.top :=dchxingform.label7.top;//czgrid1.top+5;
     label8.Left :=dchxingform.label8.left;//label7.left;
     label8.top :=dchxingform.label8.top;//label7.top+label7.Height ;
     agrid1.ScrollBars :=dchxingform.agrid1.ScrollBars ;
     xigrid1.ScrollBars :=dchxingform.xigrid1.ScrollBars ;
     cxbgrid1.ScrollBars :=dchxingform.cxbgrid1.ScrollBars ;
     bdagrid1.ScrollBars :=dchxingform.bdagrid1.ScrollBars ;
     czgrid1.ScrollBars :=dchxingform.czgrid1.ScrollBars ;
//****************灵敏度分析显示**********************************
     if (varnum>9) or (leashnum>9) then
     begin
     combobox1.Width :=70;
     combobox2.Width :=70;
     combobox3.Width :=70;
     end
     else
     begin
     combobox1.Width :=45;
     combobox2.Width :=45;
     combobox3.Width :=45;
     end;

     label9.Left :=label8.left;
     label9.top:=label8.top+label8.Height +40;
     edit1.left:=label9.Left +150;
     label1.Left :=edit1.Left +edit1.Width +5;
     combobox1.Left :=label1.left+30;
     label2.left:=combobox1.left+combobox1.Width +5;
     edit2.left:=label2.Left +30;
     button2.left:=edit2.left+edit2.Width+button5.Width+40;
     button5.left:=button2.left-button5.Width ;
     edit1.top:=label9.top;
     label1.top:=label9.top;
     combobox1.top:=label9.top;
     label2.top:=label9.top;
     edit2.top:=label9.top;
     button2.Top :=label9.top;
     button5.top:=label9.top;

     label10.Left :=label8.left;
     label10.top:=label9.top+label9.Height +10;

     edit3.left:=label10.Left +150;
     label3.Left :=edit3.Left +edit3.Width +5;
     combobox2.Left :=label3.left+30;
     label4.left:=combobox2.left+combobox2.Width +5;
     edit4.left:=label4.Left +30;
     button3.left:=edit4.left+edit4.Width+button6.Width +40;
     button6.left:=button2.left-button6.Width ;
     edit3.top:=label10.top;
     label3.top:=label10.top;
     combobox2.top:=label10.top;
     label4.top:=label10.top;
     edit4.top:=label10.top;
     button3.Top :=label10.top;
     button6.top:=label10.top;

     label11.Left :=label8.left;
     label11.top:=label10.top+label10.Height +10;

     edit5.left:=label11.Left +150;
     label5.Left :=edit5.Left +edit5.Width +5;
     combobox3.Left :=label5.left+30;
     label6.left:=combobox3.left+combobox3.Width +5;
     edit6.left:=label6.Left +30;
     button4.left:=edit6.left+edit6.Width+button7.Width +40;
     button7.left:=button4.left-button7.Width;
     edit5.top:=label11.top;
     label5.top:=label11.top;
     combobox3.top:=label11.top;
     label6.top:=label11.top;
     edit6.top:=label11.top;
     button4.Top :=label11.top;
     button7.top:=label11.top;

     button1.left:=button7.left;
     button1.Top :=button7.top+50;
     if (bdagrid1.Left+100)<(button2.Left+button2.Width+20) then
         lmdmain.width:=button2.left+button2.width+20
     else
         lmdmain.Width :=bdagrid1.Left+100;
     if lmdmain.width>800 then lmdmain.AutoScroll :=true;
     lmdmain.Height :=button1.Top +100;
     if lmdmain.Height >600 then lmdmain.AutoScroll :=true;


     if lmdfxarr[0]='a' then
     begin
        //edit1.Enabled :=true;
        if studymode then
        begin
        edit1.Enabled :=true;
        edit2.Enabled :=true;
        end;
        edit1.Color :=clwhite;
        edit1.Font.Color:=clblue;
        edit1.Text :='';
        //edit2.Enabled :=true;
        edit2.Color :=clwhite;
        edit2.Font.Color:=clblue;
        edit2.Text :='';
        button2.Enabled :=true;
        button5.Enabled :=true;
        combobox1.Enabled :=true;
        combobox1.Color :=clwindow;
     end;
     if lmdfxarr[1]='b' then
     begin
        //edit4.Enabled :=true;
        if studymode then
        begin
        edit3.Enabled :=true;
        edit4.Enabled :=true;
        end;
        edit4.Text :='';
        edit4.Color :=clwhite;
        edit4.Font.Color:=clblue;
        //edit3.Enabled :=true;
        edit3.Color :=clwhite;
        edit3.Text :='';
        edit3.Font.Color:=clblue;
        button3.Enabled :=true;
        button6.Enabled :=true;
        combobox2.Enabled :=true;
        combobox2.Color :=clwindow;
     end;
     if lmdfxarr[2]='c' then
     begin
        //edit5.Enabled :=true;
        if studymode then
        begin
        edit5.Enabled :=true;
        edit6.Enabled :=true;
        end;
        edit5.Text :='';        
        edit5.Color :=clwhite;
        edit5.Font.Color:=clblue;
        //edit6.Enabled :=true;
        edit6.Color :=clwhite;
        edit6.Font.Color:=clblue;
        edit6.Text :='';        
        button4.Enabled :=true;
        button7.Enabled :=true;
        combobox3.Enabled :=true;
        combobox3.Color :=clwindow;
     end;
//*******************取得最优时表单数据*************************
     for i:=0 to xigrid1.ColCount-1 do
         xigrid1.Cells[i,0]:='X'+inttostr(i+1);

         cxbgrid1.Cells[0,0]:='Cb';
         cxbgrid1.Cells[1,0]:='Xb';
         cxbgrid1.Cells[2,0]:='B';
         bdagrid1.Cells[0,0]:='Bj/Aij';


     for i:=0 to xigrid1.colCount-1 do
         begin
         xigrid1.Cells [i,1]:=dchxingform.xiGrid1.Cells[i,1];
         arraygrid4[i]:=dchxingform.xiGrid1.Cells[i,1];
         end;
     for i:=0 to cxbgrid1.ColCount-1 do
         for j:=0 to cxbgrid1.RowCount-1 do
         begin
         cxbgrid1.Cells [i,j+1]:=dchxingform.cxbGrid2.Cells[i,j];
         end;
     for i:=0 to agrid1.ColCount-1 do
         for j:=0 to agrid1.RowCount-1 do
         begin
         agrid1.Cells [i,j]:=dchxingform.aGrid2.Cells[i,j];
         arraygrid1[i,j]:=dchxingform.agrid2.cells[i,j]
         end;
     for i:=0 to czgrid1.ColCount-1 do
         for j:=0 to czgrid1.RowCount-1 do
         begin
         czgrid1.Cells [i,j]:=dchxingform.czGrid2.Cells[i,j];
         end;
     for j:=1 to bdagrid1.ColCount-1 do
         begin
         bdagrid1.Cells [0,j]:=dchxingform.bdaGrid2.Cells[0,j];
         end;
     for i:=0 to leashnum do
         begin
         b_value_array[i]:=dchxingform.cxbgrid2.Cells[2,i];
         end;


      objedit1.Text :=dchxingform.objedit2.Text ;


{*********************下拉列表显示**************************}
	 if combobox3.enabled=true then
	 begin
	  if combobox3.Items.Count=0 then
	  begin
	  combobox3.Items.Delete(0);
	  for i:=1 to varnum do
			begin
				  combobox3.Items.add('C'+inttostr(i));
			end;
	  end;
	  combobox3.Text :=combobox3.Items.Strings[0];
	  cnum:=1;
	 end;
 if combobox2.enabled=true then
	 begin                   
	  if combobox2.Items.Count=0 then
	  begin
	  combobox2.Items.Delete(0);
	  for i:=1 to leashnum do
			begin
				  combobox2.Items.add('B'+inttostr(i));
			end;
	  end;
	  combobox2.Text :=combobox2.Items.Strings[0];
	  bnum:=1;
	end;
	if combobox1.enabled=true then
	 begin    	
	  if combobox1.Items.Count=0  then
	  begin
	  combobox1.Items.Delete(0);

	  if (varnum>9)or(leashnum>9)then
	  for i:=1 to leashnum do
			for j:=1 to varnum do
			begin
				  if (i<10)and(j<10) then
				  combobox1.Items.add('A'+'0'+inttostr(i)+'0'+inttostr(j))
				  else
				  if (i<10)and(j>=10)then
				  combobox1.Items.add('A'+'0'+inttostr(i)+inttostr(j))
				  else
			if (i>=10)and(j<10)then
				  combobox1.Items.add('A'+inttostr(i)+'0'+inttostr(j))
				  else
				  if (i>=10)and(j>=10)then
				  combobox1.Items.add('A'+inttostr(i)+inttostr(j));
			end

	  else
	  for i:=1 to leashnum do
			for j:=1 to varnum do
			begin
				  combobox1.Items.add('A'+inttostr(i)+inttostr(j));
			end;
	  end;
	  combobox1.Text :=combobox1.Items.Strings[0];
	  anum:=1;
	 end;
{     if combobox3.Enabled =true then  ComboBox3Change(sender);
	  if combobox2.Enabled =true then  ComboBox2Change(sender);
     if combobox1.Enabled =true then  ComboBox1Change(sender);
}
end;
procedure Tlmdmain.Button1Click(Sender: TObject);
begin
lmdmain.Hide ;
end;

procedure Tlmdmain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
lmdmain.Hide ;
end;

procedure Tlmdmain.FormHide(Sender: TObject);
var i:integer;
begin
        edit1.Enabled :=false;
        edit1.text :='';        
        edit1.Color :=clbtnface;
        edit2.Enabled :=false;
        edit2.Text :='';        
        edit2.Color :=clbtnface;
        button2.Enabled :=false;
        combobox1.Enabled :=false;
        combobox1.Text :='';
        combobox1.Color :=clbtnface;
        edit4.Enabled :=false;
        edit4.Text :='';        
        edit4.Color :=clbtnface;
        edit3.Enabled :=false;
        edit3.Text :='';        
        edit3.Color :=clbtnface;
        button3.Enabled :=false;
        combobox2.Enabled :=false;
        combobox2.Text :='';
        combobox2.Color :=clbtnface;
        edit5.Enabled :=false;
        edit5.Text :='';
        edit5.Color :=clbtnface;
        edit6.Enabled :=false;
        edit6.Text :='';
        edit6.Color :=clbtnface;
        button4.Enabled :=false;
        combobox3.Enabled :=false;
        combobox3.text:='';
        combobox3.Color :=clbtnface;
        button5.Enabled :=false;
        button6.Enabled :=false;

⌨️ 快捷键说明

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