public int UpdateCell(int field, int id) { TableBll bll = new TableBll(); bll.UpdateCell(field, id); return(1); }
public JsonResult GetTable(int pageSize, int pageIndex, string search_key) { TableBll bll = new TableBll(); PagingObject pagingObject = new PagingObject(pageIndex, pageSize); // 获取数据源 List <AbhsChinese.Domain.Entity.Table> tables = bll.GetPagingTable("Id,Name,Age,Sex,Phone ", $" [Table] where Name like '%{search_key}%' ", "Id", pagingObject); _tables = tables; return(Json(new { data = tables, limit = pageSize, total = pagingObject.TotalCount }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 生成代码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCodeGenerator_Click(object sender, EventArgs e) { try { var msg = this.txtCode.Text = string.Empty; if (this._selectedTemp == null) msg = "请选择模板!"; else if (string.IsNullOrEmpty(this.txtNameSpace.Text)) { this.txtNameSpace.Focus(); msg = "请输入命名空间!"; } else if (string.IsNullOrEmpty(this.txtClassName.Text) && string.IsNullOrEmpty(this.labClassNameExtend.Text)) { this.txtClassName.Focus(); msg = "请输入类名!"; } if (!string.IsNullOrEmpty(msg)) { MessageUnity.ShowWarningMsg(msg); return; } this._codeBaseInfo.NameSpace = this.txtNameSpace.Text; this._codeBaseInfo.ClassName = this.txtClassName.Text; this._codeBaseInfo.ClassNameExtend = this.labClassNameExtend.Text; var output = string.Empty; if (this._selectedTemp.IsRanOnlyOnceByBath) //RanOnlyOnce output = TableBll.CodeGenerator("dts", new List<string> { this._codeBaseInfo.ClassName }, this._selectedTemp.Path, null); else output = TableBll.CodeGenerator(this._codeBaseInfo, this._selectedTemp.Path); if (output.StartsWith("error:")) MessageUnity.ShowErrorMsg(output); this.txtCode.Text = output; this.tabControlOpt.SelectedTab = this.tabPageCode; } catch (Exception ex) { MessageUnity.ShowErrorMsg(ex.Message); } }
/// <summary> /// 绑定表信息 /// </summary> /// <param name="dt"></param> /// <param name="isCompositeQueryDt"></param> /// <param name="sql"></param> public void BindTableInfo(DataTable dt, bool isCompositeQueryDt, string sql = "") { this.tabControlOpt.SelectedTab = this.tabPageTable; this.dgvTableInfo.DataSource = dt; if (isCompositeQueryDt) { this._codeBaseInfo = TableBll.GetCodeBaseInfoByDBTable(dt, true); this._codeBaseInfo.Sql = sql; this.txtClassName.Text = string.Empty; } else { this._codeBaseInfo = TableBll.GetCodeBaseInfoByDBTable(dt); this.txtClassName.Text = TableBll.GetClassName(dt.TableName); } }
/// <summary> /// 登陆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, EventArgs e) { try { var connectionString = string.Format("User id={0};Password={1};Server={2};database={3};", this.txtAccount.Text, this.txtPassword.Text, this.txtServerName.Text, this.txtDBName.Text); var result = TableBll.TextConnection(connectionString); if (result) { MessageUnity.ShowMsg("登陆成功!"); this.DBInfo = new DBInfo(); this.DBInfo.Key = string.Format("{0}({1})", this.txtServerName.Text, this.txtDBName.Text); this.DBInfo.ConnectionString = connectionString; this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageUnity.ShowErrorMsg(string.Format("登陆失败,错误原因:{0}", ex.Message)); } }
/// <summary> /// 绑定节点 /// </summary> /// <param name="dbInfo"></param> /// <param name="loadTable"></param> private void BindNodes(DBInfo dbInfo, bool loadTable) { if (!this._dbInfoList.Any(d => d.Key == dbInfo.Key)) { this._dbInfoList.Add(dbInfo); } var parentNode = this.tvDB.Nodes[dbInfo.Key]; if (parentNode == null) { parentNode = this.tvDB.Nodes.Insert(0, dbInfo.Key, dbInfo.Key); parentNode.ContextMenuStrip = this.parentTreeNodeMenuItem; parentNode.ImageIndex = 0; parentNode.Tag = dbInfo; } if (loadTable) { var taskArg1 = new TaskArg(); taskArg1.BeginAction = () => { var nodes = new List <TreeNode>(); dbInfo.TableList = TableBll.GetDBTableNameList(dbInfo.ConnectionString); for (int i = 0; i < dbInfo.TableList.Count; i++) { var item = dbInfo.TableList[i]; var childNode = new TreeNode(item); childNode.ContextMenuStrip = this.chideTreeNodeMenuItem; childNode.ImageIndex = childNode.SelectedImageIndex = 1; nodes.Add(childNode); Thread.Sleep(10); TaskCenter.Instance.ReportProgress( new TaskReportProgressArg { Index = i + 1, Count = dbInfo.TableList.Count, Msg = item }); } return(nodes); }; taskArg1.EndAction = (result) => { this.Invoke(new MethodInvoker(() => { parentNode.Nodes.Clear(); parentNode.Nodes.AddRange((result as List <TreeNode>).ToArray()); parentNode.ExpandAll(); })); }; TaskCenter.Instance.AddTask(taskArg1); TaskCenter.Instance.ExecuteTasks(); } }
/// <summary> /// 树状控件菜单点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TreeNodeMenuItem_Click(object sender, EventArgs e) { try { var menuItem = ((ToolStripMenuItem)sender); var dbInfo = (DBInfo)(this.tvDB.SelectedNode.Parent ?? this.tvDB.SelectedNode).Tag; var ucCG = new UCCodeGenerator(); var ucBCG = new UCBathCodeGenerator(dbInfo); var dt = new DataTable(); switch (menuItem.Text) { case "连接": this.BindNodes(dbInfo, true); break; case "注销": var parentNode = this.tvDB.Nodes[dbInfo.Key]; if (parentNode != null) { this.tvDB.Nodes.Remove(parentNode); this._dbInfoList.Remove(dbInfo); } this.SaveDBInfoList(); break; case "复合查询": this.tempList.IsShowCheckBoxes = false; var queryForm = new CompositeQueryForm(dbInfo); if (queryForm.ShowDialog() == DialogResult.OK) { dt = queryForm.Table; ucCG.BindTableInfo(dt, true, queryForm.Sql); this.AddUserControl(ucCG); } break; case "单表代码生成器": this.tempList.IsShowCheckBoxes = false; dt = TableBll.GetDBTableInfo(dbInfo.ConnectionString, this.tvDB.SelectedNode.Text); ucCG.BindTableInfo(dt, false); this.AddUserControl(ucCG); break; case "批量生成代码": this.tempList.IsShowCheckBoxes = true; this.AddUserControl(ucBCG); break; case "生成权限相关表": if (MessageUnity.ShowQuestionMsg("确定执行该操作吗?") == DialogResult.No) { return; } var sqls = new string[] { Resources.A_Common_RoleInfo, Resources.B_Common_MenuInfo, Resources.C_Common_ActionInfo, Resources.D_Common_RoleAction, Resources.E_Common_User, Resources.F_Common_UserRole, Resources.G_AddColumnDescription }; var result = TableBll.ExecuteSqls(dbInfo.ConnectionString, sqls); if (result) { MessageUnity.ShowMsg("生成成功!"); this.BindNodes(dbInfo, true); } break; default: break; } } catch (Exception ex) { MessageUnity.ShowErrorMsg(ex.Message); } }
private void Core() { var index = 1; var tables = this.lbTargetTable.Items; var tempList = this._selectedTemps; var codeBaseDict = new Dictionary <string, CodeBaseInfo>(); //step1 获取表结构信息 var taskArg1 = new TaskArg(); taskArg1.BeginAction = () => { foreach (string table in tables) { var dt = TableBll.GetDBTableInfo(this._dbInfo.ConnectionString, table); var codeBaseInfo = TableBll.GetCodeBaseInfoByDBTable(dt); codeBaseInfo.NameSpace = this.txtNameSpace.Text; codeBaseInfo.ClassName = TableBll.GetClassName(dt.TableName); codeBaseDict.Add(table, codeBaseInfo); Thread.Sleep(1); TaskCenter.Instance.ReportProgress( new TaskReportProgressArg { Index = index++, Count = tables.Count, Msg = string.Format("step1/3 获取 {0} 结构信息......", table) }); } return(null); }; taskArg1.EndAction = (result) => { index = 1; }; //step2 创建模板文件夹 var taskArg2 = new TaskArg(); taskArg2.BeginAction = () => { foreach (var temp in tempList) { //一个模板一个子文件夹 var savePath = Path.Combine(this.txtOutputDirectory.Text, temp.DirName); if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } Thread.Sleep(100); TaskCenter.Instance.ReportProgress( new TaskReportProgressArg { Index = index++, Count = tempList.Count, Msg = string.Format("step2/3 创建模板文件夹{0}......", temp.DirName) }); } return(null); }; taskArg2.EndAction = (result) => { index = 1; }; //step3 生成代码 var taskArg3 = new TaskArg(); taskArg3.BeginAction = () => { var list = tempList.Where(d => !d.IsRanOnlyOnceByBath); foreach (var temp in list) { foreach (string table in tables) { var codeBaseInfo = codeBaseDict[table]; codeBaseInfo.ClassNameExtend = temp.ClassNameExtend; var output = TableBll.CodeGenerator(codeBaseInfo, temp.Path); var msg = string.Format(@"{0}\{1}", temp.Name, table); if (output.StartsWith("error:")) { this._failureTableList.Add(msg); } else { var fileName = string.IsNullOrEmpty(temp.FileName) ? codeBaseInfo.ClassName : temp.FileName; fileName = string.Format("{0}{1}{2}", fileName, temp.ClassNameExtend, temp.FileNameExtend); //一个模板一个子文件夹 var savePath = Path.Combine(this.txtOutputDirectory.Text, temp.DirName); if (temp.IsCreateChildDirByTableName) { savePath = Path.Combine(savePath, codeBaseInfo.ClassName); if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } } savePath = Path.Combine(savePath, fileName); File.WriteAllText(savePath, output, Encoding.UTF8); this._successTableList.Add(msg); } Thread.Sleep(1); TaskCenter.Instance.ReportProgress( new TaskReportProgressArg { Index = index++, Count = list.Count() * tables.Count, Msg = string.Format("step3/3 生成代码{0}/{1}......", temp.Name, table) }); } } index = 1; //RanOnlyOnce list = tempList.Where(d => d.IsRanOnlyOnceByBath); foreach (var temp in list) { var output = TableBll.CodeGenerator("dts", codeBaseDict.Values.Select(d => d.ClassName).ToList(), temp.Path, null); var msg = temp.Name; if (output.StartsWith("error:")) { this._failureTableList.Add(msg); } else { var fileName = string.Format("{0}{1}{2}", temp.FileName, temp.ClassNameExtend, temp.FileNameExtend); var savePath = Path.Combine(this.txtOutputDirectory.Text, temp.DirName); savePath = Path.Combine(savePath, fileName); File.WriteAllText(savePath, output, Encoding.UTF8); this._successTableList.Add(msg); Thread.Sleep(1); TaskCenter.Instance.ReportProgress( new TaskReportProgressArg { Index = index++, Count = list.Count(), Msg = string.Format("step3/3 生成代码{0}......", temp.Name) }); } } return(null); }; taskArg3.EndAction = (result) => { this.Invoke(new MethodInvoker(() => { var msg = "导出完成"; //if (e.Error != null) //{ // msg = e.Error.Message; // this._successTableList.Clear(); // this._failureTableList.Clear(); //} //else if (e.Cancelled) // msg = "导出被取消!"; //else // msg = "导出完成!"; this.SetContorlsEnabled(true); var form = new BathCodeGeneratorResultForm(msg, this.txtOutputDirectory.Text, this._successTableList, this._failureTableList); form.ShowDialog(); })); }; TaskCenter.Instance.AddTask(taskArg1); TaskCenter.Instance.AddTask(taskArg2); TaskCenter.Instance.AddTask(taskArg3); TaskCenter.Instance.ExecuteTasks(); }
public ActionResult SubmitBooking(Order model) { if (DateTime.Today.AddDays(int.Parse(WebSetting.GetBookingLimit())) < model.OrderTime) { RedirectToAction("Index", "Home"); } ISettingRepository settingRepository = new SettingRepository(); var discount = decimal.Parse(settingRepository.GetSettingByKey(SystemSettingEnum.Discount.ToString()).Value); var tax = decimal.Parse(settingRepository.GetSettingByKey(SystemSettingEnum.Tax.ToString()).Value); var order = new Order { LastUpdate = DateTime.Now, CreationTime = DateTime.Now, Name = Resources.Resources.Content_Booking, Note = model.Note, DepositPrice = 0, Discount = discount, Tax = tax, OrderDetails = new List <OrderDetail>(), }; var tableBll = new TableBll(); foreach (var item in model.OrderDetails) { if (tableBll.GetOrderByTableIdAndTime(item.TableId, item.OrderTime.Value) != null) { Session.Remove("BookingEntry"); RedirectToAction("Index", "Home"); } if (!item.FoodId.HasValue) { var food = _foodRepository.Find(item.FoodId.Value); order.OrderDetails.Add(new OrderDetail { TableId = 9, FoodId = item.FoodId, FoodName = food.Name, FoodPrice = food.Price, Quantity = food.Quantity, Subtotal = food.Price * food.Quantity, CreationTime = DateTime.Now, OrderTime = item.OrderTime, LastUpdate = DateTime.Now }); } else { var food = _foodRepository.Find(item.FoodId.Value); if (!item.Quantity.HasValue || !(item.Quantity > 0) || food.Quantity < item.Quantity.Value) { return(RedirectToAction("Error", "Home")); } var sameOrderdetails = order.OrderDetails.FirstOrDefault(x => x.FoodId == food.Id && x.TableId == item.TableId); if (sameOrderdetails == null) { order.OrderDetails.Add(new OrderDetail { TableId = item.TableId, Food = food, FoodId = food.Id, FoodName = food.Name, FoodPrice = food.Price, Quantity = item.Quantity, Subtotal = food.Price * item.Quantity.Value, CreationTime = DateTime.Now, LastUpdate = DateTime.Now }); } else { sameOrderdetails.Quantity++; } order.SubTotal += food.Price * item.Quantity.Value; //Session["ReturnToUrl"] = "Orders/viewbooking"; } } Session["Booking"] = order; return(RedirectToAction("ViewBooking")); }