2018.9.
--往GridControl中添加绑定数据
// 房间费用
DataTable dtRoomInfo = new DataTable();
dtRoomInfo.Columns.Add("v_name", Type.GetType("System.String"));
dtRoomInfo.Columns.Add("t_kt_time", Type.GetType("System.String"));
dtRoomInfo.Columns.Add("v_ktsc", Type.GetType("System.String"));
dtRoomInfo.Columns.Add("v_jfgz_name", Type.GetType("System.String"));
dtRoomInfo.Columns.Add("f_room_money", Type.GetType("System.String"));
DataRow rowRoomInfo = dtRoomInfo.NewRow();
rowRoomInfo["v_name"] = ddModel.v_czzl_name;
rowRoomInfo["t_kt_time"] = ddModel.t_kaitai_time.ToString("yyyy-MM-dd HH:mm");
decimal hour = decimal.Parse((ddModel.i_jfsc * 1.0 / ( * )).ToString());
rowRoomInfo["v_ktsc"] = ((int)hour).ToString() + "小时" + ((hour - (int)hour) * ).ToString("") + "分钟";
rowRoomInfo["v_jfgz_name"] = ddModel.v_jfgz_name;
rowRoomInfo["f_room_money"] = ddModel.f_room_money.ToString();
dtRoomInfo.Rows.Add(rowRoomInfo);
this.gridControlRoomInfo.DataSource = dtRoomInfo;
//预付款
DataTable dtYFMoney = new DataTable();
dtYFMoney.Columns.Add("v_fkfs", Type.GetType("System.String"));
dtYFMoney.Columns.Add("t_time", Type.GetType("System.String"));
dtYFMoney.Columns.Add("f_yf_money", Type.GetType("System.String"));
dtYFMoney.Columns.Add("v_operation_name", Type.GetType("System.String"));
dtYFMoney.Columns.Add("v_mark", Type.GetType("System.String"));
DataRow rowYFMoney = dtYFMoney.NewRow();
//支付类型
switch (ddModel.i_yj_payment_type)
{
case :
rowYFMoney["v_fkfs"] = "现金";
break;
case :
rowYFMoney["v_fkfs"] = "银行卡";
break;
case :
rowYFMoney["v_fkfs"] = "微信";
break;
case :
rowYFMoney["v_fkfs"] = "支付宝";
break;
default:
break;
}
rowYFMoney["t_time"] = ddModel.t_kaitai_time.ToString("yyyy-MM-dd HH:mm");
rowYFMoney["f_yf_money"] = ddModel.f_yajin_money.ToString();
rowYFMoney["v_operation_name"] =ddModel.v_operator_name;
rowYFMoney["v_mark"] =ddModel.v_mark;
dtYFMoney.Rows.Add(rowYFMoney);
this.gridControlYFMoney.DataSource = dtYFMoney;
------------------------------------------------------------------------------------------------------------
2018.10.:周一
-- 返回前5个数据
SELECT TOP *
FROM Student;
-- 返回前50%的数据
SELECT TOP PERCENT *
FROM Student;
-- 以"C"或"P"开头
SELECT *
FROM Student
WHERE Subject LIKE '[CP]%';
-- 不以"C"或"P"开头
SELECT *
FROM Student
-- WHERE Subject LIKE '[^CP]%';
-- WHERE Subject LIKE '[!CP]%'; //不行
WHERE Subject NOT LIKE '[CP]%';
-- 以"A-D"开头
SELECT *
FROM Student
WHERE Subject LIKE '[A-D]%';
--选择科目是java和c#的所有人
SELECT *
FROM Student
WHERE Subject IN ('Java','C#');
-- WHERE Subject NOT IN ('Java','C#');
--选择范围之间
SELECT *
FROM Student
WHERE StuAge BETWEEN AND ;
-- WHERE StuAge NOT BETWEEN AND ;
SELECT *
FROM Student
WHERE (StuAge BETWEEN AND ) AND Subject NOT IN('Java');
SELECT *
FROM Student
WHERE StuName BETWEEN '曹操' AND '关羽'
ORDER BY StuName;
--若有日期的话
--SELECT * FROM Student WHERE Date BETWEEN #//# AND #//#;
-- 连接
-- 内
SELECT *
FROM Student INNER JOIN UserLogin
ON Student.StuName=UserLogin.UserName;
-- 左外
SELECT *
FROM Student LEFT JOIN UserLogin
ON Student.StuName=UserLogin.UserName;
-- 右外
SELECT *
FROM Student RIGHT JOIN UserLogin
ON Student.StuName=UserLogin.UserName;
-- 自然
SELECT *
FROM Student FULL JOIN UserLogin
ON Student.StuName=UserLogin.UserName;
-- 自连接
SELECT S.StuName AS NAME1,U.UserName AS NAME2
FROM Student S,UserLogin U
WHERE S.ID =U.ID;
--组合并去重复
SELECT StuName AS NAME
FROM Student
UNION
SELECT UserName
FROM UserLogin
ORDER BY StuName;
--组合但未去重复
SELECT StuName AS NAME
FROM Student
UNION ALL
SELECT UserName
FROM UserLogin
ORDER BY StuName;
--复制表中的数据到另一个新建表
SELECT *
INTO Student1015
FROM Student;
-- 复制到另一个数据库//貌似不可行
SELECT *
INTO Student181015 IN 'Nwind.mdb'
FROM Student;
--只复制一些列到新表
SELECT StuName,StuAge
INTO Student1015_1
FROM Student;
--复制多个表中信息插入新表
SELECT UserLogin.ID,Student.StuName,Student.StuAge
INTO Student1015_2
FROM Student INNER JOIN UserLogin
ON Student.StuName=UserLogin.UserName
ORDER BY UserLogin.ID;
--建一个空表,查询返回时无返回值
SELECT *
INTO newtable
FROM Student
WHERE =;
--把指定列插入另一个表的指定列
INSERT INTO Student1015_2(ID,StuName,StuAge)
SELECT TOP Student.ID,Student.Subject,Student.StuAge
FROM Student
WHERE Student.Subject='c#';
--删除表
DROP TABLE Student1015_2;
--只删除表中数据
TRUNCATE TABLE Student1015_2;
--添加列
ALTER TABLE Student1015_1
ADD STU15 DATE;
--删除列
ALTER TABLE Student1015_1
DROP COLUMN STU15;
--更改列
ALTER TABLE Student1015_1
ALTER COLUMN STU15 DATETIME;
--创建视图
GO
CREATE VIEW [MYSTUDENT] AS
SELECT ID,StuName
FROM Student1015
WHERE StuAge=;
GO
GO
CREATE VIEW [DYMYSTUDENT] AS
SELECT ID,StuName
FROM Student1015
WHERE StuAge>(SELECT AVG(StuAge) FROM Student1015);
GO
--查询视图
GO
SELECT *
FROM [MYSTUDENT]
GO
--更新视图//貌似不行
GO
CREATE OR REPLACE VIEW [MYSTUDENT] AS
SELECT ID,StuName
FROM Student1015
WHERE StuAge=;
GO
--删除视图
DROP VIEW [MYSTUDENT];
--查询时间
SELECT *
FROM Student1015_1
WHERE STU15='2018-10-15';
----------------------------------------------------------------------------------------------------------------
2018.10.:周二
--进阶
--别名
SELECT StuName,StuNum+','+StuClass+','+StuGender+','+StuPhone AS 信息
FROM Student;
--删除主键约束
ALTER TABLE Student DROP CONSTRAINT PK_Student;
--创建表并添加唯一性约束
CREATE TABLE Persons(
P_Id int NOT NULL,
LastName varchar() NOT NULL,
FirstName varchar(),
Address varchar(),
City varchar(),
CONSTRAINT uc_PersonID UNIQUE (P_Id,LastName)
);
--如果表已被创建添加唯一性约束
ALTER TABLE Student
ADD UNIQUE (ID);
--如果需要命名约束
ALTER TABLE Student
ADD CONSTRAINT uc_Student UNIQUE (ID,StuName)
--删除这个约束
ALTER TABLE Student
DROP CONSTRAINT uc_Student;
--主键约束
CREATE TABLE Person(
P_Id int NOT NULL,
LastName varchar() NOT NULL,
FirstName varchar(),
Address varchar(),
City varchar(),
CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName)
);
--在上面的实例中,只有一个主键 PRIMARY KEY(pk_PersonID)。
--然而,pk_PersonID 的值是由两个列(P_Id 和 LastName)组成的。
--如果表已创建
ALTER TABLE Person
ADD CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName);
--删除约束
ALTER TABLE Person
DROP CONSTRAINT pk_PersonID;
--外键约束
CREATE TABLE Orders(
O_Id int NOT NULL PRIMARY KEY,
OrderNo int NOT NULL,
P_Id int FOREIGN KEY REFERENCES Person(P_Id)
);
--如需命名 FOREIGN KEY 约束,并定义多个列的 FOREIGN KEY 约束
CREATE TABLE Orders1(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
CONSTRAINT fk_PerOrders FOREIGN KEY (P_Id)
REFERENCES Person(P_Id)
);
-- 当表已被创建时
ALTER TABLE Orders
ADD FOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)
-- 如需命名 FOREIGN KEY 约束,并定义多个列的 FOREIGN KEY 约束
ALTER TABLE Orders
ADD CONSTRAINT fk_PerOrders
FOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)
-- 删除约束
ALTER TABLE Orders
DROP CONSTRAINT fk_PerOrders
-- 默认约束
-- 下面的 SQL 在表创建时在 "City" 列上创建 DEFAULT 约束:
CREATE TABLE Persons1016_1(
P_Id int NOT NULL,
LastName varchar() NOT NULL,
FirstName varchar(),
Address varchar(),
City varchar() DEFAULT 'Sandnes'
)
-- 通过使用类似 GETDATE() 这样的函数,DEFAULT 约束也可以用于插入系统值:
CREATE TABLE Orders1016_2(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
OrderDate date DEFAULT GETDATE()
)
--当表已被创建时,如需在 "City" 列创建 DEFAULT 约束
ALTER TABLE Persons
ADD CONSTRAINT DF_Persons_City DEFAULT('SANDNES') FOR City
--Persons 为表名
--City 为列名
--DF_Persons_City 为我们创建的默认约束的名称 约束名称一般为:约束类型简称_表名_列名
--删除
ALTER TABLE Persons1016_1
ALTER COLUMN City DROP DEFAULT;
--having
SELECT ID,StuName,StuClass,StuPhone,StuAge,SUM(ID+StuAge) AS HE
FROM Student
GROUP BY ID ,StuName,StuClass,StuPhone,StuAge
HAVING StuAge>;
2018.10.-24:周二 周三
// 复制设置
private void tzxButtonExCopy_Click(object sender, EventArgs e)
{
if (this.currentSelectedCzzlModel==null)
{
MessageBoxFunction.showInfoMessageBox("请选择正确的餐桌进行复制!");
return;
}
// 弹出选择桌台页面
SelectTableListForm formSelectTableList = new SelectTableListForm();
formSelectTableList.ShowDialog();
//获取到所选择的桌子
selectCzzlList=formSelectTableList.SelectedTableInfoList;
//MessageBox.Show(selectCzzlList.Count.ToString());
if (formSelectTableList.DialogResult != DialogResult.OK)
{
return;
}
if (selectCzzlList == null || selectCzzlList.Count == )
{
return;
}
//把设置复制到所选择的餐桌
foreach (cy_jczl_czzl_lb item in selectCzzlList)
{
if (this.currentSelectedCzzlModel.pk == item.pk)
{
continue;
}
//对某些餐桌上已有设置的菜品进行清空
List<cy_jczl_czzl_ktsp> deleteKtspList=TableProfileManager.Instance.getKtspList(item.v_no);
foreach (cy_jczl_czzl_ktsp deleteKtspModel in deleteKtspList)
{
TableProfileManager.Instance.ktspDelete(deleteKtspModel.pk);
}
//餐桌资料的一些设置进行复制
item.i_cwf_type= this.currentSelectedCzzlModel.i_cwf_type;
if (item.i_cwf_type == )
{
item.f_cwf_cz_money = this.currentSelectedCzzlModel.f_cwf_cz_money;
}
else if (item.i_cwf_type == )
{
item.f_cwf_cz_money = this.currentSelectedCzzlModel.f_cwf_cz_money;
item.f_cwf_people_money = ;
}
else if (item.i_cwf_type == )
{
item.f_cwf_people_money = this.currentSelectedCzzlModel.f_cwf_people_money;
item.f_cwf_cz_money = ;
}
else
{
return;
}
item.i_ktcd = this.currentSelectedCzzlModel.i_ktcd;
item.i_ktsp = this.currentSelectedCzzlModel.i_ktsp;
TableProfileManager.Instance.CzzlUpdate(item);
//餐桌所选的开台菜品进行复制
List<cy_jczl_czzl_ktsp> currentKtspList = TableProfileManager.Instance.getKtspList(this.currentSelectedCzzlModel.v_no);
if (currentKtspList == null || currentKtspList.Count == )
{
return;
}
foreach (cy_jczl_czzl_ktsp currentKtspModel in currentKtspList)
{
cy_jczl_czzl_ktsp copyKtspModel = new cy_jczl_czzl_ktsp();
copyKtspModel.f_amount = currentKtspModel.f_amount;
copyKtspModel.f_price = currentKtspModel.f_price;
copyKtspModel.f_total_money = currentKtspModel.f_total_money;
copyKtspModel.i_dalei_pk = currentKtspModel.i_dalei_pk;
copyKtspModel.i_czzl_pk = item.pk;
copyKtspModel.i_delete = currentKtspModel.i_delete;
copyKtspModel.i_goods_pk = currentKtspModel.i_goods_pk;
copyKtspModel.i_status = currentKtspModel.i_status;
copyKtspModel.i_operator_pk = item.i_operator_pk;
copyKtspModel.i_xiaolei_pk = currentKtspModel.i_xiaolei_pk;
copyKtspModel.t_create_time = item.t_create_time;
copyKtspModel.v_czzl_no = item.v_no;
copyKtspModel.v_dalei_name = currentKtspModel.v_dalei_name;
copyKtspModel.v_danwei_name = currentKtspModel.v_danwei_name;
copyKtspModel.v_goods_name = currentKtspModel.v_goods_name;
copyKtspModel.v_goods_no = currentKtspModel.v_goods_no;
copyKtspModel.v_mark = currentKtspModel.v_mark;
copyKtspModel.v_specs = currentKtspModel.v_specs;
copyKtspModel.v_xiaolei_name = currentKtspModel.v_xiaolei_name;
TableProfileManager.Instance.ktspAdd(copyKtspModel);
}
}
MessageBoxFunction.showInfoMessageBox("批量添加成功!");
base.Close();
return;
}
2018.10. -:周二
.设置
public partial class CustomShortcutKeyForm : Form
{
// 键入的值
private string strKey = null;
public CustomShortcutKeyForm()
{
InitializeComponent();
}
private void CustomShortcutKeyForm_Load(object sender, EventArgs e)
{
//加载列表
this.loadCustomShortcutKey();
}
// 加载列表
private void loadCustomShortcutKey()
{
this.dataGridViewShortcutKey.Rows.Clear();
List<cy_kjjsz> kjjszList = ShortCutKeyManager.Instance.getAllKjjszModelList();
if (kjjszList == null || kjjszList.Count == )
{
return;
}
int rowIndex = ;
foreach (cy_kjjsz model in kjjszList)
{
rowIndex = this.dataGridViewShortcutKey.Rows.Add();
this.dataGridViewShortcutKey.Rows[rowIndex].Cells["index"].Value = string.Format("{0}", rowIndex + );
this.dataGridViewShortcutKey.Rows[rowIndex].Cells["functionName"].Value = string.Format("{0:D2}", model.v_name);
this.dataGridViewShortcutKey.Rows[rowIndex].Cells["keys"].Value = model.v_kjj;
this.dataGridViewShortcutKey.Rows[rowIndex].Cells["gnmk"].Value = model.v_gnmk_no;
}
//if (this.currentSelectedIndex < this.dataGridViewShortcutKey.Rows.Count)
//{
// this.dataGridViewShortcutKey.CurrentCell = this.dataGridViewShortcutKey.Rows[this.currentSelectedIndex].Cells[0];
//}
}
// 保存
private void tzxRoundedButtonOK_Click(object sender, EventArgs e)
{
int updataNumber=;
ArrayList keysArrayList =new ArrayList();
foreach (DataGridViewRow dr in this.dataGridViewShortcutKey.Rows)
{
//修改的快捷键更新数据库
cy_kjjsz keysModel = ShortCutKeyManager.Instance.getkjjszModelByGnmkNo(dr.Cells["gnmk"].Value.ToString());
if(keysModel==null)
{
return;
}
if (keysModel.v_kjj != dr.Cells["keys"].Value.ToString())
{
keysModel.v_kjj = dr.Cells["keys"].Value.ToString();
bool flag = ShortCutKeyManager.Instance.kjjszUpdate(keysModel);
if(flag==true)
{
updataNumber++;
}
}
}
//Program.m_mainFormChineseFoodOnPC.loadToolStripShortCutKeys();
if (updataNumber > )
{
MessageBoxFunction.showInfoMessageBox("快捷键已修改,重启后方可生效!");
}
}
// 重置初始值
private void tzxRoundedRecover_Click(object sender, EventArgs e)
{
// 重置数据
this.kjjStartData();
}
// 初始化数据
private void kjjStartData()
{
//删除原来的设置
List<cy_kjjsz> kjjszModelList=ShortCutKeyManager.Instance.getAllKjjszModelList();
//如果不为空,则删除原来的设置
if (kjjszModelList != null)
{
foreach (cy_kjjsz kjjszModel in kjjszModelList)
{
ShortCutKeyManager.Instance.kjjszDelete(kjjszModel.pk);
}
}
// 如果为空,则将字典中的数据加入
Dictionary<string, string> dicAllToolStripShortCutKeys = ShortCutKeysToolStripManager.getAllToolStripShortCutKeysDictionary();
if (dicAllToolStripShortCutKeys == null || dicAllToolStripShortCutKeys.Count == )
{
return;
}
cy_kjjsz kjjszMode = null;
foreach (string strDicShortCutKeys in dicAllToolStripShortCutKeys.Keys)
{
kjjszMode = new cy_kjjsz();
kjjszMode.v_gnmk_no = strDicShortCutKeys;
kjjszMode.i_operator_pk=LoginManager.Instance.getLoginerEmployeePK();
kjjszMode.v_operator_name = LoginManager.Instance.getLoginerEmployeeName();
kjjszMode.v_mac_address=GetSystemInfo.GetMacAddress();
kjjszMode.v_kjj = ShortCutKeysToolStripManager.getToolStripShortCutKeysByToolStripButtonName(strDicShortCutKeys);
switch(strDicShortCutKeys)
{
case "2-1217,toolStripButtonStartTable":
kjjszMode.v_name="开台";
break;
case "2-1218,toolStripButtonChangeTable":
kjjszMode.v_name="转台";
break;
case "2-1216,toolStripButtonCancelTable":
kjjszMode.v_name="消台";
break;
case "2-1215,ToolStripMenuItemSetUpTable":
kjjszMode.v_name="搭台";
break;
case "2-1214,ToolStripMenuItemCutTable":
kjjszMode.v_name="拆台";
break;
case "2-1213,ToolStripMenuItemCombineTable":
kjjszMode.v_name="并台";
break;
case "2-1212,ToolStripMenuItemAddTable":
kjjszMode.v_name="加台";
break;
case "2-1211,ToolStripMenuItemModifyTableInfo":
kjjszMode.v_name="修改餐桌信息";
break;
case "2-1210,toolStripButtonOrderDishes":
kjjszMode.v_name="点菜";
break;
case "2-1209,toolStripButtonChangeDishes":
kjjszMode.v_name="换菜";
break;
case "2-1208,ToolStripMenuItemPushFood":
kjjszMode.v_name="催菜";
break;
case "2-1201,ToolStripMenuItemReturnDishes":
kjjszMode.v_name="退菜";
break;
case "2-1207,ToolStripMenuItemSuspend":
kjjszMode.v_name="挂起";
break;
case "2-1206,ToolStripMenuItemRouse":
kjjszMode.v_name="叫起";
break;
case "2-1601,toolStripButtonMemberSendCard":
kjjszMode.v_name="发卡";
break;
case "2-1602,toolStripButtonMemberCharge":
kjjszMode.v_name="充值";
break;
case "2-1701,toolStripButtonPrintTotalBills":
kjjszMode.v_name="打印总单";
break;
case "2-1702,toolStripButtonPreprintBills":
kjjszMode.v_name="预打账单";
break;
case "2-1703,toolStripButtonPrintKitchenOrder":
kjjszMode.v_name="补打厨打单";
break;
case "2-1400,toolStripButtonCheckOut":
kjjszMode.v_name="结账";
break;
case "2-1407,toolStripButtonAntiSettlement":
kjjszMode.v_name="反结账";
break;
case "2-1300,toolStripButtonShiftExchange":
kjjszMode.v_name="交班";
break;
case "2-1101,toolStripButtonLogoutSystem":
kjjszMode.v_name="注销";
break;
case "2-1102,toolStripButtonCloseSystem":
kjjszMode.v_name="退出系统";
break;
default:
break;
}
ShortCutKeyManager.Instance.kjjszAdd(kjjszMode);
}
MessageBoxFunction.showInfoMessageBox("快捷键已重置,重启后方可生效!");
}
//单元格编辑停止时判断输入的值
private void dataGridViewShortcutKey_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (strKey==null)
{
strKey = "";
}
this.dataGridViewShortcutKey.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = strKey;
////是否输入汉字
//if (this.dataGridViewShortcutKey.CurrentCell.ColumnIndex == 2)
//{
// string str = this.dataGridViewShortcutKey.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
// if (Regex.IsMatch(str, @"[\u4E00-\u9FA5]+$"))
// {
// Modules.MessageBoxFunction.showInfoMessageBox("不能输入汉字");
// this.dataGridViewShortcutKey.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
// strKey = null;
// return;
// }
//}
//输入是否重复
ArrayList keysArrayList =new ArrayList();
foreach (DataGridViewRow dr in this.dataGridViewShortcutKey.Rows)
{
//所输入的快捷键是否重复
for (int i = ; i < keysArrayList.Count; i++)
{
if (dr.Cells["keys"].Value.ToString() == keysArrayList[i].ToString() && dr.Cells["keys"].Value.ToString() != "")
{
MessageBoxFunction.showInfoMessageBox("快捷键不能设置重复!请修改。");
this.dataGridViewShortcutKey.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
strKey = null;
return;
}
}
keysArrayList.Add(dr.Cells["keys"].Value.ToString());
strKey = null;
}
}
//键盘键入事件
private void CustomShortcutKeyForm_KeyDown(object sender, KeyEventArgs e)
{
string s = e.KeyValue.ToString();
if (e.KeyValue >= && e.KeyValue <= || e.KeyValue >= && e.KeyValue <= )
{
strKey = Enum.GetName(typeof(Keys), e.KeyValue);
}
else
{
switch (e.KeyCode)
{
case Keys.Decimal:
strKey = ".";
break;
case Keys.Subtract:
strKey = "-";
break;
case Keys.Add:
strKey = "+";
break;
case Keys.OemBackslash: //斜杠
strKey = "/";
break;
case Keys.Multiply: //乘号
strKey = "*";
break;
case Keys.Divide: //除号
strKey = "/";
break;
case Keys.OemOpenBrackets://左括号
strKey = "[";
break;
case Keys.Oem6: //右括号
strKey = "]";
break;
case Keys.Oem1: //分号
strKey = ";";
break;
case Keys.Oem7: //引号
strKey = "'";
break;
case Keys.Oemcomma: //逗号
strKey = ",";
break;
case Keys.OemPeriod: //句号
strKey = ".";
break;
case Keys.Oem5: //反斜杠
strKey = "\\";
break;
case Keys.Oemtilde: //波浪号
strKey = "`";
break;
default:
break;
}
}
}
//编辑快捷键时切换为英文输入法
private void dataGridViewShortcutKey_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox dg_innerTextBox;
if (e.Control is TextBox && this.dataGridViewShortcutKey.CurrentCell.ColumnIndex == )
{
dg_innerTextBox = e.Control as TextBox;
dg_innerTextBox.ImeMode = ImeMode.Close;
}
}
}
}
.主界面
/// <summary>
/// 处理所有工具栏按钮的快捷键响应事件
/// </summary>
/// <param name="e"></param>
private void DealAllToolStripButtonKeysEvent(KeyEventArgs e)
{
string strKey = null;
if (e.KeyValue>=&&e.KeyValue<=||e.KeyValue>=&&e.KeyValue<=)
{
strKey=Enum.GetName(typeof(Keys), e.KeyValue);
}
else
{
switch (e.KeyCode)
{
case Keys.Decimal:
strKey = ".";
break;
case Keys.Subtract:
strKey = "-";
break;
case Keys.Add:
strKey = "+";
break;
case Keys.OemBackslash: //斜杠
strKey = "/";
break;
case Keys.Multiply: //乘号
strKey = "*";
break;
case Keys.Divide: //除号
strKey = "/";
break;
case Keys.OemOpenBrackets://左括号
strKey = "[";
break;
case Keys.Oem6: //右括号
strKey = "]";
break;
case Keys.Oem1: //分号
strKey = ";";
break;
case Keys.Oem7: //引号
strKey = "'";
break;
case Keys.Oemcomma: //逗号
strKey = ",";
break;
case Keys.OemPeriod: //句号
strKey = ".";
break;
case Keys.Oem5: //反斜杠
strKey = "\\";
break;
case Keys.Oemtilde: //波浪号
strKey = "`";
break;
default:
break;
}
}
this.responseShortcutKey(strKey);
}
/// <summary>
/// 响应自定义快捷键的方法
/// </summary>
private void responseShortcutKey(string strShortcutKey)
{
// 先判断按下的快捷键是不是设置好的快捷键
if (!dictionaryKey.ContainsValue(strShortcutKey))
{
return;
}
object control;
ToolStripButton button; // 按钮
ToolStripDropDownButton toolStripDropDown; // 二级菜单按钮
ToolStripMenuItem toolStripItemCollection; // 二级菜单下的按钮
for (int i = ; i < toolStripShortcutButton.Items.Count; i++)
{
control = toolStripShortcutButton.Items[i];
string strKey = null;
if (control is ToolStripButton)
{
button = (ToolStripButton)control;
// 判断是不是对应的按钮
strKey = string.Format("{0},{1}", (string)button.AccessibleName, (string)button.Name);
string getKeyStr = dictionaryKey[strKey];
if (getKeyStr == null)
{
return;
}
else if (strShortcutKey == getKeyStr)
{
button.PerformClick();
return;
}
}
// 如果是二级菜单,则去找二级菜单下的按钮
else if (control is ToolStripDropDownButton)
{
toolStripDropDown = (ToolStripDropDownButton)control;
for (int j = ; j < toolStripDropDown.DropDownItems.Count; j++)
{
if (!(toolStripDropDown.DropDownItems[j] is ToolStripMenuItem))
{
continue;
}
toolStripItemCollection = (ToolStripMenuItem)toolStripDropDown.DropDownItems[j];
if (toolStripItemCollection == null)
{
continue;
}
// 判断是不是对应的按钮
strKey = string.Format("{0},{1}", (string)toolStripItemCollection.AccessibleName, (string)toolStripItemCollection.Name);
string getKeyStr = dictionaryKey[strKey]; ;
if (getKeyStr == null)
{
return;
}
if (strShortcutKey == getKeyStr)
{
toolStripItemCollection.PerformClick();
return;
}
}
}
}
}
/// <summary>
/// 加载主界面快捷键显示
/// </summary>
public void loadToolStripShortCutKeys()
{
List<cy_kjjsz> kjjszModelList = ShortCutKeyManager.Instance.getAllKjjszModelList();
if (kjjszModelList == null || kjjszModelList.Count == )
{
dictionaryKey = ShortCutKeysToolStripManager.getAllToolStripShortCutKeysDictionary();
//加载快捷键字典
this.loadShortCutKeysDic();
//写入数据库
cy_kjjsz kjjszMode = null;
foreach (string strDicShortCutKeys in dictionaryKey.Keys)
{
kjjszMode = new cy_kjjsz();
kjjszMode.v_gnmk_no = strDicShortCutKeys;
kjjszMode.i_operator_pk = LoginManager.Instance.getLoginerEmployeePK();
kjjszMode.v_operator_name = LoginManager.Instance.getLoginerEmployeeName();
kjjszMode.v_mac_address = GetSystemInfo.GetMacAddress();
kjjszMode.v_kjj = ShortCutKeysToolStripManager.getToolStripShortCutKeysByToolStripButtonName(strDicShortCutKeys);
switch (strDicShortCutKeys)
{
case "2-1217,toolStripButtonStartTable":
kjjszMode.v_name = "开台";
break;
case "2-1218,toolStripButtonChangeTable":
kjjszMode.v_name = "转台";
break;
case "2-1216,toolStripButtonCancelTable":
kjjszMode.v_name = "消台";
break;
case "2-1215,ToolStripMenuItemSetUpTable":
kjjszMode.v_name = "搭台";
break;
case "2-1214,ToolStripMenuItemCutTable":
kjjszMode.v_name = "拆台";
break;
case "2-1213,ToolStripMenuItemCombineTable":
kjjszMode.v_name = "并台";
break;
case "2-1212,ToolStripMenuItemAddTable":
kjjszMode.v_name = "加台";
break;
case "2-1211,ToolStripMenuItemModifyTableInfo":
kjjszMode.v_name = "修改餐桌信息";
break;
case "2-1210,toolStripButtonOrderDishes":
kjjszMode.v_name = "点菜";
break;
case "2-1209,toolStripButtonChangeDishes":
kjjszMode.v_name = "换菜";
break;
case "2-1208,ToolStripMenuItemPushFood":
kjjszMode.v_name = "催菜";
break;
case "2-1201,ToolStripMenuItemReturnDishes":
kjjszMode.v_name = "退菜";
break;
case "2-1207,ToolStripMenuItemSuspend":
kjjszMode.v_name = "挂起";
break;
case "2-1206,ToolStripMenuItemRouse":
kjjszMode.v_name = "叫起";
break;
case "2-1601,toolStripButtonMemberSendCard":
kjjszMode.v_name = "发卡";
break;
case "2-1602,toolStripButtonMemberCharge":
kjjszMode.v_name = "充值";
break;
case "2-1701,toolStripButtonPrintTotalBills":
kjjszMode.v_name = "打印总单";
break;
case "2-1702,toolStripButtonPreprintBills":
kjjszMode.v_name = "预打账单";
break;
case "2-1703,toolStripButtonPrintKitchenOrder":
kjjszMode.v_name = "补打厨打单";
break;
case "2-1400,toolStripButtonCheckOut":
kjjszMode.v_name = "结账";
break;
case "2-1407,toolStripButtonAntiSettlement":
kjjszMode.v_name = "反结账";
break;
case "2-1300,toolStripButtonShiftExchange":
kjjszMode.v_name = "交班";
break;
case "2-1101,toolStripButtonLogoutSystem":
kjjszMode.v_name = "注销";
break;
case "2-1102,toolStripButtonCloseSystem":
kjjszMode.v_name = "退出系统";
break;
default:
break;
}
ShortCutKeyManager.Instance.kjjszAdd(kjjszMode);
}
}
else
{
foreach (cy_kjjsz item in kjjszModelList)
{
dictionaryKey.Add(item.v_gnmk_no, item.v_kjj);
}
//加载快捷键字典
this.loadShortCutKeysDic();
}
}
//加载快捷键字典
private void loadShortCutKeysDic()
{
if (dictionaryKey == null || dictionaryKey.Count == )
{
return;
}
object control;
ToolStripButton button; // 按钮
ToolStripDropDownButton toolStripDropDown; // 二级菜单按钮
ToolStripMenuItem toolStripItemCollection; // 二级菜单下的按钮
string[] key = new string[];
foreach (var item in dictionaryKey.Keys)
{
key = item.Split(',');
if (key == null || key.Length < )
{
return;
}
for (int i = ; i < toolStripShortcutButton.Items.Count; i++)
{
control = toolStripShortcutButton.Items[i];
//菜单按钮
if (control is ToolStripButton)
{
button = (ToolStripButton)control;
// 判断是不是对应的按钮
if ((string)button.Name == key[])
{
if (dictionaryKey[item] == null || dictionaryKey[item] == "")
{
continue;
}
button.Text += "(" + dictionaryKey[item] + ")";
}
}
// 如果是二级菜单,则去找二级菜单下的按钮
else if (control is ToolStripDropDownButton)
{
toolStripDropDown = (ToolStripDropDownButton)control;
for (int j = ; j < toolStripDropDown.DropDownItems.Count; j++)
{
if (!(toolStripDropDown.DropDownItems[j] is ToolStripMenuItem))
{
continue;
}
toolStripItemCollection = (ToolStripMenuItem)toolStripDropDown.DropDownItems[j];
if (toolStripItemCollection == null)
{
continue;
}
// 判断是不是对应的按钮
if ((string)toolStripItemCollection.Name == key[])
{
if (dictionaryKey[item] == null || dictionaryKey[item] == "")
{
continue;
}
toolStripItemCollection.Text += "(" + dictionaryKey[item] + ")";
}
}
}
}
}
}