/// <summary> /// 导入数据到数据库Menu Category /// </summary> /// <param name="outFile">文件</param> /// <returns></returns> public static bool ImportMenuCate(string importFile, string SheetName) { DataTable dt = GetExcelFileData(importFile, SheetName).Tables[0]; try { //清除Menu Cate中的数据 new OnLoadSystemCommonData().GetTAMenuCategory(); foreach (var taMenuCate in CommonData.TaMenuCategoryList) { _control.DeleteEntity(taMenuCate); } //添加数据 foreach (DataRow item in dt.Rows) { if (!string.IsNullOrEmpty(item[0].ToString()) && !string.IsNullOrEmpty(item[1].ToString()) && !string.IsNullOrEmpty(item[2].ToString()) && !string.IsNullOrEmpty(item[3].ToString())) { TAMenuCategoryInfo taMenuCategoryInfo = new TAMenuCategoryInfo(); taMenuCategoryInfo.SystemKey = Guid.NewGuid(); taMenuCategoryInfo.Remark = item[0].ToString(); taMenuCategoryInfo.DisplayPosition = item[1].ToString(); taMenuCategoryInfo.EnglishName = item[2].ToString(); taMenuCategoryInfo.OtherName = item[3].ToString(); _control.AddEntity(taMenuCategoryInfo); } } return(true); } catch (Exception ex) { // MessBox.Show(""); string aa = ex.Message; return(false); } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtEnglishName.Text)) { MessageBox.Show("English Name can not empty,please entry!"); return; } if (string.IsNullOrEmpty(txtOtherName.Text)) { MessageBox.Show("Other Name can not empty,please entry!"); return; } if (string.IsNullOrEmpty(txtDisplayPosition.Text)) { MessageBox.Show("Other Name can not empty,please entry!"); return; } TAMenuCategoryInfo taMenuCategoryInfo = new TAMenuCategoryInfo(); taMenuCategoryInfo.EnglishName = txtEnglishName.Text.Trim(); taMenuCategoryInfo.OtherName = txtOtherName.Text.Trim(); taMenuCategoryInfo.DisplayPosition = txtDisplayPosition.Text.Trim(); taMenuCategoryInfo.DeptSysKey = cmbBoxDeptCode.SelectedValue.ToString(); taMenuCategoryInfo.DeptCode = cmbBoxDeptCode.Text; taMenuCategoryInfo.IsHotKey = chkHotKey.Checked ? "Y" : "N"; taMenuCategoryInfo.DishCode = txtDishCode.Text.Trim(); taMenuCategoryInfo.MenuSetID = strMenuSetKey; if (iStatus == 1) { taMenuCategoryInfo.SystemKey = new Guid(Guid.NewGuid().ToString().ToUpper()); _control.AddEntity(taMenuCategoryInfo); } else //iStatus == 2 { if (dgvCategory.CurrentRow != null) { taMenuCategoryInfo.SystemKey = new Guid(dgvCategory.CurrentRow.Cells[0].Value.ToString().ToUpper()); } _control.UpdateEntity(taMenuCategoryInfo); } new OnLoadSystemCommonData().GetTAMenuCategory(); dgvCategory.DataSource = CommonData.TaMenuCategoryList; btnSave.Enabled = false; btnAdd.Enabled = true; //btnEdit.Enabled = true; btnDel.Enabled = true; //txtEnglishName.Enabled = false; //txtOtherName.Enabled = false; //txtDisplayPosition.Enabled = false; //cmbBoxDeptCode.Enabled = false; //chkHotKey.Enabled = false; //txtDishCode.Enabled = false; }