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

📄 xg_dj.pas

📁 汽配前台收费,一个具有详细功能的小系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    pe_yj.Enabled := False;
    //
    cb_bx.Checked := False;
    lbl_kind.Caption := '维修类型';
    combo_wx_kind.Visible := True;
    combo_wx_kind.ItemIndex := -1;
    combo_bx_kind.Visible := False;
    combo_bx_kind.ItemIndex := -1;
    //
    cmd_edit.Enabled := False;
    cmd_save.Enabled := False;
    cmd_cancel.Enabled := False;
    cmd_refresh.Enabled := False;
    cmd_print.Enabled := False;
  end;
end;

procedure Tfrm_xg_dj.cmd_qClick(Sender: TObject);
begin
  QueryResult;
end;

procedure Tfrm_xg_dj.cmd_editClick(Sender: TObject);
begin
  EditInit;
end;

procedure Tfrm_xg_dj.cmd_saveClick(Sender: TObject);
var
  intResult: integer;
begin
  intResult := RuleCheck;
  if intResult = 1 then
    Exit
  else if intResult = 0 then begin
    if qe_cl.State = dsEdit then begin
      controlDj(dsEdit);
      qe_cl.Post;
    end;
  end;
  //
  SaveInit;
end;

function Tfrm_xg_dj.RuleCheck: integer;
var
  intResult: integer;
  strYear, strMonth, strDay: string;
  v: Double;
  code: integer;
begin
  intResult := 0;
  if Trim(txt_dj_time.EditText) = '0000-00-00' then begin
    MessageBox(Handle, '请确定登记时间', '沈阳信德', MB_ICONQUESTION or MB_OK);
    txt_dj_time.SetFocus;
    intResult := 1;
  end else begin
    strYear := Copy(Trim(txt_dj_time.EditText), 1, 4);
    strMonth := Copy(Trim(txt_dj_time.EditText), 6, 2);
    strDay := Copy(Trim(txt_dj_time.EditText), 9, 2);
    if (StrToInt(strYear) < 1980) or (StrToInt(strMonth) = 0) or (StrToInt(strDay) = 0) then begin
      MessageBox(Handle, '登记时间无效', '沈阳信德', MB_ICONQUESTION or MB_OK);
      txt_dj_time.SetFocus;
      intResult := 1;
    end else begin
      if Trim(txt_jc_time.EditText) = '0000-00-00' then begin
        MessageBox(Handle, '请确定交车时间', '沈阳信德', MB_ICONQUESTION or MB_OK);
        txt_jc_time.SetFocus;
        intResult := 1;
      end else begin
        strYear := Copy(Trim(txt_jc_time.EditText), 1, 4);
        strMonth := Copy(Trim(txt_jc_time.EditText), 6, 2);
        strDay := Copy(Trim(txt_jc_time.EditText), 9, 2);
        if (StrToInt(strYear) < 1980) or (StrToInt(strMonth) = 0) or (StrToInt(strDay) = 0) then begin
          MessageBox(Handle, '交车时间无效', '沈阳信德', MB_ICONQUESTION or MB_OK);
          txt_jc_time.SetFocus;
          intResult := 1;
        end else begin
          if Trim(txt_cph.Text) = '' then begin
            MessageBox(Handle, '请确定车牌号', '沈阳信德', MB_ICONQUESTION or MB_OK);
            txt_cph.SetFocus;
            intResult := 1;
          end else begin
            if Trim(txt_cx.Text) = '' then begin
              MessageBox(Handle, '请确定车型', '沈阳信德', MB_ICONQUESTION or MB_OK);
              txt_cx.SetFocus;
              intResult := 1;
            end else begin
              if (Trim(txt_cz.Text) = '') and (Trim(txt_czdw.Text) = '') then begin
                MessageBox(Handle, '请确定车主姓名或者车主单位', '沈阳信德', MB_ICONQUESTION or MB_OK);
                txt_cz.SetFocus;
                intResult := 1;
              end else begin
                if (cb_yj.Checked) and (Trim(txt_yj.Text) = '') then begin
                  MessageBox(Handle, '请确定押金金额', '沈阳信德', MB_ICONQUESTION or MB_OK);
                  txt_yj.SetFocus;
                  intResult := 1;
                end else begin
                  if (cb_yj.Checked) then begin
                    Val(Trim(txt_yj.Text), v, code);
                    if (code <> 0) or (v < 0.01) then begin
                      MessageBox(Handle, '押金金额无效', '沈阳信德', MB_ICONQUESTION or MB_OK);
                      txt_yj.SetFocus;
                      Result := 1;
                      Exit;
                    end;
                  end;
                  //
                  if (cb_bx.Checked) and (combo_bx_kind.ItemIndex = -1) then begin
                    MessageBox(Handle, '请确定保险类型', '沈阳信德', MB_ICONQUESTION or MB_OK);
                    combo_bx_kind.SetFocus;
                    Result := 1;
                    Exit;
                  end;
                  //
                  if (not cb_bx.Checked) and (combo_wx_kind.ItemIndex = -1) then begin
                    MessageBox(Handle, '请确定维修类型', '沈阳信德', MB_ICONQUESTION or MB_OK);
                    combo_wx_kind.SetFocus;
                    Result := 1;
                    Exit;
                  end;
                end;
              end;
            end;
          end;
        end;
      end;
    end;
  end;
  //
  Result := intResult;
