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

📄 existbilledit.pas

📁 中小企业管理系统------ ERP系统原代码
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    dConstPrice := ADOSetList.FieldByName('ConstPrice').AsFloat;
    dTotal := dNumber * dConstPrice;

    {EXIST_CHECK_LIST = 124; //库存盘点 }
    if lType = 2 then
      case lMode of //修改商品库存
        EXIST_RETURN:
          if not UpdateStock(1, lWareID, lDepotID, dNumber, dConstPrice, dTotal) then
            Exit; //入库
        EXIST_DRAW:
          if not UpdateStock(1, lWareID, lDepotID, -dNumber, dConstPrice, -dTotal) then
            Exit; //出库
        EXIST_LOSING:
          if not UpdateStock(1, lWareID, lDepotID, -dNumber, dConstPrice, -dTotal) then
            Exit; //出库
        EXIST_INCREASE:
          if not UpdateStock(1, lWareID, lDepotID, dNumber, dConstPrice, dTotal) then
            Exit; //入库
        EXIST_GAIN:
          if not UpdateStock(1, lWareID, lDepotID, dNumber, dConstPrice, dTotal) then
            Exit; //入库
        EXIST_PRESENT:
          if not UpdateStock(1, lWareID, lDepotID, -dNumber, dConstPrice, -dTotal) then
            Exit; //出库
        EXIST_ENTER_DEPOT:
          begin
            if not UpdateStock(1, lWareID, 0, -dNumber, dConstPrice, -dTotal) then
              Exit; //出库
            if not UpdateStock(1, lWareID, lDepotID, dNumber, dConstPrice, dTotal) then
              Exit; //入库
          end;
        EXIST_EXCHANGE:
          begin
            if not UpdateStock(1, lWareID, lDepotID, -dNumber, dConstPrice, -dTotal) then
              Exit; //出库
            if not UpdateStock(1, lWareID, lDepotID2, dNumber, dConstPrice, dTotal) then
              Exit; //入库
          end;
        EXIST_PRICE_EXCHANGE:
          begin
            if not UpdateStock(1, lWareID, lDepotID, -dNumber, dConstPrice, -dTotal) then
              Exit; //出库
            if not UpdateStock(1, lWareID, lDepotID2, dNumber, dPrice, dTotal) then
              Exit; //入库
          end;
        EXIST_CHANGE_PRICE:
          begin
            if not UpdateStock(1, lWareID, lDepotID, -dNumber, dConstPrice, -dTotal) then
              Exit; //出库
            if not UpdateStock(1, lWareID, lDepotID, dNumber, dPrice1, dTotal) then
              Exit; //入库
          end;
        EXIST_ASSEMBLY:
          begin
            if rbZh.Checked then
            begin
              if not UpdateStock(1, lWareID, lDepotID, -dNumber, dPrice, -dTotal) then
                Exit; //出库
            end
            else
              if not UpdateStock(1, lWareID, lDepotID, dNumber, dPrice1, dTotal) then
                Exit //入库
          end;
        EXIST_OTHER:
          begin
            if edtInvoice.ItemIndex = 0 then
            begin
              if not UpdateStock(1, lWareID, lDepotID, dNumber, dConstPrice, dTotal) then
                Exit //入库
            end
            else
              if not UpdateStock(1, lWareID, lDepotID, -dNumber, dConstPrice, -dTotal) then
                Exit //出库
          end;
        EXIST_CHECK_LIST:
          if not UpdateStock(1, lWareID, lDepotID, dNumber, dPrice1, dTotal, 'CheckWareStock') then
            Exit; //入盘点库
      end;
    ADOSetList.Next;
  end;
  if not SaveDataSet2(ADOSetList, sUniqueTable) then
  begin
    RollbackTrans;
    Exit;
  end;
  ADOSetList.EnableControls;
  GetAutoSerial(lMode, 1);
  CommitTrans;
  lID := 0;
end;

procedure TfrmExistBillEdit.edtUnitButtonClick(Sender: TObject;
  AbsoluteIndex: Integer);
var
  sUnitID: string;
begin
  inherited;
  if edtUnit.ReadOnly then
    Exit;
  if (lMode >= STOCK_ORDER_EDIT) and (lMode <= STOCK_BACK_EDIT) then
    sUnitID := BaseSelect(BASE_PROVIDE, 1, edtUnit.Text)
  else
    sUnitID := BaseSelect(BASE_CLIENT, 1, edtUnit.Text);
  if (sUnitID <> '') then
  begin
    ADOSetMaster.FieldByName('UnitID').AsInteger := StrToInt2(sUnitID);
    edtUnit.Text := FieldIdToName('Unit', sUnitID, 'Name');
  end;
end;

procedure TfrmExistBillEdit.edtEmployeButtonClick(Sender: TObject;
  AbsoluteIndex: Integer);
var
  sEmployeID: string;
begin
  inherited;
  if edtEmploye.ReadOnly then
    Exit;
  sEmployeID := BaseSelect(BASE_EMPLOYE, 1, edtEmploye.Text);
  if (sEmployeID <> '') then
  begin
    ADOSetMaster.FieldByName('EmployeID').AsInteger := StrToInt2(sEmployeID);
    edtEmploye.Text := FieldIdToName('Employe', sEmployeID, 'Name');
  end;
end;

function TfrmExistBillEdit.CheckMsg: Boolean;
var
  lVal: Integer;
begin
  Result := False;
  if not CheckEditEmpty(1, self, [lblBillDate.Name, lblUserCode.Name, lblUnit.Name, lblEmploye.Name],
    [edtBillDate.Name, edtUserCode.Name, edtUnit.Name, edtEmploye.Name]) then
    Exit;
  lVal := CheckDataSetColValue(ADOSetList, 'Number', 0);
  if lVal > 0 then
  begin
    ShowMsg('表格第' + IntToStr(lVal) + '行数量不能为0!');
    Exit;
  end;
  {  lVal := CheckDataSetColValue(ADOSetList, 'Price', 0);
    if not bPriceCan0 and (lVal > 0) then
    begin
      ShowMsg('表格第' + IntToStr(lVal) + '行单价不能为0!');
      Exit;
    end;}
  Result := True;
end;

procedure TfrmExistBillEdit.bbOkClick(Sender: TObject);
var
  lRet, lType: Integer;
begin
  inherited;
  if not CheckMsg then Exit;
  lRet := MsgBox('你可以将单据保存为过账单据,也可保存为草稿!' + #13 + '是:过账单据。  否:草稿单据。', '提示',
    MB_YESNOCANCEL);
  case lRet of
    IDYES: lType := 2;
    IDNO: lType := 3;
  else
    Exit;
  end;
  SaveData(lType);
  LoadData;
end;

procedure TfrmExistBillEdit.edtDepotButtonClick(Sender: TObject;
  AbsoluteIndex: Integer);
var
  sDepot: string;
begin
  inherited;
  if edtDepot.ReadOnly then
    Exit;
  sDepot := BaseSelect(BASE_DEPOT, 1, edtDepot.Text);
  if (sDepot <> '') then
  begin
    ADOSetMaster.FieldByName('DepotID').AsInteger := StrToInt2(sDepot);
    edtDepot.Text := FieldIdToName('Depot', sDepot, 'Name');
  end;
end;

procedure TfrmExistBillEdit.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  SaveGirdWidth;
end;

procedure TfrmExistBillEdit.mnPrintInitClick(Sender: TObject);
begin
  inherited;
  PrintForm(Self, 1, INITI_REPORT, sPrintFile);
end;

procedure TfrmExistBillEdit.bbSetupClick(Sender: TObject);
begin
  inherited;
  if BillSetupShow(lMode) then
    ShowMsg('改动的单据格式将会在退出这张单据时生效!');
end;

procedure TfrmExistBillEdit.bbPrevClick(Sender: TObject);
begin
  if (lID = 0) and (ADOSetList.RecordCount > 0) and
    ((ADOSetMaster.State = dsInsert) or (ADOSetMaster.State = dsEdit)) then
  begin
    case MsgBox('你没有保存数据,确定保存?', '提示', MB_YESNOCANCEL) of
      IDOK:
        begin
          if not CheckMsg then
            Exit;
          SaveData(2);
        end;
      IDNO:
        begin
          ADOSetList.Cancel;
          ADOSetMaster.Cancel;
        end;
    else
      Exit;
    end;
  end;
  inherited;
  LoadData;
end;

procedure TfrmExistBillEdit.bbNextClick(Sender: TObject);
begin
  if (lID = 0) and (ADOSetList.RecordCount > 0) and
    ((ADOSetMaster.State = dsInsert) or (ADOSetMaster.State = dsEdit)) then
  begin
    case MsgBox('你没有保存数据,确定保存?', '提示', MB_YESNOCANCEL) of
      IDOK:
        begin
          if not CheckMsg then
            Exit;
          SaveData(2);
        end;
      IDNO:
        begin
          ADOSetList.Cancel;
          ADOSetMaster.Cancel;
        end;
    else
      Exit;
    end;
  end;
  inherited;
  LoadData;
end;

procedure TfrmExistBillEdit.edtBillDateKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  case KEY of
    VK_DOWN: SendMsg(TWinControl(Sender).Handle, WM_KEYDOWN, VK_F4);
  end;
end;

procedure TfrmExistBillEdit.BillRowSummary;
begin
  if gridMain.ColumnByFieldName('WareID').Field.AsInteger > 0 then
    CalcRowSummary(gridMain, 'Number,Price', 'Total', 1); //计算行合计
end;

procedure TfrmExistBillEdit.gridMainChangeColumn(Sender: TObject;
  Node: TdxTreeListNode; Column: Integer);
begin
  inherited;
  BillRowSummary;
end;

procedure TfrmExistBillEdit.edtDepot2ButtonClick(Sender: TObject;
  AbsoluteIndex: Integer);
var
  sDepot: string;
begin
  inherited;
  if edtDepot2.ReadOnly then
    Exit;
  sDepot := BaseSelect(BASE_DEPOT, 1, edtDepot2.Text);
  if (sDepot <> '') then
  begin
    ADOSetMaster.FieldByName('DepotID2').AsInteger := StrToInt2(sDepot);
    edtDepot2.Text := FieldIdToName('Depot', sDepot, 'Name');
  end;
end;

procedure TfrmExistBillEdit.edtWareButtonClick(Sender: TObject;
  AbsoluteIndex: Integer);
var
  sWareID: string;
begin
  if edtWare.ReadOnly then
    Exit;
  sWareID := BaseSelect(BASE_WARE, 1, edtWare.Text);
  if (sWareID <> '') then
  begin
    ADOSetMaster.FieldByName('WareID').AsInteger := StrToInt2(sWareID);
    edtWare.Text := FieldIdToName('Ware', sWareID, 'Name');
    ADOSetMaster.FieldByName('Price').AsString := FieldIdToName('Ware', sWareID, 'Pos_Price');
  end;
end;

procedure TfrmExistBillEdit.CalcTotal;
begin
  case lMode of
    EXIST_ASSEMBLY:
      with ADOSetMaster do
      begin
        //        FieldByName('Total').AsFloat := FieldByName('Price').AsFloat * FieldByName('Number').AsFloat;
      end;
  end;
end;

procedure TfrmExistBillEdit.edtNumberExit(Sender: TObject);
begin
  inherited;
  CalcTotal;
end;

procedure TfrmExistBillEdit.edtPriceExit(Sender: TObject);
begin
  inherited;
  CalcTotal;
end;

procedure TfrmExistBillEdit.ADOSetListBeforeScroll(DataSet: TDataSet);
begin
  inherited;
  BillRowSummary;
end;

procedure TfrmExistBillEdit.edtUnitExit(Sender: TObject);
begin
  inherited;
  if edtUnit.Text = '' then
    ADOSetMaster.FieldByName('UnitID').AsInteger := 0;
end;

procedure TfrmExistBillEdit.edtEmployeExit(Sender: TObject);
begin
  inherited;
  if edtEmploye.Text = '' then
    ADOSetMaster.FieldByName('EmployeID').AsInteger := 0;
end;

procedure TfrmExistBillEdit.edtWareExit(Sender: TObject);
begin
  inherited;
  if edtWare.Text = '' then
    ADOSetMaster.FieldByName('WareID').AsInteger := 0;
end;

procedure TfrmExistBillEdit.edtDepotExit(Sender: TObject);
begin
  inherited;
  if edtDepot.Text = '' then
    ADOSetMaster.FieldByName('DepotID').AsInteger := 0;
end;

procedure TfrmExistBillEdit.edtDepot2Exit(Sender: TObject);
begin
  inherited;
  if edtDepot2.Text = '' then
    ADOSetMaster.FieldByName('DepotID2').AsInteger := 0;
end;

end.



//此源码由程序太平洋收集整理发布,任何人都可自由转载,但需保留本站信息
//╭⌒╮┅~ ¤ 欢迎光临程序太平洋╭⌒╮
//╭⌒╭⌒╮╭⌒╮~╭⌒╮  ︶  ,︶︶
//,︶︶︶︶,''︶~~ ,''~︶︶  ,''
//╔ ╱◥███◣═╬╬╬╬╬╬╬╬╬╗
//╬ ︱田︱田 田 ︱          ╬
//╬       http://www.5ivb.net ╬
//╬  ╭○╮●                     ╬
//╬  /■\/■\                    ╬
//╬   <| ||    有希望,就有成功! ╬
//╬                 ╬
//╚╬╬╬╬╬╬╬╬╬╬╗  ╔╬╬╬╬╝
//
//说明:
//专业提供VB、.NET、Delphi、ASP、PB源码下载
//包括:程序源码,控件,商业源码,系统方案,开发工具,书籍教程,技术文档

⌨️ 快捷键说明

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