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

📄 modifydeleteorderform.cpp

📁 使用短信猫可以实现短信的群发
💻 CPP
字号:
// ModifyDeleteOrderForm.cpp : implementation file
//

#include "stdafx.h"
#include "sms.h"
#include "ModifyDeleteOrderForm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CModifyDeleteOrderForm dialog


CModifyDeleteOrderForm::CModifyDeleteOrderForm(CWnd* pParent /*=NULL*/)
	: CDialog(CModifyDeleteOrderForm::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModifyDeleteOrderForm)
	m_OrderFormContent = _T("");
	m_StartTime = COleDateTime::GetCurrentTime();
	m_EndTime = COleDateTime::GetCurrentTime();
	m_EndDate = COleDateTime::GetCurrentTime();
	m_StartDate = COleDateTime::GetCurrentTime();
	//}}AFX_DATA_INIT
}


void CModifyDeleteOrderForm::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModifyDeleteOrderForm)
	DDX_Text(pDX, IDC_ORDER_FORM_CONTENT, m_OrderFormContent);
	DDV_MaxChars(pDX, m_OrderFormContent, 140);
	DDX_DateTimeCtrl(pDX, IDC_START_TIME, m_StartTime);
	DDX_DateTimeCtrl(pDX, IDC_END_TIME, m_EndTime);
	DDX_DateTimeCtrl(pDX, IDC_END_DATE, m_EndDate);
	DDX_DateTimeCtrl(pDX, IDC_START_DATE, m_StartDate);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CModifyDeleteOrderForm, CDialog)
	//{{AFX_MSG_MAP(CModifyDeleteOrderForm)
	ON_BN_CLICKED(IDC_MODIFY, OnModify)
	ON_BN_CLICKED(IDC_DELETE, OnDelete)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CModifyDeleteOrderForm message handlers

BOOL CModifyDeleteOrderForm::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	




	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CModifyDeleteOrderForm::OnModify() 
{
	UpdateData(); //将窗口的内容更新到于之关连的对象或值中去 
	COleDateTime startDateTime(m_StartDate.GetYear(),
								m_StartDate.GetMonth(),
								m_StartDate.GetDay(),
								m_StartTime.GetHour(),
								m_StartTime.GetMinute(),
								m_StartTime.GetSecond());
	
	COleDateTime endDateTime(m_EndDate.GetYear(),
								m_EndDate.GetMonth(),
								m_EndDate.GetDay(),
								m_EndTime.GetHour(),
								m_EndTime.GetMinute(),
								m_EndTime.GetSecond());
	
	TRACE("Start %d %d %d %d %d %d",m_StartDate.GetYear(),m_StartDate.GetMonth(),m_StartDate.GetDay(),\
		m_StartTime.GetHour(),m_StartTime.GetMinute(),m_StartTime.GetSecond());
	
	TRACE("End %d %d %d %d %d %d",m_EndDate.GetYear(),m_EndDate.GetMonth(),m_EndDate.GetDay(),\
		m_EndTime.GetHour(),m_EndTime.GetMinute(),m_EndTime.GetSecond());
	
	if(startDateTime >= endDateTime)
	{
		AfxMessageBox("结束时间必须大于开始时间");
		return;
	}
	

	//////////////////////////////////////////////////////////////////////////
	///数据库操作
	//////////////////////////////////////////////////////////////////////////
	CSMSApp * pCSMSApp=(CSMSApp *)AfxGetApp();//取得App类对象的指针
	CSMSADO &Ado=pCSMSApp->m_SMSAdo;
	
	//这里判断数据连接是否连接成功
	if(!Ado.IsConnection())
	{
		MessageBox("连接数据库出错\n请重新设置Oracle相关信息");
		return;
	}
	
	
	CString sql;
	long isRecordSet=0;
	int id=((COrderFormManager *)(GetParent()->GetParent()))->m_id;
	sql.Empty();//清空查询语句
	//插入定单
	sql.Format("update orders set \
		orderstart=to_Date('%d-%d-%d %d:%d:%d','YYYY-MM-DD HH24:MI:SS') ,\
		orderend=to_Date('%d-%d-%d %d:%d:%d','YYYY-MM-DD HH24:MI:SS') , \
		content='%s' where id=%d",
		startDateTime.GetYear(),startDateTime.GetMonth(),startDateTime.GetDay(),
		startDateTime.GetHour(),startDateTime.GetMinute(),startDateTime.GetSecond(),
		endDateTime.GetYear(),endDateTime.GetMonth(),endDateTime.GetDay(),
		endDateTime.GetHour(),endDateTime.GetMinute(),endDateTime.GetSecond(),
		m_OrderFormContent,id);


	
	int isSuccess=Ado.ExecuteWithoutRecordset(sql);
	if(!isSuccess)
	{
		MessageBox("插入数据出错,请查看是否以连接数据库");
		return;
	}
	
	((COrderFormManager *)(GetParent()->GetParent()))->ShowOrderFormList();
	m_OrderFormContent.Empty();
	
	UpdateData(FALSE);//将变量的内容更新到于之关加的窗口上

}

