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

📄 untposquestbillstr.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit UntPosQuestBillStr;
///门店配送退货出库单  2004-4-15 ydy
////ydy 2004-4-23 修改为用STRINGGRID
/////2004-4-25 修改初步完成,采用公用函数
interface

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

//////数据表的记录
type TSendMaster = record
    vcSendBillId: string;
    VcSourceId: string;
    BillNo: string;
    iBIlltype: integer;
    vcSendStockID: string;
    vcRecvStockID: string;
    dtDrawDate: TDateTime;
    dtOutStockDate: Tdatetime;
    vcEId: string;
    vcListerId: string;
    vcAssessorId: string;
    NSumQty: Double;
    nuCess: Double;
    nuTax: Double;
    nuIncTaxSum: Double;
    nuTotalMoney: Double;
    nuUnTaxSum: Double;
    BillStatus: Integer;
    inVoucherSign: Integer;
    inIsReadSign: Integer;
    vcOutHouseReadBillId: string;
    inByReadSign: Integer;
    vcExplain: string;
    SendStatus: Integer;
    VcSendStockName: string;
    VcRecvStockName: string;
    ObjectID: Integer;
  end;
type
  TFmPosQuestBillStr = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    BtnAddRow: TSpeedButton;
    BtnDelRow: TSpeedButton;
    sourcebill: TSpeedButton;
    query: TSpeedButton;
    help: TSpeedButton;
    Label4: TLabel;
    Label6: TLabel;
    EdtMemo: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    StaticText1: TStaticText;
    EdtBillNo: TEdit;
    BillTitle: TLabel;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    CdsMasterData: TClientDataSet;
    CdsDetailData: TClientDataSet;
    sgorder: TStringGrid;
    bitcheck: TBitBtn;
    edtsendshop: TLabeledEdit;
    edtRecvStock: TLabeledEdit;
    edtm: TLabeledEdit;
    edtg: TLabeledEdit;
    edtc: TLabeledEdit;
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BtnDelRowClick(Sender: TObject);
    procedure BtnAddRowClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure sgorderDblClick(Sender: TObject);
    procedure SgorderSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure FormShow(Sender: TObject);
    procedure sgorderDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure sgorderKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure sgorderKeyPress(Sender: TObject; var Key: Char);
    procedure sgorderMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure bitcheckClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    SendMaster: TSendMaster;
    sBillId, SEditMode: string;
    sGoodsName: string;
    sUserCode: string;

    procedure FormIni;
    function CheckData: Boolean;
    function SaveData: Boolean;
    function ReadBill: Boolean;
    procedure SumCol(ACol, ARow: Integer);
    procedure ClearGrid;  
  public
    { Public declarations }
     pcol,prow:integer; //记录行列编号
  end;

var
  FmPosQuestBillStr: TFmPosQuestBillStr;
  function ShowPosQuestBillFmStrGrid(sBillId: string; EditMode: string; iBillType: Integer): Integer;

implementation

uses  UntgoodCodeSelPei, Unt_PubStrGrid, Data,untdatadm, func;

{$R *.dfm}

//外部调用函数 (完全自管理)
function ShowPosQuestBillFmStrGrid(sBillId: string; EditMode: string; iBillType: Integer): Integer;
begin
  Result := 1;
  FmPosQuestBillStr := TFmPosQuestBillStr.Create(nil);
  FmPosQuestBillStr.sBillId := sBillId;
  FmPosQuestBillStr.SEditMode := UpperCase(EditMode);
  FmPosQuestBillStr.SendMaster.iBIlltype := iBillType;
  try
    FmPosQuestBillStr.FormIni;
    FmPosQuestBillStr.ShowModal;
  finally
    FmPosQuestBillStr.Free;
  end;
end;

procedure TFmPosQuestBillStr.BitBtn2Click(Sender: TObject);
begin
  Close;
end;

