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

📄 rkglxt.~pas

📁 《仓库管理系统》 开发语言:Delphi7.0 数据库:SQLServer2000 数据库文件:仓库管理系统_Data.MDF,仓库管理系统_Log.LDF(mingrisoft仓库管理系统Da
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
            parameters.ParamByName('b').Value := StrToFloat(Label17.Caption)- StrToFloat(Edit1.Text) ;
            parameters.ParamByName('c').Value := Trim(StringGrid1.Cells[5,Rowsum]) ;
            ExecSQL;
          end;
        end;
      end;
    Data.ADOConnection1.CommitTrans;
    Application.MessageBox('保存成功。','提示',0+64);
    Clear;
    BitBtn3.SetFocus;
    Except
      Data.ADOConnection1.RollbackTrans;
      Application.MessageBox('系统出错。','提示',0+64);
      Close;
    end;
  end;
end;

procedure TForm12.Edit8Exit(Sender: TObject);
begin
  if Edit8.Text = '' then
  begin
    Application.MessageBox('折扣不能为空。','提示',0+64);
    Edit8.SetFocus;
    Exit;
  end;
  if (StrToFloat(Edit8.Text)>1)or(StrToFloat(Edit8.Text)<0)then
  begin
    Application.MessageBox('折扣不能大于1或小于0。','提示',0+64);
    Edit8.Clear;
    Edit8.SetFocus;
    Exit;
  end;
  try
    StrToFloat(Edit8.Text);
  except
    Application.MessageBox('请输入合法字符。','提示',0+64);
    Edit8.Clear;
    Edit8.SetFocus;
  end;
end;

procedure TForm12.Clear;
var
  r,c: integer;
begin
  Edit2.ReadOnly := False;
  Label14.Caption := '';
  Label10.Caption := '';
  Edit2.Clear;
  Edit8.Text := '1.0';
  Label15.Caption := '0';
  Label16.Caption := '0';
  Label17.Caption := '0.0';
  ComboBox2.ItemIndex := 0;
  Edit4.Clear;
  Edit1.Clear;
  For r := 1 to StringGrid1.RowCount-1 do
    For c := 0 to StringGrid1.ColCount-1 do
      StringGrid1.Cells[c,r]:='';
  StringGrid1.RowCount  :=2;
end;

procedure TForm12.BitBtn7Click(Sender: TObject);
begin
  Clear;
  BitBtn3.SetFocus;
end;

procedure TForm12.BitBtn3MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clRed;
end;

procedure TForm12.BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clBlue;
end;

procedure TForm12.Edit8KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = VK_return then
    if (Trim(Edit8.Text)<>'')and(Trim(StringGrid1.Cells[2,x])='') then
    begin
      StringGrid1.Cells[4,StringGrid1.RowCount-1]:= Edit8.Text;
      StringGrid1.Col := 2;
      StringGrid1.SetFocus;
    end;
end;

procedure TForm12.Edit4KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_ReTurn then
    if Trim(Edit4.Text)<>'' then
      Edit2.SetFocus;
end;

procedure TForm12.StringGrid1SetEditText(Sender: TObject; ACol,
  ARow: Integer; const Value: String);
var
  Jg: Real;
  a1: Integer;
begin
  Jg := 0.0;
  if (Trim(StringGrid1.Cells[0,x])<>'')and(Trim(StringGrid1.Cells[1,x])<>'')then
    if Trim(StringGrid1.Cells[2,x])<>'' then
    begin
      with Data.ADOQuery4 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select * from 商品基础信息表 where 商品编号 =:a');
        Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[0,x]);
        Open;
      end;
      Jg:= Data.ADOQuery4.FieldByName('进价').Value;
      StringGrid1.Cells[3,x]:= FloatToStr(StrToInt(StringGrid1.Cells[2,x])* Jg*(StrToFloat(StringGrid1.Cells[4,x])));
      if jcxmlb = True then
      begin
        Label17.Caption := FloatToStr(SumPrice);
        Label16.Caption := IntToStr(SumSL);
        Label15.Caption := IntToStr(Kinds);
      end;
      Exit;
    end
    else
    begin
      StringGrid1.Cells[3,x]:='';
      Exit;
    end;
  if (ss = False)and(s1 = False) then
  begin
    if ACol = 1 then
    begin
      with Data.ADOQuery1 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select * from 商品基础信息表 where (商品名称 like :b and  供应商编号 = :a)');
        Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[1,x])+'%';
        Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[5,x]);
        Open;
     end;
      if Data.ADOQuery1.RecordCount>0 then
      begin
        DataSource1.DataSet := Data.ADOQuery1;
        DBGrid1.Visible := True;
      end
      else
      begin
        DataSource1.DataSet := nil;
        DBGrid1.Visible := False;
        S1 := True;
        if FirstIsNull = True then
          if Application.MessageBox('该供应商没有提供此商品,要选择其他供应商吗?','提示',MB_YESNO )=ID_Yes then
          begin
            ClearString;
            Edit2.ReadOnly := False;
            Edit2.Clear;
            Edit2.SetFocus ;
          end
          else
          begin
            For a1 := 0 to 3 do
              StringGrid1.Cells[a1,x]:= '';
            StringGrid1.SetFocus;
            StringGrid1.Col := 1;
          end
        else
        Begin
          Application.MessageBox('该供应商没有提供此商品。','提示',64);
          For a1 := 0 to 3 do
            StringGrid1.Cells[a1,x]:= '';
          StringGrid1.SetFocus;
          StringGrid1.Col := 1;
        end;
      end;
    end;
  end ;
