Exemple #1
0
int TDBTBL::Cardinality(PGLOBAL g)
  {
  if (!g)
    return 0;                 // Cannot make the table list
  else if (Cardinal < 0) {
    int tsz;

    if (!Tablist && InitTableList(g))
      return 0;               // Cannot be calculated at this stage

    Cardinal = 0;

    for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) {
      if ((tsz = tabp->GetTo_Tdb()->Cardinality(g)) < 0) {
        Cardinal = -1;
        return tsz;
        } // endif mxsz

      Cardinal += tsz;
      } // endfor i

    } // endif Cardinal

  return Cardinal;
  } // end of Cardinality
Exemple #2
0
/*
 * 说明:
 *    删除台号信息
 * 参数:
 *    hwnd [in] 主窗口句柄
 * 返回值
 *    成功返回true
 */
bool DeleteTable(HWND hwnd)
{
	CListView table_list(hwnd, IDC_L_TABLE_INFO);
	int select = table_list.GetSelectionMark();
	if (-1 == select) {
		MessageBox(hwnd, TEXT("请在左侧列表款选择要删除的房间编号!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
		return false;
	}
	std::string floor, room, table_no;
	CComboBox combo(hwnd, IDC_TABLE_FLOOR_COMBO);
	combo.GetComboBoxText(floor);              // 获取楼层名
	room = table_list.GetItem(select, 0);      // 获取房间名
	table_no = table_list.GetItem(select, 1);  // 获取台号
		CTableInfo table;
		table.DeleteTable(floor.c_str(), room.c_str(), table_no.c_str());
		CComboBox combox;
		//清空显示
		combox.Initialization(hwnd,IDC_C_FLOOR_NAME);
		combox.DeleteAllString();
		combox.Initialization(hwnd,IDC_C_ROOM_NAME);
		combox.DeleteAllString();
		CEdit edit;
		edit.Initialization(hwnd,IDC_E_TABLE_NO);
		edit.Empty();
		edit.Initialization(hwnd,IDC_E_TABLE_NUM);
		edit.Empty();
		InitTableList(hwnd, IDC_L_TABLE_INFO, floor.c_str(), 0);  // 更新
	return true;
}
Exemple #3
0
bool TDBTBL::OpenDB(PGLOBAL g)
  {
  if (trace)
    htrc("TBL OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n",
                      this, Tdb_No, Use, To_Key_Col, Mode);

  if (Use == USE_OPEN) {
    /*******************************************************************/
    /*  Table already open, replace it at its beginning.               */
    /*******************************************************************/
    ResetDB();
    return Tdbp->OpenDB(g);  // Re-open fist table
    } // endif use

  /*********************************************************************/
  /*  When GetMaxsize was called, To_CondFil was not set yet.          */
  /*********************************************************************/
  if (To_CondFil && Tablist) {
    Tablist = NULL;
    Nbc = 0;
    } // endif To_CondFil

  /*********************************************************************/
  /*  Open the first table of the list.                                */
  /*********************************************************************/
  if (!Tablist && InitTableList(g))     //  done in GetMaxSize
    return TRUE;

  if ((CurTable = Tablist)) {
    Tdbp = (PTDBASE)CurTable->GetTo_Tdb();
//  Tdbp->SetMode(Mode);
//  Tdbp->ResetDB();
//  Tdbp->ResetSize();

    // Check and initialize the subtable columns
    for (PCOL cp = Columns; cp; cp = cp->GetNext())
      if (cp->GetAmType() == TYPE_AM_TABID)
        cp->COLBLK::Reset();
      else if (((PPRXCOL)cp)->Init(g, NULL) && !Accept)
        return TRUE;
        
    if (trace)
      htrc("Opening subtable %s\n", Tdbp->GetName());

    // Now we can safely open the table
    if (Tdbp->OpenDB(g))
      return TRUE;

    } // endif *Tablist

  Use = USE_OPEN;
  return FALSE;
  } // end of OpenDB
Exemple #4
0
/*
 * 说明:
 *    更新台号信息
 * 参数:
 *    hwnd [in] 主窗口句柄
 * 返回值
 *    成功返回true
 */
bool UpdateTable(HWND hwnd)
{
	CListView table_list(hwnd, IDC_L_TABLE_INFO);
	int select = table_list.GetSelectionMark();
	if (-1 == select) {
		MessageBox(hwnd, TEXT("请在左侧列表款选择要删除的房间编号!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
		return false;
	}
	TABLEINFO table_info;//台号信息结构体
	CComboBox old_floor,new_floor,new_room;
	CEdit new_no,new_payable;
	old_floor.Initialization(hwnd,IDC_TABLE_FLOOR_COMBO);
	new_floor.Initialization(hwnd,IDC_C_FLOOR_NAME);
	new_room.Initialization(hwnd,IDC_C_ROOM_NAME);
	new_no.Initialization(hwnd,IDC_E_TABLE_NO);
	new_payable.Initialization(hwnd,IDC_E_TABLE_NUM);
	//获取更新的台号信息
	new_floor.GetComboBoxText(table_info.new_floor_name);
	new_room.GetComboBoxText(table_info.new_room_name);
	new_no.GetEditText(table_info.new_table_no);
	new_payable.GetEditText(table_info.new_table_payable);	
	//获取旧台号信息
	old_floor.GetComboBoxText(table_info.old_floor_name);
	table_info.old_room_name=table_list.GetItem(select,0);
	table_info.old_table_no=table_list.GetItem(select,1);

	CTableInfo table;
	table.UpdateTable(&table_info);
	//清空显示
	new_floor.DeleteAllString();
	new_room.DeleteAllString();
	new_no.Empty();
	new_payable.Empty();
	CComboBox floor_name;
	floor_name.Initialization(hwnd, IDC_TABLE_FLOOR_COMBO);
	std::string floor;
	floor_name.GetComboBoxText(floor);
	InitTableList(hwnd, IDC_L_TABLE_INFO, floor.c_str(), 0); 
	//刷新显示
	return true;
}
Exemple #5
0
bool AddTable(HWND hwnd)
{
	std::string floor, room, table_no, sum_str;
	CComboBox floor_combox(hwnd, IDC_C_FLOOR_NAME);
	CComboBox room_combox(hwnd, IDC_C_ROOM_NAME);
	floor_combox.GetComboBoxText(floor);
	room_combox.GetComboBoxText(room);
	CEdit edit;
	edit.Initialization(hwnd, IDC_E_TABLE_NO);
	edit.GetEditText(table_no);
	edit.Initialization(hwnd, IDC_E_TABLE_NUM);
	edit.GetEditText(sum_str);

	CTableInfo table;
	table.AddTable(floor.c_str(), room.c_str(), table_no.c_str(), atoi(sum_str.c_str()));
	//显示添加的台号信息
	CComboBox left_combox_floor(hwnd,IDC_TABLE_FLOOR_COMBO);
	left_combox_floor.SetCurSel(left_combox_floor.FindString(floor.c_str()));
	InitTableList(hwnd, IDC_L_TABLE_INFO, floor.c_str(), 0);  // 更新
	return true;
}
Exemple #6
0
int TDBTBL::GetMaxSize(PGLOBAL g)
  {
  if (MaxSize < 0) {
    int mxsz;

    if (!Tablist && InitTableList(g))
      return 0;               // Cannot be calculated at this stage

    MaxSize = 0;

    for (PTABLE tabp = Tablist; tabp; tabp = tabp->GetNext()) {
      if ((mxsz = tabp->GetTo_Tdb()->GetMaxSize(g)) < 0) {
        MaxSize = -1;
        return mxsz;
        } // endif mxsz

      MaxSize += mxsz;
      } // endfor i

    } // endif MaxSize

  return MaxSize;
  } // end of GetMaxSize
Exemple #7
0
/*
 * @ brief: 台号信息处理函数
 * @ param: hwnd [in] 窗口句柄
 * @ param: msg [in] 消息类型
 **/
BOOL CALLBACK ChildTableInfoProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_INITDIALOG:
		{
			CListView table_list(hwnd, IDC_L_TABLE_INFO);
			table_list.SetSelectAndGrid(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
			table_list.InsertColumn(1,80,"房间名称");
			table_list.InsertColumn(2,100,"台    号");
			table_list.InsertColumn(2,60,"人    数");
			try {

				InitFloorName(hwnd, IDC_TABLE_FLOOR_COMBO);//初始化左边第一个“楼层”下拉列表
				InitFloorName(hwnd, IDC_C_FLOOR_NAME);//初始化游标第二个“楼层”下拉列表
				CComboBox floor_combo(hwnd, IDC_TABLE_FLOOR_COMBO);
				std::string floor_name;
				floor_combo.GetComboBoxText(floor_name);
			    InitTableList(hwnd, IDC_L_TABLE_INFO, floor_name.c_str(), 0);
				InitRoomCombo(hwnd,floor_name.c_str(),IDC_C_ROOM_NAME);//根据楼层名,初始化房间下拉列表
			} catch (Err &err) {
				MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
				return FALSE;
			}
			return TRUE;
		}
	case  WM_NOTIFY:
		{
			switch(LOWORD(wParam))
			{
			case IDC_L_TABLE_INFO:
				{
					if (((LPNMHDR)lParam)->code == NM_CLICK){      // 点击列表中的一项
						int index = -1;
						CEdit num, no;
						CComboBox room_name, floor_name;
						CListView table_list;
						table_list.Initialization(hwnd, IDC_L_TABLE_INFO);
						index = table_list.GetSelectionMark();
						if (-1 == index) {
							MessageBox(hwnd, TEXT("请先在左侧选择一个台号!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
							break;
						}
						
						room_name.Initialization(hwnd, IDC_C_ROOM_NAME);
						no.Initialization(hwnd, IDC_E_TABLE_NO);
						num.Initialization(hwnd, IDC_E_TABLE_NUM);
						CComboBox combo(hwnd, IDC_TABLE_FLOOR_COMBO);
						std::string name;
						combo.GetComboBoxText(name);
						floor_name.Initialization(hwnd, IDC_C_FLOOR_NAME);
						floor_name.DeleteAllString();
						InitFloorName(hwnd,IDC_C_FLOOR_NAME);
					    floor_name.SetCurSel(floor_name.FindString(name.c_str()));
						
						InitRoomCombo(hwnd,name.c_str(),IDC_C_ROOM_NAME);
						room_name.SetCurSel(room_name.FindString(table_list.GetItem(index, 0).c_str()));
						no.SetEditText(table_list.GetItem(index, 1).c_str());
						num.SetEditText(table_list.GetItem(index, 2).c_str());
					}
					break;
				}
			}
			return TRUE;
		}
	case WM_COMMAND:
		{
			switch (LOWORD(wParam))
			{
			case IDC_B_ADD_TABLE:
				{
					try {
					    if(AddTable(hwnd))
						{
							MessageBox(hwnd, TEXT("添加台号信息成功"), TEXT("基础信息管理 "), MB_ICONINFORMATION);
						}
					} catch (Err &err) {
						MessageBox(hwnd, err.what(), TEXT("基础信息管理 "), MB_ICONERROR);
						return FALSE;
					}
					break;
				}
			case IDC_B_DISHPATCH_TABLE:
				{
					try
					{
						if (UpdateTable(hwnd))
						{
							MessageBox(hwnd, TEXT("修改台号信息成功"), TEXT("基础信息管理"), MB_OK);
						}
					}
					catch (Err &err)
					{
						MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
					}
					break;
				}
			case IDC_B_DELETE_TABLE:
				{
				try
					{
						if (DeleteTable(hwnd))
						{
								MessageBox(hwnd, TEXT("删除台号信息成功"), TEXT("基础信息管理"), MB_OK);
						}
					}
					catch (Err &err)
					{
						MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
					}
					break;
				}
			case IDC_TABLE_FLOOR_COMBO://点击左边第一个”楼层“下拉列表
				{
					if (HIWORD(wParam) == CBN_SELCHANGE) {
						try {
							CComboBox combo(hwnd, IDC_TABLE_FLOOR_COMBO);
							std::string floor_name;
							combo.GetComboBoxText(floor_name);
							CComboBox room(hwnd, IDC_C_ROOM_NAME);
							room.DeleteAllString();//清空“房间”下拉列表,然后在插入新的数据
							InitTableList(hwnd, IDC_L_TABLE_INFO, floor_name.c_str(), 0);
						} catch (Err &err) {
							MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
							return FALSE;
						}
					    CEdit edit;
						// 清空右侧编辑框数据
						edit.Initialization(hwnd, IDC_E_TABLE_NO);
						edit.Empty();
						edit.Initialization(hwnd, IDC_E_TABLE_NUM);
						edit.Empty();
					}
					break;
				}
			case IDC_C_FLOOR_NAME://点击第二个“楼层”下拉列表
				{
					if (HIWORD(wParam) == CBN_SELCHANGE)
					{
						try
						{
							CComboBox combo(hwnd, IDC_C_FLOOR_NAME);
							std::string floor_name_str;
							combo.GetComboBoxText(floor_name_str);
							CComboBox room_name(hwnd, IDC_C_ROOM_NAME);
							RoomInfo room_info;
							room_info.GetRoomName(floor_name_str.c_str());  // 获取楼层下的房间名称记录集
							room_name.DeleteAllString();
							while (!room_info.IsEOF())
							{
								room_name.AddString(room_info.room_name());
							} 
						}
						catch (Err &err)
						{
							MessageBox(hwnd, err.what(), TEXT("基础信息管理"), MB_ICONERROR);
							return FALSE;
						}			
					}
					break;
				}	
			case IDC_B_TABLE_CANCLE:
				{
					EndDialog(hwnd,0);
					break;
				}

			}	

			return TRUE;
		}
	case WM_CLOSE:
		{
			EndDialog(hwnd,0);
			return TRUE;
		}
	}
	return FALSE;
}