// public void SaveTableInBatch(int loop) { Table table = new Table(); if (CodePrefix != null && !CodePrefix.Trim().Equals("")) {//编号有前缀 int lengthDiff = Convert.ToInt32(CodeLength) - (CodePrefix.Length + loop.ToString().Length); if (lengthDiff <= 0) {//前缀加编号是否大于编号长度,如果小于则要补0 table.Code = CodePrefix + loop.ToString(); } else {//长度不达标,中间补0 for (int Cursor = 1; Cursor <= lengthDiff; Cursor++) { table.Code = CodePrefix + "0"; } table.Code = table.Code + loop.ToString(); } } else {//编号没有前缀 int lengthDiff = Convert.ToInt32(CodeLength) - loop.ToString().Length; if (lengthDiff <= 0) {//前缀加编号是否大于编号长度,如果小于则要补0 table.Code = loop.ToString(); } else {//长度不达标,中间补0 for (int Cursor = 1; Cursor <= lengthDiff; Cursor++) { table.Code = "0"; } table.Code = table.Code + loop.ToString(); } } table.Name = "桌" + table.Code; table.LocationId = LocationId; table.TableTypeId = TableTypeId; table.Seat = Convert.ToInt32(Seat); table.Deleted = 0; table.Status = Status; table.CreateBy = SubjectUtils.GetAuthenticationId(); table.CreateDatetime = DateTime.Now; table.UpdateBy = SubjectUtils.GetAuthenticationId(); table.UpdateDatetime = DateTime.Now; _TableService.SaveTable(table); //刷新餐桌列表数据 TableGrid.Add(table); }