花店销售管理系统C++语言关键代码
关键代码;
以雇员管理为例:
刷新的代码如下
oid gygl::shuaxin()
{
gyglset gy;
int i=0,j=0;
CString s;
gy.Open ();
while(!gy.IsEOF ())//是不是指向表尾
{
m_list11.InsertItem(j,"");//向列表控件中插入一行
m_list11.SetItemText(i,0,gy.m_column1);//设置列表控件中网格处的文本
m_list11.SetItemText(i,1,gy.m_column2);
m_list11.SetItemText(i,2,gy.m_column3);
m_list11.SetItemText(i,3,gy.m_column4);
m_list11.SetItemText(i,4,gy.m_column5);
m_list11.SetItemText(i,5,gy.m_column6);
m_list11.SetItemText(i,6,gy.m_column7);
i++;
j++;
gy.MoveNext();
}
gy.Close ();
}
查看的代码如下:
void gygl::Onchakan()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_list11.DeleteAllItems();
gyglset xianhua;
int i=0;
int j=0;
int n=0;
//if(xianhua.m_column2>=m_xia && xianhua.m_column2<=m_shang)
if(xianhua.Open())
{
while(!xianhua.IsEOF())
{
m_list11.InsertItem(j,"");
m_list11.SetItemText(i,0,xianhua.m_column1);
m_list11.SetItemText(i,1,xianhua.m_column2);
m_list11.SetItemText(i,2,xianhua.m_column3);
m_list11.SetItemText(i,3,xianhua.m_column4);
m_list11.SetItemText(i,4,xianhua.m_column5);
m_list11.SetItemText(i,5,xianhua.m_column6);
m_list11.SetItemText(i,6,xianhua.m_column7);
i++;
j++;
xianhua.MoveNext();
n++;
}
if(n==0)
{
MessageBox("很抱歉没有符合该要求的花","顾客您好!");
}
}
xianhua.Close();
}
有表格的列表控件初始化代码如下
void gygl::Onchakan()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_list11.DeleteAllItems();
gyglset xianhua;
int i=0;
int j=0;
int n=0;
//if(xianhua.m_column2>=m_xia && xianhua.m_column2<=m_shang)
if(xianhua.Open())
{
while(!xianhua.IsEOF())
{
m_list11.InsertItem(j,"");
m_list11.SetItemText(i,0,xianhua.m_column1);
m_list11.SetItemText(i,1,xianhua.m_column2);
m_list11.SetItemText(i,2,xianhua.m_column3);
m_list11.SetItemText(i,3,xianhua.m_column4);
m_list11.SetItemText(i,4,xianhua.m_column5);
m_list11.SetItemText(i,5,xianhua.m_column6);
m_list11.SetItemText(i,6,xianhua.m_column7);
i++;
j++;
xianhua.MoveNext();
n++;
}
if(n==0)
{
MessageBox("很抱歉没有符合该要求的花","顾客您好!");
}
}
xianhua.Close();
}
删除代码如下:
void gygl::Onshanchu()
{
// TODO: Add your control notification handler code here
long row=m_list11.GetSelectionMark();//返回列表控件中的一处文本
gyglset us;
CString str;
str=m_list11.GetItemText(row,0);
if(str=="")
{
MessageBox("请选择一行!");
}
else
{
if(MessageBox("确定要删除记录吗?","删除询问",MB_OKCANCEL)==IDOK)
{
us.Open();
us.Move(row);
us.Delete();
m_list11.DeleteItem(row);
}
}
添加代码如下:
void gygl::Ontianjia()
{
// TODO: Add your control notification handler code here
gyglset b;
UpdateData(TRUE);
b.Open ();
if(m_gy == _T("")||m_mima== _T("")||m_xm == _T("")||m_xb == _T("")||m_lxfs == _T("")||m_jtzz == _T("")||m_yb == _T(""))
{
MessageBox("请您将信息填写完整","温馨提示");
return;
}
else
{
int i=0;
b.AddNew ();
b.m_column1 =m_gy;
b.m_column2 =m_mima;
b.m_column3 =m_xm;
b.m_column4 =m_xb;
b.m_column5 =m_lxfs;
b.m_column6 =m_jtzz;
b.m_column7 =m_yb;
b.Update ();//数据表更新
b.Requery ();//记录集更新
b.MoveLast ();
m_list11.SetItemText(i,0,b.m_column1);
m_list11.SetItemText(i,1,b.m_column2);
m_list11.SetItemText(i,2,b.m_column3);
m_list11.SetItemText(i,3,b.m_column4);
m_list11.SetItemText(i,4,b.m_column5);
m_list11.SetItemText(i,5,b.m_column6);
m_list11.SetItemText(i,6,b.m_column7);
i++;
MessageBox("成功添加一条雇员信息");
}
b.Close();
}
修改代码如下:
void gygl::Onxiugai()
{
// TODO: Add your control notification handler code here
gyglset gy;
UpdateData(TRUE);
int i=0,j=0;
CString s;
gy.Open ();
gy.MoveFirst ();//指向第一条记录
for(i=0;i
gy.MoveNext ();//指向下一条记录
if(m_list11.GetSelectionMark()!=-1)//检索列表视图控件的选择标记
{
s=gy.m_column1 ;
gy.Edit ();
gy.m_column1 =s;
gy.m_column2 =m_mima;
gy.m_column3 =m_xm;
gy.m_column4 =m_xb;
gy.m_column5 =m_lxfs;
gy.m_column6 =m_jtzz;
gy.m_column7 =m_yb;
m_list11.DeleteAllItems ();//删除列表控件在中的行
gy.Update ();//数据表更新
gy.Requery ();//记录集更新
gy.MoveLast ();
shuaxin();
MessageBox("成功修改一条雇员信息");
}
}