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

📄 unitjhth.~pas

📁 这是一个很好的超市管理系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
      with DM.ADOQJHTH do
      begin
        close;
        SQL.Clear;
        SQL.Add(str3);
        if (not prepared) then
          prepared := true;
        try
          open;
        except
          ExecSQL;
        end;
      end;
    end;
    if (RadioButton3.Checked) then
    begin
      str4 := 'select order_form_id,operator_id,order_person_id,order_person_name,order_total_money,order_pre_money,order_owe_money from order_pay where pay_finish = 0';
      with DM.ADOQJHTH do
      begin
        close;
        SQL.Clear;
        SQL.Add(str4);
        if (not prepared) then
          prepared := true;
        try
          open;
        except
          ExecSQL;
        end;
      end;
    end;
    Combobox1.Enabled := true;
    Combobox1.Color := clwindow;
    DM.ADOQJHTH.Close;
    DM.ADOQJHTH.Open;
end;

procedure TFrmJHTH.RadioButton1Click(Sender: TObject);
begin
  RadioButton2.Checked := false;
  RadioButton3.Checked := false;
  Combobox1.Enabled := false;
  Combobox1.Color := clLtGray;
end;

procedure TFrmJHTH.RadioButton2Click(Sender: TObject);
begin
  RadioButton1.Checked := false;
  RadioButton3.Checked := false;
  Combobox1.Enabled := false;
  Combobox1.Color := clLtGray;
end;

procedure TFrmJHTH.RadioButton3Click(Sender: TObject);
begin
  RadioButton1.Checked := false;
  RadioButton2.Checked := false;
  Combobox1.Enabled := false;
  Combobox1.Color := clLtGray;
end;

procedure TFrmJHTH.BitBtn8Click(Sender: TObject);
var
  ids, sign: integer;
  moneys: real;
  str1, str2, str3: string;
begin
  ids := DM.ADOQJHTH.fieldbyname('order_form_id').Value;
  moneys := DM.ADOQJHTH.fieldbyname('order_pre_money').Value;
  str1 := 'delete from order_pay where order_form_id = :id';
  str2 := 'delete from orders where order_form_id = :id';
  str3 := 'select pay_finish from order_pay where order_form_id = :id';
  with DM.ADOQTEMP1 do
  begin
    close;
    SQL.Clear;
    SQL.Add(str3);
    parameters.ParamByName('id').Value := ids;
    if (not prepared) then
      prepared := true;
    try
      open;
    except
      ExecSQL;
    end;
    sign := fieldbyname('pay_finish').Value;
    if (sign = 1) then
    begin
      showmessage('这条订单已出货,不能删除!');
      exit;
    end;
  end;
  if (messagebox(0,'确定要删除订货单吗?','提示',MB_OKCANCEL) = IDOK) then
  begin
  with DM.ADOQTEMP1 do
  begin
    close;
    SQL.Clear;
    SQL.Add(str1);
    parameters.ParamByName('id').Value := ids;
    if (not prepared) then
      prepared := true;
    try
      ExecSQL;
    except
      showmessage('操作失败,请再试!');
      exit;
    end;
    close;
    SQL.Clear;
    SQL.Add(str2);
    parameters.ParamByName('id').Value := ids;
    if (not prepared) then
      prepared := true;
    try
      ExecSQL;
    except
      messagebox(0, pchar('发生错误,请把订单号为' + inttostr(ids) + '的订货删除,退还订金 + floattostr(moneys) + 元。'), '错误', MB_OK+MB_ICONERROR);
    end;
  end;
  end;
  messagebox(0, pchar('退还订金' + floattostr(moneys) + '元。'), '操作完成',MB_OK);
  DM.ADOQJHTH.Close;
  DM.ADOQJHTH.Open;
end;

procedure TFrmJHTH.BitBtn6Click(Sender: TObject);
var
  array1, array2, array3: array of integer;
  str1, str2, str3, str4: string;
  i,j,num: integer;
  money: real;