void CModifyDeleteOrderForm::OnDelete() 
{
	// TODO: Add your control notification handler code here
	UpdateData(); //将窗口的内容更新到于之关连的对象或值中去 
	COleDateTime startDateTime(m_StartDate.GetYear(),
								m_StartDate.GetMonth(),
								m_StartDate.GetDay(),
								m_StartTime.GetHour(),
								m_StartTime.GetMinute(),
								m_StartTime.GetSecond());
	
	COleDateTime endDateTime(m_EndDate.GetYear(),
								m_EndDate.GetMonth(),
								m_EndDate.GetDay(),
								m_EndTime.GetHour(),
								m_EndTime.GetMinute(),
								m_EndTime.GetSecond());
	
	
	
	
	
	
	TRACE("Start %d %d %d %d %d %d",m_StartDate.GetYear(),m_StartDate.GetMonth(),m_StartDate.GetDay(),\
		m_StartTime.GetHour(),m_StartTime.GetMinute(),m_StartTime.GetSecond());
	
	TRACE("End %d %d %d %d %d %d",m_EndDate.GetYear(),m_EndDate.GetMonth(),m_EndDate.GetDay(),\
		m_EndTime.GetHour(),m_EndTime.GetMinute(),m_EndTime.GetSecond());
	
	if(startDateTime >= endDateTime)
	{
		AfxMessageBox("结束时间必须大于开始时间");
		return;
	}
	
	
	//////////////////////////////////////////////////////////////////////////
	///数据库操作
	//////////////////////////////////////////////////////////////////////////
	CSMSApp * pCSMSApp=(CSMSApp *)AfxGetApp();//取得App类对象的指针
	CSMSADO &Ado=pCSMSApp->m_SMSAdo;
	
	//这里判断数据连接是否连接成功
	if(!Ado.IsConnection())
	{
		MessageBox("连接数据库出错\n请重新设置Oracle相关信息");
		return;
	}
	
	
	CString sql;
	long isRecordSet=0;
	int id=((COrderFormManager *)(GetParent()->GetParent()))->m_id;
	sql.Empty();//清空查询语句
	//插入定单
	sql.Format("delete orders where id=%d",id);

	int isSuccess=Ado.ExecuteWithoutRecordset(sql);
	if(!isSuccess)
	{
		MessageBox("删除数据中orders表出错,请查看是否以连接数据库");
		return;
	}

	sql.Empty();//清空查询语句
	//插入定单
	sql.Format("delete phonenumber where orderid=%d",id);

	isSuccess=Ado.ExecuteWithoutRecordset(sql);
	if(!isSuccess)
	{
		MessageBox("删除数据中phonenumber表出错,请查看是否以连接数据库");
		return;
	}

	((COrderFormManager *)(GetParent()->GetParent()))->ShowOrderFormList();
	m_OrderFormContent.Empty();
	
	UpdateData(FALSE);//将变量的内容更新到于之关加的窗口上
}

BOOL CModifyDeleteOrderForm::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (pMsg->message == WM_KEYDOWN)
	{	
		if (pMsg->wParam == VK_RETURN)	return TRUE;
		if (pMsg->wParam == VK_ESCAPE)	return TRUE;
	} 
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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