procedure TFmPosQuestBillStr.sgorderKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (sgorder.Col = 7) then
  begin
    if key = VK_RETURN then
    begin
      sgorder.Col := 8;
      Exit;
    end;
  end;

  if (sgorder.Col = 7) then
  begin
    SumCol(7, sgorder.Row);
    if key = VK_RETURN then
    begin
      sgorder.Col := 8;
      Exit;
    end;
  end;

  if (sgorder.Col = 8) then
  begin
    SumCol(8, sgorder.Row);
    if key = VK_RETURN then
    begin
      if (Trim(sgorder.Cells[1, sgorder.Row]) <> '') or
        (Trim(sgorder.Cells[2, sgorder.Row]) <> '') then
      begin
        if sgorder.Row = (sgorder.RowCount - 1) then
        begin
          sgorder.RowCount := sgorder.RowCount + 1;
        end;

        sgorder.Col := 1;
        sgorder.Row := sgorder.Row + 1;
        Exit;
      end;
    end;
  end;
  if key = VK_RETURN then
    Key := VK_TAB;
{
  if (Key = VK_Insert) and (ssCtrl in Shift) then
 //     sgorder.InsertRows(sgorder.Row, 1);
 if (Key = VK_DELETE) and (ssCtrl in Shift) then
    BtnAddRowClick(sender);
}
end;

procedure TFmPosQuestBillStr.FormIni;
var
  iRow: Integer;
  TEMP,MAKE:STRING;
begin
  EdtMemo.Text := '';
  InitialStrGrid(sgorder,'配送退货单');
  if SendMaster.iBIlltype = 505 then
  begin
    FmPosQuestBillStr.Caption := '门店退货出库单';
    BillTitle.Caption := '门店退货出库单';
  end;
  if SendMaster.iBIlltype = 501 then
  begin
    FmPosQuestBillStr.Caption := '配送收货单';
    BillTitle.Caption := '配送收货单';
  end;
  IF SEditMode = '' THEN
  begin
    ReadBill;
  end;

end;



function TFmPosQuestBillStr.CheckData: Boolean;
var
  iRow: Integer;
begin
//
  Result := False;
  SendMaster.vcExplain := EdtMemo.Text;
  SendMaster.BillNo := EdtBillNo.Text;
  if Trim(SendMaster.BillNo) = '' then
  begin
    EdtBillNo.SetFocus;
    Application.MessageBox('单据编号不能为空!', pchar(application.Title), MB_OK +MB_ICONinformation);
    Exit;
  end;
  if (Trim(edtRecvStock.Text) = '') or
    (SendMaster.vcRecvStockID = '') then
  begin
//    EdtRecvStock.SetFocus;
    Application.MessageBox('收货仓库不能为空!', pchar(application.Title), MB_OK +MB_ICONinformation);
    Exit;
  end;
  if (Trim(edtM.Text) = '') or
    (SendMaster.vcListerId = '') then
  begin
//    EdtM.SetFocus;
    Application.MessageBox('制单人不能为空!', pchar(application.Title), MB_OK +MB_ICONinformation);
    Exit;
  end;
  if (Trim(edtG.Text) = '') or
    (SendMaster.vcEId = '') then
  begin
//    EdtG.SetFocus;
    Application.MessageBox('经手人不能为空!', pchar(application.Title), MB_OK +MB_ICONinformation);
    Exit;
  end;
  if (Trim(edtC.Text) = '') or
    (SendMaster.vcAssessorId = '') then
  begin
