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

📄 unit_dictionary.pas

📁 用delphi开发的美容院管理系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  sbtn_front.Enabled := false;
  sbtn_back.Enabled  := false;
  if sg_MealType.RowCount >3 then sbtn_back.Enabled := true;
end;

procedure Tfrm_dictionary.ClearServiceMealTypeInfo ();
begin
  edt_MealTypeid.Text :='';
  edt_MealTypename.Text :='';
  edt_Mealtyperemark.Text :='';
end;

procedure Tfrm_dictionary.MakeServiceMealTypeEnabled(temp:boolean);
begin
  if sbtn_append.enabled then
     sbtn_save.Enabled :=true
  else
     sbtn_save.Enabled :=false;
  sbtn_delete.Enabled  :=false;
  edt_MealTypeid.Enabled :=temp;
  edt_Mealtypename.Enabled :=temp;
  edt_Mealtyperemark.Enabled :=temp;
end;

function Tfrm_dictionary.SaveServiceMealTypeInfo ():boolean;
begin
  result := true;
  if trim(edt_MealTypename.Text)='' then
  begin
    Messagebox(handle,'请输入服务套餐名称!','提示',mb_ok+mb_iconinformation);
    result:=false;
    edt_MealTypename.SetFocus ;
    exit;
  end;

  MealTypeid:=trim(edt_Mealtypeid.Text );
  if MealTypeAppendOrEdit then
  with dmod.qrydata do
  begin
    close;
    SQL.Text := 'select type_id from ServiceMealType where type_id=:typeid';
    ParamByName('typeid').AsString := MealTypeid;
    Open;
    if not eof then
    begin
      MessageBox(self.handle,'该员工类别编号已经存在,请重新确认!','提示',mb_ok+mb_iconinformation);
      edt_MealTypeid.SetFocus ;
      result:=false;
      exit;
    end;
  end;
  
  with dmod.qrydata do
  begin
    close;
    SQL.Text := 'select type_id from ServiceItemType where type_name=:typename';
    ParamByname('typename').AsString := trim(edt_MealTypename.Text);
    open;
    if not eof then
    if FieldByName('type_id').AsString <> Mealtypeid then
    begin
      MessageBox(self.Handle ,'该员工姓名已经存在,请重新确认!','提示',mb_ok+mb_iconinformation);
      edt_MealTypename.SetFocus ;
      result := false;
      exit;
    end;
  end;
  
  try
    dmod.Database.StartTransaction ;
    with dmod.qrydata do
    begin
      close;
      SQL.Text := 'delete from ServiceMealType where type_id=:typeid';
      ParamByName('typeid').AsString := MealTypeId;
      ExecSQL;

      close;
      SQL.Text := 'insert into ServiceMealType(type_id,type_name,type_remark) values(:typeid,:typename,:typeremark)';
      ParamByName('typeid').AsString := trim(edt_Mealtypeid.Text );
      ParamByName('typename').AsString := trim(edt_Mealtypename.Text );
      ParamByName('typeremark').AsString := trim(edt_Mealtyperemark.Text );
      ExecSQL;
    end;
  finally
    try
      dmod.Database.Commit ;
    except
      dmod.Database.Rollback ;
      MessageBox(handle,'操作失败,请重试!','提示',mb_ok+mb_iconinformation);
      result:=false;
    end;
  end;
end;
{***********************ServiceMealType***********************}

{***********************ServiceMeal***********************}
procedure Tfrm_dictionary.ServiceMeal_ref ;
begin
  with sg_MealType2 do
  begin
    cells[0,0] := '套餐序号';
    cells[1,0] := '套餐名称';
  end;
  with sg_ItemType2 do
  begin
    cells[0,0] := '项目序号';
    cells[1,0] := '项目名称';
    cells[2,0] := '项目价格';
  end;
  SearchServiceMealInfo();
  SearchServiceItem2Info();
end;

procedure Tfrm_dictionary.SearchServiceMealInfo ();
var
  i:integer;
begin
  with dmod.qrydata do
  begin
    close;
    SQL.Text := 'select type_id,type_name from ServiceMealType';
    Open;
    i:=1;
    while not eof do
    begin
      sg_MealType2.Cells[0,i]:=FieldByName('type_id').AsString ;
      sg_MealType2.Cells[1,i]:=FieldByName('type_name').AsString ;
      inc(i);
      next;
    end;
  end;
  if i<>1 then sg_MealType2.RowCount := i+1;
  sbtn_front.Enabled := false;
  sbtn_back.Enabled  := false;
  if sg_MealType2.RowCount >3 then sbtn_back.Enabled := true;
  
  if sg_MealType2.Cells[0,1]<>'' then
  SearchServiceMealItemInfo(sg_MealType2.Cells[0,1]);