end;

procedure TForm12.DBGrid1DblClick(Sender: TObject);
begin
  StringGrid1.Cells[0,x]:= Data.ADOQuery1.FieldByName('商品编号').Value;
  StringGrid1.Cells[1,x]:= Data.ADOQuery1.FieldByName('商品名称').Value;
  DataSource1.DataSet := nil;
  DBGrid1.Visible := False;
  StringGrid1.SetFocus;
  StringGrid1.Col := 2;
end;

procedure TForm12.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = VK_ReTurn then
    DBGrid1.OnDblClick(Sender);
end;

procedure TForm12.SelectSPXX;
begin
  with Data.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 商品基础信息表 where (商品名称 = :b and  供应商编号 = :a)');
    Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[1,x]);
    Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[5,x]);
    Open;
  end;
end;

function TForm12.IsNull: Boolean;
var
  a: Integer;
begin
  IsNull := False;
  For a:= 0 to StringGrid1.ColCount -1 do
  begin
    if Trim(Stringgrid1.Cells[a,x])='' then
    begin
      IsNull := True;
      Break;
    end;
  end;
end;

procedure TForm12.ClearString;
var
  i: Integer;
begin
  For i := 0 to 3 do
    StringGrid1.Cells[i,x]:= '';
end;

procedure TForm12.ClearStringEnd;
var
  mm: Integer;
begin
  For mm:= 0 to 3 do
    StringGrid1.Cells[mm,StringGrid1.RowCount-1]:= '';
end;

Function TForm12.SumPrice: Real;
var
  nn: Integer;
  sum: Real;
begin
  sum := 0.0;
    For nn := 1 to StringGrid1.RowCount-1 do
      sum := Sum + StrToFloat(StringGrid1.Cells[3,nn]);
  ReSult := Sum;
end;

function TForm12.EndIsNull: Boolean;
var
  Cc: Integer;
begin
  Result := False;
  For Cc := 0 to StringGrid1.ColCount-1 do
    if Trim(StringGrid1.Cells[Cc,StringGrid1.RowCount-1])='' then
    begin
      Result := True;
      Break;
    end;
end;

function TForm12.SumSL: Integer;
var
  nn: Integer;
  sum: Integer;
begin
  sum := 0;
    For nn := 1 to StringGrid1.RowCount-1 do
      sum := Sum + StrToInt(StringGrid1.Cells[2,nn]);
  ReSult := Sum;
end;

//该函数用于统计商品的种类,基本思路是将当前记录与当前记录之前的记录比较
//如果当前记录与之前记录重复,进行下一次循环,如果不重复,则将当前记录与之后的记录比较
//如果重复将返回值减一
function TForm12.Kinds: Integer;
var
  i,m,mm: Integer;
  Iscf: Boolean;  //判断当前记录是否与之前的记录重复
begin
  mm:= 0;
  Iscf := False;
  Result := StringGrid1.RowCount-1;
  For m := 1 to StringGrid1.RowCount-1 do
    For i := m+1 to StringGrid1.RowCount-1 do
    begin
      Iscf := False;
      if m >1 then
        For mm := 1 to m-1 do
          if Trim(StringGrid1.Cells[0,m])= Trim(StringGrid1.Cells[0,mm])then
          begin
            Iscf := True;
            Break;
          end;
      if Iscf = True then
        Continue;
      if Trim(StringGrid1.Cells[0,m])=Trim(StringGrid1.Cells[0,i])then
        ReSult := Result -1;
    end;
end;

