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

📄 unit_managersmssend.pas

📁 delphi开发的中国移动大客户管理系统,后台数据库为oracle
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Unit_ManagerSMSSend;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, ComCtrls, Db,dialogs, DBTables, Mask, ImgList, Grids,
  DBGrids, DBCtrls, CheckLst, TFlatButtonUnit, TFlatMemoUnit, TFlatEditUnit,
  TFlatComboBoxUnit, TFlatSpeedButtonUnit, TFlatCheckBoxUnit;

type
  TFrm_ManagerSMSSend = class(TForm)
    SP_DXFW: TStoredProc;
    ImageList1: TImageList;
    ImageList2: TImageList;
    DS_YFS: TDataSource;
    QYFS: TQuery;
    Table1: TTable;
    DataSource1: TDataSource;
    Table1DHHM: TStringField;
    Table1ID: TFloatField;
    Table1DXLR: TStringField;
    Table1FXSJ: TDateTimeField;
    Table1NAME: TStringField;
    Table1GH: TStringField;
    Table1FSCS: TFloatField;
    Query1: TQuery;
    OpenDialog1: TOpenDialog;
    Panel1: TPanel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Panel6: TPanel;
    Panel11: TPanel;
    Label7: TLabel;
    Panel3: TPanel;
    TabSheet2: TTabSheet;
    Panel2: TPanel;
    Panel13: TPanel;
    Panel14: TPanel;
    Panel15: TPanel;
    ListBox1: TCheckListBox;
    Label8: TLabel;
    Panel12: TPanel;
    Label5: TLabel;
    DBGrid1: TDBGrid;
    DBMemo1: TDBMemo;
    BitBtn5: TFlatButton;
    BitBtn1: TFlatButton;
    Memo1: TFlatMemo;
    Panel7: TPanel;
    BitBtn2: TFlatButton;
    CheckBox1: TFlatCheckBox;
    SpeedButton4: TFlatButton;
    Edit1: TFlatEdit;
    ComboBox1: TFlatComboBox;
    Panel4: TPanel;
    PageControl2: TPageControl;
    TabSheet3: TTabSheet;
    Panel5: TPanel;
    Label1: TLabel;
    SpeedButton3: TFlatButton;
    EditDHHM: TFlatEdit;
    TabSheet4: TTabSheet;
    PageControl3: TPageControl;
    Panel8: TPanel;
    Label2: TLabel;
    SpeedButtonFGJT: TFlatButton;
    SpeedButtonJT_OK: TFlatButton;
    ComboBoxJT: TFlatComboBox;
    TabSheet11: TTabSheet;
    Panel9: TPanel;
    Label10: TLabel;
    Edit3: TFlatEdit;
    SpeedButton9: TFlatSpeedButton;
    BitBtn4: TFlatButton;
    Memo2: TFlatMemo;
    Label11: TLabel;
    FlatButton2: TFlatButton;
    FlatButton1: TFlatButton;
    procedure BitBtn1Click(Sender: TObject);
    procedure EditDHHMKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ListBox1DblClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButtonFGJTClick(Sender: TObject);
    procedure SpeedButtonJT_OKClick(Sender: TObject);
    procedure Image1DblClick(Sender: TObject);
    procedure TabSheet4Show(Sender: TObject);
    procedure TabSheet5Show(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure SpeedButton7Click(Sender: TObject);
    procedure SpeedButton8Click(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton9Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure CheckListBox1DblClick(Sender: TObject);
    procedure Memo1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure PageControl2Change(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure EditDHHMKeyPress(Sender: TObject; var Key: Char);
    procedure FlatButton2Click(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure ListBox1ClickCheck(Sender: TObject);
    procedure FlatButton1Click(Sender: TObject);
  private
    { Private declarations }
    strtmp : integer;
    Function SendSms(pSid:String;pSmsContent:String):Integer;
  public
    { Public declarations }
    function GetFirstSelection(List: TCustomListBox): Integer;
  end;

var
  Frm_ManagerSMSSend: TFrm_ManagerSMSSend;
  multigroup : boolean;

implementation
uses dmmain,MAIN,Unit_SelectInfoP,crypt,procedurep;
{$R *.DFM}

Function TFrm_ManagerSMSSend.SendSms(pSid:String;pSmsContent:String):Integer;
Begin
   SendSms := -1 ; //发送失败,modify by zengzc 
   Try
      SP_DXFW.Close;
      SP_DXFW.ParamByName('pSid').AsString:=Trim(pSid);
      SP_DXFW.ParamByName('pSmsContent').AsString:=Trim(pSmsContent);
      SP_DXFW.ParamByName('pWKNO').AsString:=Trim(GH);
      SP_DXFW.ParamByName('pCityNo').AsString:=PS_CityNo;
      SP_DXFW.ParamByName('pCounty').AsInteger:=JX;
      SP_DXFW.ExecProc;
      SendSms:= 0;//SP_DXFW.ParamByName('pResult').AsInteger;
   Except
      strtmp := -1 ;
      Application.MessageBox('系统在执行过程中发生错误,发送失败!','提示',MB_ICONINFORMATION);
   End;
End;

procedure TFrm_ManagerSMSSend.BitBtn1Click(Sender: TObject);
var
  i, icount : Integer;
  Str : String;
  SendStr : String;
begin
  icount := 0;
  //ListBox1.Refresh;
  if Length(trim(Memo1.Text)) <= 0 then
    begin
       Application.MessageBox('请输入要发送的短信息的内容!', '系统提示', MB_ICONINFORMATION);
       Memo1.SetFocus;
       exit;
    end;
  Str := Trim(Memo1.Text);
  if multigroup then
  else
    begin
      for i:=0  to ListBox1.Items.Count-1 do
        if listbox1.Checked[i] then
          begin
            inc(icount);
            If Length(Str)<=140 Then
              begin
                if SendSms(Trim(ListBox1.Items.Strings[I]),Trim(Memo1.Text)) = -1 then Exit;
                Str := '';
              end
            Else
              Begin
                 While Length(Str)<>0 Do
                   Begin
                     //If Length(Trim(Str))<=140 Then
                        //Begin
                          //if SendSms(Trim(ListBox1.Items.Strings[I]),Trim(Memo1.Text)) = -1 then Exit;
                          //Str:='';
                          //Exit;
                        //End
                      //Else
                        //Begin
                          If Length(Trim(Str))>140 Then
                            SendStr:=Copy(Str,1,136)+'5678'
                          else
                            SendStr := Str;
                          if SendSms(Trim(ListBox1.Items.Strings[I]), SendStr) = -1 then Exit;
                          Str:=Trim(Copy(Str,137,Length(Trim(Str))-137));
                        //End;
                   End;
              End;
          end
        else
          begin
            Application.MessageBox('请选择要发送短信息的客户!', '系统提示', MB_OK + MB_ICONINFORMATION);
            Exit;
          end;
      //判断是否发短信息给大户经理确认
      if CheckBox1.Checked then
        begin
          query1.active:=false;
          query1.sql.Clear;
          query1.sql.Append('select HOMETEL,sid from T_F_MANAGER where WK_NO='''+gh+'''');
          query1.Active:=true;
          If Trim(Query1.fieldbyname('sid').asstring) <> '' Then
            if SendSms(Trim(Query1.fieldbyname('sid').asstring),'您好,共发送了:'+IntToStr(icount)+'条短消息') = -1  then Exit;
        end;
    end;
  if strtmp <> -1 then
    begin
      Application.MessageBox(Pchar('您好,发送成功!' + '共发送了:'+IntToStr(icount)+'条短消息'), '系统提示', MB_OK + MB_ICONINFORMATION);
      BitBtn1.Enabled := False;
      Label8.Caption := '总用户数:0';
    end
  else
    Exit;
  ListBox1.Items.Clear;
end;

procedure TFrm_ManagerSMSSend.EditDHHMKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Key= VK_RETURN) then
     SpeedButton3Click(Nil);
end;

procedure TFrm_ManagerSMSSend.ListBox1DblClick(Sender: TObject);
var
  index:integer;
begin
  index:=GetFirstSelection(ListBox1);
  ListBox1.Items.Delete(index);
end;

function TFrm_ManagerSMSSend.GetFirstSelection(List: TCustomListBox): Integer;
begin
  for Result := 0 to List.Items.Count - 1 do
    if List.Selected[Result] then Exit;
  Result := LB_ERR;
end;

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

  crypt.UserEnter_Log(Caption,'浏览',0,Gh,'登入窗体');
end;

procedure TFrm_ManagerSMSSend.BitBtn2Click(Sender: TObject);
begin
  Close;
end;

procedure TFrm_ManagerSMSSend.FormShow(Sender: TObject);
begin
  crypt.UserEnter_Log(Caption,'浏览',-1,Gh,'登入窗体');
  setFunVisible(Self,gh);

  multigroup:=false;
  EditDHHM.SetFocus;
end;

procedure TFrm_ManagerSMSSend.SpeedButtonFGJTClick(Sender: TObject);
begin
  SpeedButtonFGJT.Enabled:=FALSE;
  Label2.Visible:=true;
  ComboBoxJT.Visible:=true;
  SpeedButtonJT_OK.Visible:=true;
  ComboBoxJT.Items.Clear;

  WITH dm_main.QueryJTYH DO
  Begin
    Close;
    SQL.Clear;
//    SQL.Add('SELECT distinct jtyhmc,jtyhdm FROM JTYH WHERE jtlb=''J''');
    SQL.Add('SELECT distinct JTYHMC,JTYHDM FROM t_f_groupinfo WHERE 1=1');
    if JBDM=3 then
        SQL.Add(' AND GH='+''''+GH+'''')
    else if (JBDM=1) or (JBDM=2) then
         SQL.Add(' AND JX='+IntToStr(JX)) ;
    Open;

    While not Eof  do
    begin
       ComboBoxJT.Items.Add(FieldByName('JTYHMC').AsString);
       Next;
    end;
  END;
  ComboBoxJT.ItemIndex:=0;
end;


procedure TFrm_ManagerSMSSend.SpeedButtonJT_OKClick(Sender: TObject);
var
  jtindex:integer;
begin
   ListBox1.Clear;   //2001-6-28    CQB
   with dm_main.QueryJTYH do
   begin
     SQL.Clear;
     SQL.Add('select jtyhdm from t_f_groupinfo where ltrim(rtrim(jtyhmc))='''+Trim(ComboBoxJT.Items.Strings[ComboBoxJT.Itemindex])+'''');
     Open;
     jtindex:=Fieldbyname('jtyhdm').AsInteger;
   end;
   with dm_main.QueryZZC do
   begin
      Close;
      SQL.Clear;
      SQL.Add(' SELECT * FROM t_f_custinfo WHERE FYBZ<>''0'' AND JTYHDM='+IntToStr(jtindex));
      Open;
      First;
      while not Eof do
      begin
        ListBox1.Items.Add(Fieldbyname('SID').AsString);
        listbox1.checked[listbox1.Items.Count-1]:=true;
        Next;
      end;
   end;
   ComboBoxJT.Items.Delete(ComboBoxJT.ItemIndex);
   ComboBoxJT.ItemIndex:=0;
   if ListBox1.Items.Count>0 then BitBtn1.Enabled:=TRUE;
   Label8.Caption:='总用户数:'+IntToStr(ListBox1.Items.Count);
end;

procedure TFrm_ManagerSMSSend.Image1DblClick(Sender: TObject);
begin
    //内部处理,在双击该图表的时候,clear listbox1 作者:曾
  SpeedButtonFGJT.Enabled:=FALSE;
  if ListBox1.Items.Count<>0 then
  begin
   if multigroup then
     Application.MessageBox(pChar('请注意:'+#13#13+'将要把列表框中的:'+IntToStr(ListBox1.items.Count)+'个待发短信的集团删除!'),pChar('提示'),MB_ICONINFORMATION+MB_OK)
   else
     Application.MessageBox(pChar('请注意:'+#13#13+'将要把列表框中的:'+IntToStr(ListBox1.items.Count)+'条待发短信的号码删除!'),pChar('提示'),MB_ICONINFORMATION+MB_OK);
     ListBox1.Items.Clear;
  end;
   BitBtn1.Enabled:=False;
   multigroup:=false;  // 复原
end;

⌨️ 快捷键说明

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