begin
  money := DM.ADOQJHTH.fieldbyname('order_owe_money').Value;
  str1 := 'select order_prod_id,order_prod_number from orders where order_form_id = :id';
  str2 := 'update prod set prod_stock = :stock, prod_sale = :sale where prod_id = :id';
  str3 := 'update order_pay set order_owe_money = 0, pay_finish = 1 where order_form_id = :id';
  str4 := 'select prod_stock, prod_sale from prod where prod_id = :id';
  with DM.ADOQTEMP1 do
  begin
    close;
    SQL.Clear;
    SQL.Add(str1);
    parameters.ParamByName('id').Value := DM.ADOQJHTH.fieldbyname('order_form_id').Value;
    if (not prepared) then
      prepared := true;
    try
      open;
    except
      ExecSQL;
    end;
    if recordcount <> 0 then
    begin
      setlength(array1,recordcount);
      setlength(array2,recordcount);
      setlength(array3,30);
      first;
    end;
    num := recordcount;
    for i := 0 to num - 1 do
    begin
      with DM.ADOQTEMP3 do
      begin
        close;
        SQL.Clear;
        SQL.Add(str4);
        parameters.ParamByName('id').Value := DM.ADOQTEMP1.fieldbyname('order_prod_id').Value;
        if (not prepared) then
          prepared := true;
        try
          open;
        except
          ExecSQL;
        end;
        array1[i] := fieldbyname('prod_stock').Value;
        array2[i] := DM.ADOQTEMP1.fieldbyname('order_prod_number').Value;
        array3[i] := fieldbyname('prod_sale').Value;
      end;
      with DM.ADOQTEMP2 do
      begin
        close;
        SQL.Clear;
        SQL.Add(str2);
        parameters.ParamByName('stock').Value := DM.ADOQTEMP3.fieldbyname('prod_stock').Value - DM.ADOQTEMP1.fieldbyname('order_prod_number').Value;
        parameters.ParamByName('sale').Value := DM.ADOQTEMP3.fieldbyname('prod_sale').Value + DM.ADOQTEMP1.fieldbyname('order_prod_number').Value;
        parameters.ParamByName('id').Value := DM.ADOQTEMP1.fieldbyname('order_prod_id').Value;
        if (DM.ADOQTEMP3.fieldbyname('prod_stock').Value - DM.ADOQTEMP1.fieldbyname('order_prod_number').Value < 0) then
        begin
          showmessage('库存数量不足,操作失败,请入货后再试。');
          exit;
        end;
        if (not prepared) then
          prepared := true;
        try
          ExecSQL;
        except
          if i = 0 then
            exit
          else
          begin
            for j := 0 to i -1 do
            begin
              with DM.ADOQTEMP4 do
              begin
                close;
                SQL.Clear;
                SQL.Add(str2);
                parameters.ParamByName('stock').Value := array1[j];
                parameters.ParamByName('sale').Value := array3[j];
                parameters.ParamByName('id').Value := array2[j];
                if (not prepared) then
                  prepared := true;
                try
                  ExecSQL;
                except
                  //showmessage('发生错误,窗口将关闭,系统将从错误中恢复过来!');
                  //self.Close;
                  //self.Free;
                  //exit;
                  messagebox(0, pchar('发生错误,请把编号为' + inttostr(array2[i]) + '商品的库存数量改为' + inttostr(array1[i]) + '已销售数量改为' + inttostr(array2[i]) + ',否则会有严重后果'), '严重错误', MB_OK+MB_ICONWARNING);
                end;
              end;
            end;
          end;
        end;
      end;
    end;
  end;
        {if (not prepared) then
          prepared := true;
        try
          ExecSQL;
        except
          if i = 0 then
            exit
          else
          begin
            for j := 0 to i -1 do
            begin
              with DM.ADOQTEMP4 do
              begin
                close;
                SQL.Clear;
                SQL.Add(str2);
                parameters.ParamByName('stock').Value := array1[i];
                parameters.ParamByName('sale').Value := array3[i];
                parameters.ParamByName('id').Value := array2[i];
                if (not prepared) then
                  prepared := true;
                try
                  ExecSQL;
                except
                  messagebox(0, pchar('发生错误,请把编号为' + inttostr(array2[i]) + '商品的库存数量改为' + inttostr(array1[i]) + '已销售数量改为' + inttostr(array2[i]) + ',否则会有严重后果'), '严重错误', MB_OK+MB_ICONWARNING);
                end;
              end;
            end;
          end;
        end;
      end;
    end;}
      with DM.ADOQTEMP5 do
      begin
        close;
        SQL.Clear;
        SQL.Add(str3);
        parameters.ParamByName('id').Value := DM.ADOQJHTH.fieldbyname('order_form_id').Value;
        if (not prepared) then
          prepared := true;
        try
          ExecSQL;
        except
          for j := 0 to num -1 do
          begin
            with DM.ADOQTEMP4 do
            begin
              close;
              SQL.Clear;
              SQL.Add(str2);
              parameters.ParamByName('stock').Value := array1[i];
              parameters.ParamByName('sale').Value := array3[i];
              parameters.ParamByName('id').Value := array2[i];
              if (not prepared) then
                prepared := true;
              try
                ExecSQL;
              except
                messagebox(0, pchar('发生错误,请把编号为' + inttostr(array2[i]) + '商品的库存数量改为' + inttostr(array1[i]) + '已销售数量改为' + inttostr(array2[i]) + ',否则会有严重后果'), '严重错误', MB_OK+MB_ICONWARNING);
              end;
            end;
          end;
        end;
      end;
   messagebox(0,pchar('请交余额' + floattostr(money) + '然后取货'), '提示', MB_OK+MB_ICONINFORMATION);
   DM.ADOQJHTH.Close;
   DM.ADOQJHTH.Open;
   DBGrid2.Refresh;