end;

procedure Tfrm_dictionary.SearchServiceMealItemInfo (temp:string);
var
   i:integer;
   total_sum,promotion_sum:double;
begin
   total_sum:=0.0;promotion_sum:=0.0;
  StringGridClear(sg_ItemType2);

  with dmod.qrydata do
  begin
    Close;
    SQL.Text :='select total_sum,promotion_sum from ServiceMealType where type_id=:typeid';
    ParamByName('typeid').AsString :=temp;
    Open;
    if not eof then
    begin
      total_sum:=FieldbyName('total_sum').AsFloat ;
      promotion_sum:=FieldbyName('promotion_sum').AsFloat ;
    end;

    Close;
    SQL.Text := 'select i.item_id,item_name,item_price from ServiceMeal m,ServiceItem i where m.item_id=i.item_id '+
                'and m.type_id='+#39+temp+#39;
    Open;
    i:=1;
    while not eof do
    begin
      sg_ItemType2.Cells[0,i]:= FieldByName('item_id').AsString ;
      sg_ItemType2.Cells[1,i]:= FieldByName('item_name').AsString ;
      sg_ItemType2.Cells[2,i]:= FieldByName('item_price').AsString ;
      inc(i);
      next;
    end;
  end;

  edt_totalsum.Text :=FloatToStr(total_sum);
  edt_promotionsum.Text :=FloatToStr(promotion_sum);
  
  if i<>1 then sg_ItemType2.RowCount := i+1;

  //sbtn_front.Enabled := false;
  //sbtn_back.Enabled  := false;
  //if sg_ItemType2.RowCount >3 then sbtn_back.Enabled := true;
end;

procedure Tfrm_dictionary.SearchServiceItem2Info ();
begin
  cbb_MealType.Clear ;
  with dmod.qrydata do
  begin
    Close;
    SQL.Text:='select item_id,item_name,item_price from ServiceItem';
    Open;
    while not eof do
    begin
      cbb_MealType.Items.Add(FieldByName('item_id').AsString+'-'+FieldByName('item_name').AsString+'-'+FloatToStr(FieldByName('item_Price').AsFloat));
      next;
    end;
  end;
end;

function Tfrm_dictionary.SaveServiceMealInfo ():boolean;
var
  temp_type_id,temp_type_name:string;
  i:integer;
begin
  result:=true;
  temp_type_id:=sg_MealType2.Cells[0,sg_MealType2.Row];
  temp_type_name:=sg_MealType2.cells[1,sg_MealType2.row];

  if temp_type_id='' then
  begin
     MessageBox(handle,'请先选择一个服务项目类型','提示',mb_ok+mb_iconinformation);
     result:=false;
     exit;
  end;
  
  if (edt_promotionsum.Text ='') or (edt_promotionsum.Text ='0') then
  begin
     MessageBox(handle,'请输入服务套餐的优惠价','提示',mb_ok+mb_iconinformation);
     edt_PromotionSum.SetFocus ;
     result:=false;
     exit;
  end;

  try
    dmod.Database.StartTransaction ;
    with dmod.qrydata do
    begin
      close;
      SQL.Text :='update ServiceMealType set total_sum=:totalsum,promotion_sum=:promotionsum where '+
                 'type_id=:typeid';
      ParamByName('totalsum').AsFloat := StrToFloat(edt_totalsum.Text );
      ParamByName('promotionsum').AsFloat := StrToFloat(edt_promotionsum.Text );
      ParamByName('typeid').AsString := temp_type_id;
      ExecSQL;

      close;
      SQL.Text :='delete from ServiceMeal where type_id=:typeid';
      ParambyName('typeid').AsString :=temp_type_id;
      ExecSQL;
      
      for i:=1 to sg_ItemType2.RowCount -2 do
      begin
        close;
        SQL.Text :='insert into ServiceMeal(type_id,item_id) values(:typeid,:itemid)';
        ParamByName('typeid').AsString :=temp_type_id;
        //ParamByName('typename').AsString :=temp_type_name;
        ParamByName('itemid').AsString := trim(sg_ItemType2.Cells[0,i]);
        ExecSQL;
      end;
    end;
  finally
    try
      dmod.Database.Commit ;
      result:=true;
    except
      MessageBox(handle,'操作失败,请重试!','提示',mb_ok+mb_iconinformation);
      dmod.Database.Rollback ;
      result:=false;
    end;
  end;
end;
{***********************ServiceMeal***********************}

