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

📄 sfc_wipprice_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Sfc_WipPrice_D;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit, Mask;

Type
  TFrm_Sfc_WipPrice_D = Class(TFrm_Base_Detail)
    Label4: TLabel;
    ExtEdt_ItemCode: TExtEdit;
    Label3: TLabel;
    Lbl_ItemName: TLabel;
    Label1: TLabel;
    Edt_WipInvQty: TEdit;
    Label2: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    MaskEdit1: TMaskEdit;
    Label7: TLabel;
    Edit1: TEdit;
    Label8: TLabel;
    procedure ExtEdt_ItemCodeExit(Sender: TObject);
    procedure Edit1Exit(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure InitControls; Override;
    procedure SaveData; Override;

  public
    { Public declarations }
  end;

var
  Frm_Sfc_WipPrice_D: TFrm_Sfc_WipPrice_D;

implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Sfc_WipPrice_D.InitControls;
begin
  SetFocus_Control:=maskedit1;
  inherited;
  with AdoQry_Maintain do
  begin
    MaskEdit1.Text:=fieldbyname('wiPMonth').asstring;
    edit1.text:=fieldbyname('DeptCode').asstring;
    label8.Caption:=fieldbyname('DeptName').asstring;
    ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').AsString;
    Lbl_ItemName.Caption:=fieldbyname('ItemName').AsString;
    Edt_WipInvQty.Text:=fieldbyname('Itemprice').AsString;
  end;
end;

procedure TFrm_Sfc_WipPrice_D.SaveData;
begin
  inherited;
  if(Add)then
  begin
    with AdoQry_tmp do
    begin
      Close;
      sql.text:='select Count(*) as aa from wipPrice '
            +' Where ItemCode='''+AdoQry_Maintain.fieldbyname('ItemCode').AsString+''''
            +' and wiPMonth='+QuotedStr(MaskEdit1.text)
            +' and DeptCode='+QuotedStr(edit1.text);
      open;
      if fieldbyname('aa').Value>0 then
      begin
         DispInfo('该物料已经定义了价格',1);
         Abort;
      end;
    end;
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='Insert WipPrice(wiPMonth,DeptCode,ItemCode,Itemprice)'
      +' Values('
      +' '''+MaskEdit1.Text+''''
      +','''+edit1.Text+''''
      +', '''+ExtEdt_ItemCode.Text+''''
      +','''+Edt_WipInvQty.Text+''''
      +')';
    AdoQry_Tmp.ExecSQL;
  end
  else
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='Update WipPrice Set'
      +' Itemprice='''+Edt_WipInvQty.Text+''''
      +' Where ItemCode='''+AdoQry_Maintain.fieldbyname('ItemCode').AsString+''''
      +' and wiPMonth='+QuotedStr(MaskEdit1.text)
      +' and DeptCode='+QuotedStr(edit1.text);
    AdoQry_Tmp.ExecSQL;
  end;
  with AdoQry_Maintain do
  begin
    fieldbyname('wiPMonth').asstring:=MaskEdit1.text;
    fieldbyname('DeptCode').asstring:=edit1.Text;
    fieldbyname('DeptName').asstring:=label8.Caption;
    fieldbyname('ItemCode').AsString:= ExtEdt_ItemCode.Text;
    fieldbyname('ItemName').asstring:=Lbl_ItemName.Caption;
    fieldbyname('Itemprice').AsString:=Edt_WipInvQty.Text;
    fieldbyname('UomName').AsString:=label5.Caption;
    Post;
  end;
end;


procedure TFrm_Sfc_WipPrice_D.ExtEdt_ItemCodeExit(Sender: TObject);
begin
  inherited;
  InOutItemCodeCheck(ExtEdt_ItemCode);
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select Item.ItemName,Uom.UomName from Item '+
              ' left join Uom on Item.UomCode=Uom.UomCode '+
              ' where Item.ItemCode='+QuotedStr(ExtEdt_ItemCode.Text);
    open;
    if not eof then
    begin
       Lbl_ItemName.Caption:=fieldbyname('ItemName').AsString;
       label5.Caption:=fieldbyname('UomName').AsString;
    end
    else
    begin
      DispInfo('物料代码不存在',1);
    end;
  end;
end;

procedure TFrm_Sfc_WipPrice_D.Edit1Exit(Sender: TObject);
begin
  inherited;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select DeptName from Dept where DeptCode='+QuotedStr(edit1.Text);
    open;
    if not eof then
      label8.Caption:=fieldbyname('DeptName').AsString
    else
      DispInfo('部门代码不存在',1);
  end;
end;

procedure TFrm_Sfc_WipPrice_D.btn_okClick(Sender: TObject);
begin
  if MaskEdit1.Text='____.__' then
  begin
    DispInfo('月份不可为空',1);
    abort;
  end;
  if edit1.Text='' then
  begin
    DispInfo('部门代码不可为空',1);
    Abort;
  end;
  if ExtEdt_ItemCode.Text='' then
  begin
    DispInfo('物料代码不可为空',1);
    Abort;
  end;
  inherited;
end;

end.

⌨️ 快捷键说明

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