end;

procedure Tfrm_xg_dj.controlDj(intState: TDataSetState);
var
  cur_yj: Double;
begin
  if intState = dsEdit then begin
    qe_cl.FieldByName('dj_cph').AsString := Trim(txt_cph.Text);
    qe_cl.FieldByName('dj_cx').AsString := Trim(txt_cx.Text);
    qe_cl.FieldByName('dj_dph').AsString := Trim(txt_dph.Text);
    qe_cl.FieldByName('dj_fdjh').AsString := Trim(txt_fdjh.Text);
    qe_cl.FieldByName('dj_cz').AsString := Trim(txt_cz.Text);
    qe_cl.FieldByName('dj_czdw').AsString := Trim(txt_czdw.Text);
    qe_cl.FieldByName('dj_tel').AsString := Trim(txt_tel.Text);
    qe_cl.FieldByName('dj_addr').AsString := Trim(txt_addr.Text);
    qe_cl.FieldByName('dj_time').AsString := Trim(txt_dj_time.EditText);
    qe_cl.FieldByName('dj_jctime').AsString := Trim(txt_jc_time.EditText);
    if cb_bx.Checked then begin
      qe_cl.FieldByName('dj_bx_bs').AsInteger := 1;
      qe_cl.FieldByName('dj_bx_kind').AsString := combo_bx_kind.Text;
      qe_cl.FieldByName('dj_wx_kind').AsString := '无';
    end else begin
      qe_cl.FieldByName('dj_bx_bs').AsInteger := 0;
      qe_cl.FieldByName('dj_wx_kind').AsString := combo_wx_kind.Text;
      qe_cl.FieldByName('dj_bx_kind').AsString := '无';
    end;
    if cb_yj.Checked then begin
      qe_cl.FieldByName('dj_yj_bs').AsInteger := 1;
      //
      cur_yj := StrToFloat(Trim(txt_yj.Text));
      cur_yj := Int(cur_yj) + Round((Frac(cur_yj)*100))/100;
      //
      qe_cl.FieldByName('dj_yj_zf').Value := cur_yj;
    end else begin
      qe_cl.FieldByName('dj_yj_bs').AsInteger := 0;
      qe_cl.FieldByName('dj_yj_zf').Value := 0;
    end;
  end;
end;

procedure Tfrm_xg_dj.cmd_cancelClick(Sender: TObject);
begin
  CancelInit;
end;

procedure Tfrm_xg_dj.cmd_refreshClick(Sender: TObject);
begin
  qe_cl.Close;
  qe_cl.Open;
  qe_cl.First;
  //
  EnabledComponent(dsBrowse);
end;

procedure Tfrm_xg_dj.cb_yjClick(Sender: TObject);
begin
  if qe_cl.State = dsEdit then begin
    EnabledComponent(dsEdit);
    if cb_yj.Checked then begin
      pe_yj.Enabled := True;
      txt_yj.SetFocus;
    end else begin
      txt_yj.OnChange := nil;
      txt_yj.Text := '';
      txt_yj.OnChange := frm_xg_dj.controlChange1;
      pe_yj.Enabled := False;
    end;
  end;
end;