{***********************MemberCardType******************************}
procedure Tfrm_dictionary.MemberCardType_ref ;
begin
  with sg_CardType do
  begin
    cells[0,0] := '类型序号';
    cells[1,0] := '类型名称';
    cells[2,0] := '最低消费';
    cells[3,0] := '享受折扣';
    cells[4,0] := '类型描述';
  end;
  SearchMemberCardTypeInfo();
end;

procedure Tfrm_dictionary.SearchMemberCardTypeInfo();
var
  i:integer;
begin
  with dmod.qrydata do
  begin
    close;
    SQL.Text := 'select type_id,type_name,mincost,discount,type_remark from MemberCardType';
    Open;
    i:=1;
    while not eof do
    begin
      sg_CardType.Cells[0,i] := FieldByName('type_id').AsString ;
      sg_CardType.Cells[1,i] := FieldByName('type_name').AsString ;
      sg_CardType.Cells[2,i] := FloatToStr(FieldbyName('mincost').AsFloat);
      sg_CardType.Cells[3,i] := FloatToStr(FieldByName('discount').AsFloat);
      sg_CardType.Cells[4,i] := FieldByName('type_remark').AsString ;
      inc(i);
      next;
    end;
  end;
  if i<>1 then sg_CardType.RowCount := i+1;
  sbtn_front.Enabled := false;
  sbtn_back.Enabled  := false;
  if sg_CardType.RowCount >3 then sbtn_back.Enabled := true;
end;

procedure Tfrm_dictionary.ClearMemberCardTypeInfo ();
begin
  edt_CardTypeid.Text :='';
  edt_CardTypename.Text :='';
  edt_Mincost.Text :='';
  edt_discount.Text :='';
  edt_Cardtyperemark.Text :='';
end;

procedure Tfrm_dictionary.MakeMemberCardTypeEnabled(temp:boolean);
begin
  if sbtn_append.enabled then
     sbtn_save.Enabled :=true
  else
     sbtn_save.Enabled :=false;
  sbtn_delete.Enabled  :=false;
  edt_CardTypeid.Enabled :=temp;
  edt_CardTypename.Enabled :=temp;
  edt_Mincost.Enabled :=temp;
  edt_discount.Enabled :=temp;
  edt_Cardtyperemark.Enabled :=temp;
end;

function Tfrm_dictionary.SaveMemberCardTypeInfo():boolean;
begin
  result := true;
  if trim(edt_CardTypename.Text)='' then
  begin
    Messagebox(handle,'请输入会员卡类型名称!','提示',mb_ok+mb_iconinformation);
    result:=false;
    edt_CardTypename.SetFocus ;
    exit;
  end;
  
  CardTypeid:=trim(edt_Cardtypeid.Text );
  if CardTypeAppendOrEdit then
  with dmod.qrydata do
  begin
    close;
    SQL.Text := 'select type_id from MemberCardType where type_id=:typeid';
    ParamByName('typeid').AsString := CardTypeid;
    Open;
    if not eof then
    begin
      MessageBox(self.handle,'该会员卡类型编号已经存在,请重新确认!','提示',mb_ok+mb_iconinformation);
      edt_CardTypeid.SetFocus ;
      result:=false;
      exit;
    end;
  end;

  with dmod.qrydata do
  begin
    close;
    SQL.Text := 'select type_id from MemberCardType where type_name=:typename';
    ParamByname('typename').AsString := trim(edt_CardTypename.Text);
    open;
    if not eof then
    if FieldByName('type_id').AsString <> CardTypeid then
    begin
      MessageBox(self.Handle ,'该会员卡类型名称已经存在,请重新确认!','提示',mb_ok+mb_iconinformation);
      edt_CardTypename.SetFocus ;
      result := false;
      exit;
    end;
  end;
  
  try
    dmod.Database.StartTransaction ;
    with dmod.qrydata do
    begin
      close;
      SQL.Text := 'delete from MemberCardType where type_id=:typeid';
      ParamByName('typeid').AsString := CardTypeId;
      ExecSQL;

      close;
      SQL.Text := 'insert into MemberCardType(type_id,type_name,mincost,discount,type_remark) '+
                  'values (:typeid,:typename,:mincost,:discount,:typeremark)';
      ParamByName('typeid').AsString := trim(edt_Cardtypeid.Text );
      ParamByName('typename').AsString := trim(edt_Cardtypename.Text );
      ParamByName('mincost').AsFloat := StrToFloat(trim(edt_MinCost.Text));
      ParamByName('discount').AsFloat := StrToFloat(trim(edt_Discount.Text ));
      ParamByName('typeremark').AsString := trim(edt_Cardtyperemark.Text );

⌨️ 快捷键说明

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