procedure TForm12.Edit1Exit(Sender: TObject);
begin
  if Edit1.Text = '' then
  begin
    Application.MessageBox('实付金额不能为空。','提示',0+64);
    Edit1.SetFocus;
    Exit;
  end;
  if StrToFloat(Edit1.Text)<0then
  begin
    Application.MessageBox('实付金额不能小于0。','提示',0+64);
    Edit1.Clear;
    Edit1.SetFocus;
  end;
  try
    StrToFloat(Edit1.Text);
  except
    Application.MessageBox('请输入合法字符。','提示',0+64);
    Edit1.Clear;
    Edit1.SetFocus;
  end;
end;

procedure TForm12.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Key = vk_ReTurn)and(Trim(Edit1.Text)<>'') then
    BitBtn4.SetFocus;
end;

procedure TForm12.ComboBox2KeyPress(Sender: TObject; var Key: Char);
begin
  Key := #0;
end;

procedure TForm12.Edit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if FirstIsNull = False then
    Exit;
  if Key = VK_Next then
  begin
    ListBox1.Visible:= True;
    ListBox1.SetFocus;
    ListBox1.ItemIndex := 0;
  end;
  if Key = Vk_ReTurn then
  begin
    ListBox1.Visible := False;
    if (Trim(Label14.Caption)='')or(Trim(Label3.Caption)='') then
    begin
      Application.MessageBox('请添加入库票号和入库时间。','提示',0+64);
      BitBtn3.SetFocus;
      Exit;
    end;
    if Trim(Edit2.Text)<>'' then
    begin
      with Data.ADOQuery2 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select * from 供应商基础信息表 where 供应商全称 = :a');
        Parameters.ParamByName('a').Value := Trim(Edit2.Text);
        Open;
      end;
      if Data.ADOQuery2.RecordCount>1 then
      begin
        Application.CreateForm(TForm13,Form13);
        Form13.DataSource1.DataSet := Data.ADOQuery2;
        Form13.ShowModal;
        Form13.Free;
        Edit2.ReadOnly:= True;
      end
      else if Data.ADOQuery2.RecordCount= 1 then
      begin
        StringGrid1.Cells[5,StringGrid1.RowCount-1]:= Data.ADOQuery2.FieldByName('供应商编号').AsString;
        StringGrid1.Cells[6,StringGrid1.RowCount-1]:= Data.ADOQuery2.FieldByName('供应商全称').AsString;
        Edit2.ReadOnly:= True;
      end
      else
      begin
        Application.MessageBox('对不起,该供应商不存在。','提示',64);
        Edit2.Clear;
        Edit2.SetFocus;
        Exit;
      end;
      StringGrid1.SetFocus;
      StringGrid1.Col := 1;
      StringGrid1.Cells[4,StringGrid1.RowCount-1]:= '1.0';
      StringGrid1.Cells[7,StringGrid1.RowCount-1]:= Label10.Caption;
      StringGrid1.Cells[8,StringGrid1.RowCount-1]:= Label14.Caption;
   end;
  end;
end;

procedure TForm12.ListBox1DblClick(Sender: TObject);
begin
  Edit2.Text:= ListBox1.Items[ListBox1.ItemIndex];
  Edit2.SetFocus;
  ListBox1.Visible := False;
end;

procedure TForm12.ListBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = Vk_ReTurn then
    ListBox1.OnDblClick(Sender);
end;

function TForm12.FirstIsNull: Boolean;
var
  Cc: Integer;
begin
  Result := False;
  For Cc := 0 to StringGrid1.ColCount-1 do
    if Trim(StringGrid1.Cells[Cc,1])='' then
    begin
      Result := True;
      Break;
    end;
end;
function TForm12.CurrentIsCf: Boolean;
var
  i: Integer;
begin
  ReSult := False;
  if x > 1 then
  begin
    For i := 1 to x-1 do
    begin
      if  Trim(StringGrid1.Cells[0,x])= Trim(StringGrid1.Cells[0,i]) then
      begin
        ReSult := True;
        Break;
        Exit;
      end;
    end;
    For i := x+1 to StringGrid1.RowCount-1 do
    begin
      if  Trim(StringGrid1.Cells[0,x])= Trim(StringGrid1.Cells[0,i]) then
      begin
        ReSult := True;
        Break;
        Exit;
      end;
    end;
  end
  else if x = 1 then
  begin
    For i := 2 to StringGrid1.RowCount-1 do
      if  Trim(StringGrid1.Cells[0,x])= Trim(StringGrid1.Cells[0,i]) then
      begin
        ReSult := True;
        Break;
        Exit;
      end;
  end;

end;

end.

⌨️ 快捷键说明

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