//    EdtC.SetFocus;
    Application.MessageBox('审核人不能为空!', pchar(application.Title), MB_OK +MB_ICONinformation);
    Exit;
  end;
  for iRow := 1 to sgorder.RowCount - 1 do
  begin
    if (sgorder.Cells[1, iRow] = '') or (sgorder.Cells[2, iRow] = '') then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 1;
      Application.MessageBox('当前商品不能为空!', pchar(application.Title), MB_OK +MB_ICONinformation);
      Exit;
    end;
    sgorder.Cells[20, iRow] := '1';
{
    if sgorder.Cells[20, iRow] = '' then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 6;
      Application.MessageBox('请选择当前的单位!', pchar(application.Title), MB_OK +MB_ICONinformation);
      Exit;
    end;
}
    if Trim(sgorder.Cells[7, iRow]) = '' then sgorder.Cells[7, iRow] := '0';
    if StrToFloat(sgorder.Cells[7, iRow]) = 0 then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 7;
      Application.MessageBox('请输入退货数量!', pchar(application.Title), MB_OK +MB_ICONinformation);
      Exit;
    end;
    if Trim(sgorder.Cells[8, iRow]) = '' then sgorder.Cells[8, iRow] := '0';
    if StrToFloat(sgorder.Cells[8, iRow]) = 0 then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 6;
      Application.MessageBox('退回价不能为空或零!', pchar(application.Title), MB_OK +MB_ICONinformation);
      Exit;
    end;
    sgorder.Cells[9, iRow] := FloatToStr(StrToFloat(sgorder.Cells[7, iRow]) * StrToFloat(Trim(sgorder.Cells[8, iRow])));
  end;

  Result := True;
end;

procedure TFmPosQuestBillStr.BitBtn1Click(Sender: TObject);
begin
  if not CheckData then Exit;
  if not SaveData then Exit;
  FormIni;
end;

function TFmPosQuestBillStr.SaveData: Boolean;
var
  IRow: Integer;
  fQty, fPrice, fTotal, dRate: Double;
  PsRst, iunit: Integer;
  iEditMode,i: Integer;
  mdata,Ddata:olevariant;//主副表数据
begin
//
  SendMaster.VcSourceId:='0';
  SendMaster.dtDrawDate:=date;
  for i:=1 to sgorder.RowCount-1 do
  begin
    SendMaster.nuTotalMoney:=SendMaster.nuTotalMoney+strtofloat(sgorder.cells[9,i]);
  end;
  Result := False;
  if SEditMode = '' then
    iEditMode := 0
  else
    iEditMode := 1;
  try
   with CdsMasterData do
   begin
   EmptyDataSet;
   Append;
   FieldByName('vcSendBillId').AsString := SendMaster.vcSendBillId;
   FieldByName('VcSourceId').AsString := SendMaster.VcSourceId;
   FieldByName('vcSendStockID').AsString := SendMaster.vcSendStockID;
   FieldByName('vcRecvStockID').AsString := SendMaster.vcRecvStockID;
   FieldByName('vcEId').AsString := SendMaster.vcEId;
   FieldByName('vcListerId').AsString := SendMaster.vcListerId;
   FieldByName('vcAssessorId').AsString := SendMaster.vcAssessorId;
   FieldByName('vcOutHouseReadBillId').AsString := SendMaster.vcOutHouseReadBillId;
   FieldByName('vcExplain').AsString := SendMaster.vcExplain;
   FieldByName('BillStatus').Asinteger := SendMaster.BillStatus;
   FieldByName('iBIlltype').Asinteger := SendMaster.iBIlltype;
   FieldByName('inVoucherSign').Asinteger := SendMaster.inVoucherSign;
   FieldByName('inIsReadSign').Asinteger := SendMaster.inIsReadSign;
   FieldByName('SendStatus').Asinteger := SendMaster.SendStatus;
   FieldByName('NSumQty').AsFloat := SendMaster.NSumQty;
   FieldByName('nuCess').AsFloat := SendMaster.nuCess;
   FieldByName('nuTax').AsFloat := SendMaster.nuTax;
   FieldByName('nuIncTaxSum').AsFloat := SendMaster.nuIncTaxSum;
   FieldByName('nuTotalMoney').AsFloat := SendMaster.nuTotalMoney;
   FieldByName('nuUnTaxSum').AsFloat := SendMaster.nuUnTaxSum;
   FieldByName('dtDrawDate').AsDateTime := SendMaster.dtDrawDate;
   FieldByName('dtOutStockDate').AsDateTime := SendMaster.dtOutStockDate;
   FieldByName('BillNo').AsString := SendMaster.BillNo;
   FieldByName('ObjectID').asInteger := SendMaster.ObjectID;

   end;
   with  CdsDetailData do
   begin
    EmptyDataSet;

⌨️ 快捷键说明

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