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

📄 fm_overflow.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit fm_Overflow;

//////////2004-4-14 modify ydy 
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, fm_Base, StdCtrls, Grids, DBGrids, Buttons, ExtCtrls, Menus;

type
  TfmOverflow = class(TfmBase)
    Label1: TLabel;
    Label4: TLabel;
    Label3: TLabel;
    Label6: TLabel;
    Label2: TLabel;
    Bevel1: TBevel;
    Panel1: TPanel;
    Label10: TLabel;
    edttotals: TLabel;
    Panel2: TPanel;
    BitBtn7: TBitBtn;
    BitBtn1: TBitBtn;
    btnSave: TBitBtn;
    Panel3: TPanel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    edtremakt: TEdit;
    edtnewdate: TEdit;
    edtcode: TEdit;
    edtnewmen: TEdit;
    sgorder: TStringGrid;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    Bevel2: TBevel;
    CmbG: TComboBox;
    CmbC: TComboBox;
    Label5: TLabel;
    EdtTotalCount: TLabel;
    BitBtn2: TBitBtn;
    btnprint: TBitBtn;
    procedure BitBtn7Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure sgorderDblClick(Sender: TObject);
    procedure sgorderSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure sgorderKeyPress(Sender: TObject; var Key: Char);
    procedure btnSaveClick(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure sgorderDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnprintClick(Sender: TObject);
  private
    { Private declarations }
    part_no,stockid:widestring;
    function readdata:boolean; //数据绑定
    procedure init;
    procedure DeleteRow(Row: Integer);
    procedure TotalCount;  //汇总计算
  public
    { Public declarations }
    ///不要求判断库存数量  2004-4-14
  end;

var
  fmOverflow: TfmOverflow;
implementation

uses UntgoodCodeSelStr, func, untdatadm, Unitreportxf;

var
  pcol,prow:integer;
  flag:string;

{$R *.dfm}
///////////////////////////////////

function tfmOverflow.readdata:boolean;
var
  temp:widestring;
  i:integer;
  r:boolean;
begin
  r:=false;
  if Public_Do='stock_outed' then
  begin
    temp:='select * from dp_Overflow as a,dp_Overflowdetail as b,goods_prices as c where c.goods_no=b.od_ccode and a.o_code=b.od_ocode and a.o_code='+''''+trim(list_no)+'''';
    dmmain.CDSquery2.Close;
    dmmain.CDSquery2.Data:=NULL;
    dmmain.CDSquery2.Data:=adisp.resultrecord(temp);
    try
    dmmain.CDSquery2.Open;
    temp:='select * from dp_Overflow where o_code='+''''+trim(list_no)+'''';
    if dmmain.CDSexecsql.Active then dmmain.CDSexecsql.Close;
    dmmain.CDSexecsql.data:=null;
    dmmain.CDSexecsql.Data:=adisp.execSql(temp);
    dmmain.CDSexecsql.Open; 
    r:=true;
    bitbtn1.Enabled:=false;
    flag:='1';
    except
    end;
    edtnewdate.text:=dmmain.CDSquery2.fieldbyname('o_newdate').AsString;
    edtnewmen.text:=dmmain.CDSquery2.fieldbyname('o_newman').AsString;
    edtcode.text:=dmmain.CDSquery2.fieldbyname('o_code').AsString;
    cmbg.text:=dmmain.CDSquery2.fieldbyname('o_operater').AsString;
    cmbc.text:=dmmain.CDSquery2.fieldbyname('o_auditer').AsString;
    edtremakt.text:=dmmain.CDSquery2.fieldbyname('o_remark').AsString;
    part_no:=dmmain.CDSquery2.fieldbyname('o_shop').AsString;
     //stockid
    temp:='select storageid from part where part_no='+''''+trim(part_no)+'''';
    dmmain.CDSexecsql.Close;
    dmmain.CDSexecsql.Data:=null;
    try
    dmmain.CDSexecsql.Data:=adisp.execSql(temp);
    dmmain.CDSexecsql.Open;
    stockid:=trim(dmmain.CDSexecsql.fieldbyname('storageid').AsString);
    dmmain.CDSexecsql.Close;
    dmmain.CDSexecsql.Data:=null;
    except
      exit;
    end;
    ///
    sgorder.RowCount:=dmmain.CDSquery2.RecordCount+1;
    for i:=1 to dmmain.CDSquery2.RecordCount do
    begin
      sgorder.Cells[0,i]:=inttostr(i);
      sgorder.Cells[1,i]:=dmmain.CDSquery2.fieldbyname('od_ccode').AsString;
      sgorder.Cells[2,i]:=dmmain.CDSquery2.fieldbyname('od_cname').AsString;
      sgorder.Cells[4,i]:=dmmain.CDSquery2.fieldbyname('od_ccount').AsString;
      sgorder.Cells[8,i]:=dmmain.CDSquery2.fieldbyname('baseprice').AsString;
      dmmain.CDSquery2.Next;
    end;
    GetDataPrint(dmmain.cdsprintmaster,dmmain.CDsquery2);
  end;
  result:=r;
end;
procedure tfmOverflow.DeleteRow(Row: Integer);
var
  i : integer;
begin
//最后一行直接删除
 if (Row = sgorder.RowCount-1) and (row >1)  then
    Sgorder.RowCount := Sgorder.RowCount - 1;

//自动上移
  if (Row < Sgorder.RowCount) and (Row > Sgorder.FixedRows-1) then
  begin
    if Row < Sgorder.RowCount - 1 then
    begin
      for i := Row to Sgorder.RowCount-1 do
        Sgorder.Rows[i] := Sgorder.Rows[i+1];
      Sgorder.RowCount := Sgorder.RowCount - 1;
    end;
  end;
end;
procedure TfmOverflow.init;
var
  maks,sql,s_newdate:string;
begin
  s_newdate:=formatdatetime('yyyy''-''mm''-''dd',date);
  sql:='select max(right(o_Code,4)) from DP_Overflow where o_newdate='+''''+s_NewDate+''''+' and o_shop='+''''+trim(Handle_Part)+''''; //部门编号
  maks:='BY-'+Handle_Part+trim(handle_no);
  edtcode.Text:=setcode(sql,maks); //Autoid

  edtnewdate.Text:=formatdatetime('yyyy''-''mm''-''dd',Date);
  edtnewmen.Text:=Handle_Man;
  flag:='1';
  if not dmmain.cdsOverflow.Active  then dmmain.cdsOverflow.Open;
  if not dmmain.cdsOverflowdetail.Active  then dmmain.cdsOverflowdetail.Open;

  EdtTotalCount.Caption :='';
  edttotals.Caption :='';

end;

procedure TfmOverflow.BitBtn7Click(Sender: TObject);
begin
  inherited;
  ////2004-3-8加入
 dmmain.CDSexecsql.Data := null; //客户端内存减少
  dmmain.CDSexecsql.Close;   //ydy add

  close;
end;

procedure TfmOverflow.FormShow(Sender: TObject);
var
  t_sql:string;
begin
  inherited;
  sgorder.Cells[1,0]:='商品编号';
  sgorder.ColWidths[0] := 20;
  sgorder.ColWidths[1] := 130;
  sgorder.ColWidths[2] := 190;
  sgorder.ColWidths[6] := 70;
  sgorder.Cells[2,0]:='商品名称';
  sgorder.Cells[3,0]:='商品单价';
  sgorder.Cells[4,0]:='商品数量';
  sgorder.Cells[5,0]:='商品折扣';
  sgorder.Cells[6,0]:='折扣后单价';
  sgorder.Cells[7,0]:='金额';
  sgorder.ColWidths[8]:=0;
  if not readdata then
  begin
    init;
     t_sql:='select p_name from  [dp_person] where p_workid ='+''''+trim(Handle_Part)+'''';
  GetDataToComBoX(cmbg,t_sql,'p_name');
  cmbg.ItemIndex := -1;
  cmbc.Items := cmbg.Items;
  end;
end;

procedure TfmOverflow.BitBtn1Click(Sender: TObject);
var
  sql:widestring;
  i:integer;
  quedata:olevariant;
begin
  inherited;
  //sql:='select cd_ccode as code ,cd_cname as name ,CD_Amount as count from dp_checkdetail where cd_checkcode in (select c_code from dp_check where c_state='+''''+'4'+''''+' or c_shop='+''''+trim(shopid)+''''+') and cd_state='+''''+'2'+''''; //盘点转单
  flag:='2';
  //select * from vcheckdata where c_shop
  sql:='select * from [vcheckdata]  where count>0 and c_shop='+''''+trim(Handle_Part)+''''+' and cd_state='+''''+'1'+'''';  // 加工的定单;
  if dmmain.CDSexecsql.Active then dmmain.CDSexecsql.Close;
  try
    dmmain.CDSexecsql.Data:=adisp.execSql(sql);
  except
  end;
  dmmain.CDSexecsql.Open;
  dmmain.CDSexecsql.First;
  i:=1;
  while not dmmain.CDSexecsql.Eof do //加载显示(thing)
  begin
    sgorder.Cells[1,i]:=trim(dmmain.CDSexecsql.fieldbyname('code').AsString );
    sgorder.Cells[2,i]:=trim(dmmain.CDSexecsql.fieldbyname('name').AsString );
    sgorder.Cells[8,i]:=trim(dmmain.CDSexecsql.fieldbyname('baseprice').Asstring);
    sgorder.Cells[4,i]:=trim(dmmain.CDSexecsql.fieldbyname('count').AsString);
    dmmain.CDSexecsql.Next;
    if i<>1 then
    begin
      sgorder.RowCount:= sgorder.RowCount+1;
    end;
    inc(i);
  end;
end;

procedure TfmOverflow.sgorderDblClick(Sender: TObject);
var
  i:integer;
begin
  inherited;
  if flag='1' then
  begin
    if pcol in [1,2,3] then
    begin
////2004-4-12 add
   fmgoodCodeSelStr:= TfmgoodCodeSelStr.Create(nil);
   try
    fmgoodcodeselStr.show_mode:='4';
   fmgoodcodeselStr.ShowModal;
   finally
   fmgoodcodeselStr.Free;
   end;
{
      with tfmgoods.Create(self) do
      try
        show_mode:='4';  ///ydy modify
        ShowModal;
      finally
        Free;
      end;
}
    end;
  if pcol = 4 then  //复制数量
  begin
   for i := prow+1 to sgorder.rowcount -1 do
   begin
   sgorder.cells[4,i]:= sgorder.cells[4,prow];
   //同时要计算金额
   if trim(sgorder.Cells[4,i]) <>''  then
   begin
        sgorder.Cells[7,i]:=floattostrf(strtofloat(sgorder.Cells[3,i])*strtofloat(sgorder.Cells[4,i]),ffFixed,11,2);  //无折扣单价
   end;
    TotalCount;
  end;
  end;

  end;
end;

procedure TfmOverflow.sgorderSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  inherited;
  pcol:=acol;
  prow:=arow;
end;

procedure TfmOverflow.sgorderKeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
  if flag='1' then
  begin
    if pcol in [4] then
    begin
      if not (key in ['0'..'9',#8,'.']) then
      begin
        key:=#0;
      end else
      begin
        if key<>#8 then
        begin
          if pcol=4 then  sgorder.Cells[4,prow]:=sgorder.Cells[4,prow]+key;
        end else
        begin
          if pcol=4 then
          begin
            sgorder.Cells[4,prow]:='';  //不加退格符号;
            sgorder.Cells[7,prow]:='';
           //汇总计算
           TotalCount;
          end;
          exit;
        end;
      end;
    end;
    if trim(sgorder.Cells[3,prow])<>'' then

⌨️ 快捷键说明

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