//保存 protected void btnSubmit_Click(object sender, EventArgs e) { String building = this.buildingText.Text; String floor = this.floorText.Text; String room = this.roomText.Text; String capacity = this.capacityText.Text; String remark = this.remarkText.Text; int floorInt; int capacityInt; if (building == "") { JscriptMsg("考场所在楼不能为空!", "", "Error"); return; } if (floor == "") { JscriptMsg("楼层不能为空!", "", "Error"); return; } if (room == "") { JscriptMsg("房间号不能为空!", "", "Error"); return; } if (capacity == "") { JscriptMsg("容量不能为空!", "", "Error"); return; } if (Tools.CheckParams(building)) { JscriptMsg("考场所在楼名不合法!", "", "Error"); return; } if (Tools.CheckParams(floor)) { JscriptMsg("考场所在楼层不合法!", "", "Error"); return; } if (Tools.CheckParams(room)) { JscriptMsg("考场所在房间号不合法!", "", "Error"); return; } if (Tools.CheckParams(capacity)) { JscriptMsg("考场容量不合法!", "", "Error"); return; } if (Tools.CheckParams(remark)) { JscriptMsg("备注不合法!", "", "Error"); return; } try { floorInt = int.Parse(floor); capacityInt = int.Parse(capacity); }catch { JscriptMsg("输入不合法!", "", "Error"); return; } if (action == MyEnums.ActionEnum.Edit.ToString()) //修改 { if (signId != 0) { Model.CCOM.Examination_room model = new BLL.CCOM.Examination_room().GetModel(" Er_id=" + signId); if (model != null) { model.Er_building = building; model.Er_floor = floorInt; model.Er_room = room; model.Er_capacity = capacityInt; model.Er_remark = remark; if (new BLL.CCOM.Examination_room().Update(model)) { string pageUrl = Utils.CombUrlTxt("RoomList.aspx", "fun_id={0}", DESEncrypt.Encrypt(this.fun_id)); JscriptMsg("考场编辑成功!^_^", pageUrl, "Success"); } else { JscriptMsg("出现异常,考场编辑失败!", "", "Error"); } } } } else { //add Model.CCOM.Examination_room model = new Model.CCOM.Examination_room(); model.Er_building = building; model.Er_floor = floorInt; model.Er_room = room; model.Er_capacity = capacityInt; model.Er_remark = remark; model.Er_id = new BLL.CCOM.Examination_room().Add(model); if (model.Er_id > 0) { string pageUrl = Utils.CombUrlTxt("RoomList.aspx", "fun_id={0}", DESEncrypt.Encrypt(this.fun_id)); JscriptMsg("考场添加成功!^_^", pageUrl, "Success"); } else { JscriptMsg("出现异常,考场添加失败!", "", "Error"); } } }
protected string ImportDataItem(DataSet ds, ref int success, ref int error)//基础数据 { string result = ""; BLL.CCOM.Examination_room bll = new BLL.CCOM.Examination_room(); Model.CCOM.Examination_room model = new Model.CCOM.Examination_room(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string checkmsg = null; string building = ds.Tables[0].Rows[i]["所在楼"].ToString().Trim(); if (!ValidDFValue(building, true, "", ref checkmsg)) { result += "×第" + (i + 1).ToString() + "行数据更新失败,所在楼名" + checkmsg + "<br/>"; error++; continue; } else if (building != "") { model.Er_building = building; } string floor = ds.Tables[0].Rows[i]["楼层"].ToString().Trim(); int floorInt; try { floorInt = int.Parse(floor); } catch { result += "×第" + (i + 1).ToString() + "行数据更新失败,所在楼层填写需要为整数<br/>"; error++; continue; } if (!ValidDFValue(floor, true, "", ref checkmsg)) { result += "×第" + (i + 1).ToString() + "行数据更新失败,所在楼层" + checkmsg + "<br/>"; error++; continue; } else if (floor != "") { model.Er_floor = floorInt; } string room = ds.Tables[0].Rows[i]["房间号"].ToString().Trim(); if (!ValidDFValue(room, true, "", ref checkmsg)) { result += "×第" + (i + 1).ToString() + "行数据更新失败,所在房间号" + checkmsg + "<br/>"; error++; continue; } else if (room != "") { model.Er_room = room; } string cap = ds.Tables[0].Rows[i]["容量"].ToString().Trim(); int capInt; try { capInt = int.Parse(cap); } catch { result += "×第" + (i + 1).ToString() + "行数据更新失败,考场容量填写需要为整数<br/>"; error++; continue; } if (!ValidDFValue(cap, true, "", ref checkmsg)) { result += "×第" + (i + 1).ToString() + "行数据更新失败,考场容量" + checkmsg + "<br/>"; error++; continue; } else if (cap != "") { model.Er_capacity = capInt; } string remark = ds.Tables[0].Rows[i]["备注"].ToString().Trim(); if (!ValidDFValue(remark, false, "", ref checkmsg)) { result += "×第" + (i + 1).ToString() + "行数据更新失败,备注" + checkmsg + "<br/>"; error++; continue; } else if (remark != "") { model.Er_remark = remark; } if (bll.Add(model) == 0) { result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>"; error++; continue; } else { success++; } } return(result); }