/// <summary> /// GridView绑定 /// </summary> /// <param name="intCurrentIndex"></param> private void Bind(int intCurrentIndex) { TB_Bed mTB_Bed = new TB_Bed(); BedBLL mBedBLL = new BedBLL(); Pager pager = new Pager(); pager.CurrentPageIndex = intCurrentIndex; pager.srcOrder = " ID desc"; mTB_Bed.SiteID = (base.UserInfo == null ? base.SystemAdminInfo.SiteID : base.UserInfo.SiteID); mTB_Bed.DormAreaID = Convert.ToInt32(this.ddlDormArea.SelectedValue); mTB_Bed.BuildingID = Convert.ToInt32(Request.Form[this.ddlBuildingName.UniqueID.ToString()]); mTB_Bed.UnitID = Convert.ToInt32(Request.Form[this.ddlUnit.UniqueID.ToString()]); mTB_Bed.FloorID = Convert.ToInt32(Request.Form[this.ddlFloor.UniqueID.ToString()]); mTB_Bed.RoomID = Convert.ToInt32(Request.Form[this.ddlRoom.UniqueID.ToString()]); mTB_Bed.Status = (int)TypeManager.BedStatus.Free; //mTB_Bed.RoomType = Convert.ToInt32(this.ddlRoomType.SelectedValue); //mTB_Bed.RoomSexType = this.ddlRoomSexType.SelectedValue; mTB_Bed.Name = this.txtBed.Text.Trim(); GridView1.DataSource = mBedBLL.GetTableByEnableStatus(mTB_Bed, ref pager); GridView1.DataBind(); this.Pager1.ItemCount = pager.TotalRecord; this.Pager1.PageCount = pager.TotalPage; this.Pager1.CurrentIndex = pager.CurrentPageIndex; this.Pager1.PageSize = pager.PageSize; }
/// <summary> /// 初始化页面数据 /// </summary> private void InitPage() { string strID = Request.QueryString["id"]; int intID; TB_Bed mTB_Bed = null; BedBLL mBedBLL = new BedBLL(); if (Int32.TryParse(strID, out intID)) { mTB_Bed = mBedBLL.Get(intID); this.txtBed.Text = mTB_Bed.Name; this.txtKeyCount.Text = mTB_Bed.KeyCount.ToString(); this.ddlDormArea.SelectedValue = mTB_Bed.DormAreaID.ToString(); this.BindDDLBuilding(mTB_Bed.DormAreaID); this.ddlBuilding.SelectedValue = mTB_Bed.BuildingID.ToString(); this.BindDDLUnit(mTB_Bed.BuildingID); this.ddlUnit.SelectedValue = mTB_Bed.UnitID.ToString(); //this.ddlRoomType.SelectedValue = mTB_Room.RoomType.ToString(); //this.ddlRoomSexType.SelectedValue = mTB_Room.RoomSexType.ToString(); this.BindDDLFloor(mTB_Bed.UnitID); this.ddlFloor.SelectedValue = mTB_Bed.FloorID.ToString(); //this.BindDDLRoom(mTB_Bed.FloorID); this.BindDDLRoomByBuildingID(mTB_Bed.BuildingID); this.ddlRoom.SelectedValue = mTB_Bed.RoomID.ToString(); } }
public string EditBed(TB_Bed tb_Bed) { BedBLL mBedBLL = new BedBLL(); mBedBLL.ErrMessage = string.Empty; mBedBLL.Edit(tb_Bed); return(mBedBLL.ErrMessage); }
/// <summary> /// 导入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnImport_Click(object sender, EventArgs e) { string strFilePath = ViewState["FilePath"] as String; if (string.IsNullOrEmpty(strFilePath)) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Error", "alert('请先上传需要导入的文件!')", true); return; } try { DataTable dt = new ExcelHelper().GetDataFromExcel(strFilePath); if (dt.Columns.Count != 8) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Error", "alert('文件模板有误,请重新下载模板!')", true); return; } string errorMsg = ""; int iInsertCount = new BedBLL().Import(dt, ref errorMsg); if (dt.Rows.Count - iInsertCount > 0) { if (iInsertCount == 0) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Success", "alert('导入失败:" + errorMsg + "')", true); } else { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Success", "alert('导入完成!存在记录" + (dt.Rows.Count - iInsertCount).ToString() + "条,新增记录" + iInsertCount + "条')", true); } } else { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Success", "alert('导入完成!新增记录" + iInsertCount + "条')", true); } this.Bind(1); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Error", "alert('导入失败!" + ex.Message + "')", true); } finally { ViewState["FilePath"] = null; } }