end;
procedure TFrmJHTH.BitBtn7Click(Sender: TObject);
begin
  self.Close;
end;

procedure TFrmJHTH.FormKeyPress(Sender: TObject; var Key: Char);
var e:TEdit;
begin //规范数字输入
  e:= (Sender as TEdit); //需要限制输入的控件可共享这段代码
  if not(key in [#48..#57,'.','-',#8]) //可接受的字符
      or(key='-')and(e.SelStart>0)  //负号只能在串首
      or(key='.')and(pos( '.',e.Text)>0)then key:=#0; //只接受一个小数点

end;



procedure TFrmJHTH.DBGrid1CellClick(Column: TColumn);
var
  str1: string;
  ids: integer;
begin
  //totalmon := DM.ADOQJHTH.fieldbyname('order_total_money').Value;
  ids := DM.ADOQJHTH.fieldbyname('order_form_id').Value;
  str1 := ' select order_form_id, operator_id, order_id, order_prod_id, '
    + ' order_prod_name, order_prod_price, order_prod_number, order_money,order_person_id, '
    + ' order_person_name, order_time, order_deliver_time, order_memo from orders where order_form_id = :id ';
  with DM.ADOQCHTH do
  begin
    close;
    SQL.Clear;
    SQL.Add(str1);
    parameters.ParamByName('id').Value := ids;
    if (not prepared) then
      prepared := true;
    try
      open;
    except
      ExecSQL;
    end;
  end;

  //DM.ADOQCHTH.Close;
  //DM.ADOQCHTH.Open;
end;



procedure TFrmJHTH.ComboBox1Change(Sender: TObject);
begin
  RadioButton1.Checked := false;
  RadioButton2.Checked := false;
  RadioButton3.Checked := false;
end;

end.


⌨️ 快捷键说明

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