procedure Tfrm_xg_dj.cb_bxClick(Sender: TObject);
begin
  if qe_cl.State = dsEdit then begin
    EnabledComponent(dsEdit);
    if cb_bx.Checked then begin
      lbl_kind.Caption := '保险类型:';
      combo_wx_kind.Visible := False;
      combo_bx_kind.Visible := True;
      combo_bx_kind.ItemIndex := -1;
      combo_bx_kind.SetFocus;
    end else begin
      lbl_kind.Caption := '维修类型:';
      combo_wx_kind.Visible := True;
      combo_bx_kind.Visible := False;
      combo_wx_kind.ItemIndex := -1;
      combo_wx_kind.SetFocus;
    end;
  end;
end;

procedure Tfrm_xg_dj.cmd_printClick(Sender: TObject);
var
  intPos: integer;
  intPos1: integer;
  cur_yj: Double;
begin
  combo_p.Items.Clear;
  combo_p.items.Assign(Printer.Printers);
  if combo_p.Items.Count = 0 then begin
    MessageBox(Handle, '没有可用的打印机,请添加打印机', '沈阳信德', MB_ICONQUESTION or MB_OK);
    Exit;
  end;
  //
  if not Assigned(frm_yj_select) then begin
    frm_yj_select := Tfrm_yj_select.Create(Application);
    frm_yj_select.ShowModal;
  end;
  //
  if frm_log.yj_jsfs = - 1 then Exit;  
  //
  cur_yj := StrToFloat(Trim(txt_yj.Text));
  cur_yj := Int(cur_yj) + Round((Frac(cur_yj)*100))/100;
  //
  qe_jy.Close;
  qe_jy.SQL.Clear;
  qe_jy.SQL.Add('SELECT * FROM CL_DJ WHERE DJ_BH = ''' + cur_bh + ''' AND DJ_ZF_BS = 0');
  qe_jy.Open;
  qe_jy.First;
  if (qe_jy.Bof) and (qe_jy.Eof) then begin
    MessageBox(Handle, '该登记已经作废,请按<刷新登记>刷新当前登记', '沈阳信德', MB_ICONQUESTION or MB_OK);
    Exit;
  end;
  //
  intPos := qe_jy.FieldByName('dj_yj_jsbs').AsInteger;
  intPos1 := qe_jy.FieldByName('dj_yj_print').AsInteger;
  qe_jy.Close;
  //
  if intPos = 0 then begin
    sp_up_cl_dj.ParamByName('@ibh').Value := cur_bh;
    sp_up_cl_dj.Prepare;
    sp_up_cl_dj.ExecProc;
    sp_up_cl_dj.UnPrepare;
    //
    sp_insert_into_day.ParamByName('@idate').Value := frm_log.controlDate(DateToStr(Date()));
    sp_insert_into_day.ParamByName('@izy').Value := '(押金)-' + Trim(txt_cph.Text) + '-' + Trim(txt_cx.Text) + '收款';
    if frm_log.yj_jsfs = 1 then
      sp_insert_into_day.ParamByName('@ikm').Value := '现金'
    else
      sp_insert_into_day.ParamByName('@ikm').Value := '银行存款';
    //  
    sp_insert_into_day.ParamByName('@ijf').Value := cur_yj;
    sp_insert_into_day.ParamByName('@idf').Value := 0;
    sp_insert_into_day.ParamByName('@izy_id').Value := 4;
    sp_insert_into_day.ParamByName('@idj_bh').Value := cur_bh;
    sp_insert_into_day.ExecProc;
    //
    YJ_BH := SetNewBH1(4);
    //
    frm_print.pc_main.ActivePageIndex := 0;
    if frm_log.yj_jsfs = 1 then
      frm_print.lbl_fs.Caption := '现金'
    else
      frm_print.lbl_fs.Caption := '支票';
    frm_print.lbl_cap.Caption := frm_log.cur_gs_name;
    frm_print.lbl_tel.Caption := frm_log.cur_gs_tel;
    frm_print.lbl_addr.Caption := frm_log.cur_gs_addr;
    frm_print.lbl_date.Caption := frm_log.controlDate(DateToStr(Date()));
    frm_print.lbl_bh.Caption := 'YJ' + YJ_BH;
    frm_print.lbl_jnr.Caption := Trim(txt_cz.Text);
    frm_print.lbl_dw.Caption := Trim(txt_czdw.Text);
    frm_print.lbl_cph.Caption := Trim(txt_cph.Text);
    frm_print.lbl_cx.Caption := Trim(txt_cx.Text);
    frm_print.lbl_dx.Caption := frm_log.shiftNum(cur_yj);
    frm_print.lbl_xx.Caption := frm_log.ControlNum(FloatToStr(cur_yj)) + '元';
    frm_print.lbl_czr.Caption := frm_main.user_name;
    frm_print.qr_yj.Print;
  end else begin
    if intPos1 = 1 then begin
      MessageBox(Handle, '押金凭证已经打印,要想重新打印请通知财务员', '沈阳信德', MB_ICONQUESTION or MB_OK);
      Exit;
    end else begin
      sp_up_cl_dj.ParamByName('@ibh').Value := cur_bh;
      sp_up_cl_dj.ExecProc;
      //
      frm_print.pc_main.ActivePageIndex := 0;
      frm_print.lbl_cap.Caption := frm_log.cur_gs_name;
      frm_print.lbl_tel.Caption := frm_log.cur_gs_tel;
      frm_print.lbl_addr.Caption := frm_log.cur_gs_addr;
      frm_print.lbl_date.Caption := frm_log.controlDate(DateToStr(Date()));
      if frm_log.yj_jsfs = 1 then
        frm_print.lbl_fs9.Caption := '现金'
      else
        frm_print.lbl_fs9.Caption := '支票';
      frm_print.lbl_bh.Caption := 'SJ' + YJ_BH;
      frm_print.lbl_jnr.Caption := Trim(txt_cz.Text);
      frm_print.lbl_dw.Caption := Trim(txt_czdw.Text);
      frm_print.lbl_cph.Caption := Trim(txt_cph.Text);
      frm_print.lbl_cx.Caption := Trim(txt_cx.Text);
      frm_print.lbl_dx.Caption := frm_log.shiftNum(cur_yj);
      frm_print.lbl_xx.Caption := frm_log.ControlNum(FloatToStr(cur_yj)) + '元';
      frm_print.lbl_czr.Caption := frm_main.user_name;
      frm_print.qr_yj.Print;
    end;
  end;
end;

procedure Tfrm_xg_dj.FormShow(Sender: TObject);
begin
  qe_cl.Close;
  //
  qe_bx.Close;
  qe_bx.Open;
  qe_bx.First;
  while not qe_bx.Eof do begin
    combo_bx_kind.Items.Add(Trim(qe_bx.FieldByName('kind_name').AsString));
    qe_bx.Next;
  end;
  qe_bx.Close;
  //
  cmd_edit.Enabled := False;
  cmd_save.Enabled := False;
  cmd_cancel.Enabled := False;
  cmd_refresh.Enabled := False;
  cmd_print.Enabled := False;
  //
  frm_main.mu_yw_xg_dj.Enabled := False;
  //
  frm_main.current_handle := Handle;
end;

procedure Tfrm_xg_dj.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure Tfrm_xg_dj.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
var
  intResult: integer;
begin
  CanClose := True;
  //
  if (qe_cl.State = dsEdit) then begin
    if cmd_save.Enabled then begin
      intResult := MessageBox(Handle, '记录正被编辑, 是否在关闭窗体前保存所作修改?', '沈阳信德', MB_YESNOCANCEL or MB_ICONQUESTION);
      if intResult = ID_YES then begin
        intResult := RuleCheck;
        if intResult = 1 then begin
          CanClose := False;
          Exit;
        end;
        controlDj(dsEdit);
        qe_cl.Post;
        CanClose := True;
      end else if intResult = ID_NO then begin
        qe_cl.Cancel;
        CanClose := True;
      end else if intResult = ID_CANCEL then
        CanClose := False;
    end;
  end;
  //
  if CanClose then begin
    qe_cl.Close;
    qe_jy.Close;
    qe_bx.Close;
    //
    frm_main.mu_yw_xg_dj.Enabled := True;
    frm_main.current_handle := 0;
    //
    frm_main.Tag := 1; //标识窗体能否关闭; 1-能关闭;2-不能关闭;
  end;
end;

procedure Tfrm_xg_dj.FormDestroy(Sender: TObject);
begin
  qe_cl := nil;
  qe_jy := nil;
  qe_bx := nil;
  //
  frm_xg_dj := nil;
end;

end.

⌨️ 快捷键说明

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