Exemple #1
0
        public DataTable GetTable(TB_AssignRoom info)
        {
            DataTable dt = null;
            DbCommand dbCommandWrapper = null;

            try
            {
                string        strSQL     = @"select [ID]
      ,[RoomID]
      ,[isActive]
      ,[BedID]
      ,[SiteID] from [TB_AssignRoom] where 1=1";
                StringBuilder strBuilder = new StringBuilder(strSQL);
                Database      db         = DBO.GetInstance();
                dbCommandWrapper             = db.DbProviderFactory.CreateCommand();
                dbCommandWrapper.CommandType = CommandType.Text;
                strBuilder.AppendLine(" AND SiteID = @SiteID");
                db.AddInParameter(dbCommandWrapper, "@SiteID", DbType.Int32, info.SiteID);
                dbCommandWrapper.CommandText = strBuilder.ToString();
                dt = db.ExecuteDataSet(dbCommandWrapper).Tables[0];
                return(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (dbCommandWrapper != null)
                {
                    dbCommandWrapper = null;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public int Create(TB_AssignRoom info)
 {
     try
     {
         Database db = DBO.CreateDatabase();
         return(this.Create(info, (DbTransaction)null, db));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lstRoomID"></param>
        /// <returns></returns>
        public bool Add(List <int> lstRoomID)
        {
            TB_AssignRoom mTB_AssignRoom = null;
            int           siteID         = SessionHelper.Get(HttpContext.Current, TypeManager.Admin) == null ?
                                           ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).SiteID :
                                           ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).SiteID;
            string operatorUser = SessionHelper.Get(HttpContext.Current, TypeManager.Admin) == null ?
                                  ((TB_User)SessionHelper.Get(HttpContext.Current, TypeManager.User)).ADAccount :
                                  ((TB_SystemAdmin)SessionHelper.Get(HttpContext.Current, TypeManager.Admin)).Account;
            DataTable dtBed = null;

            try
            {
                foreach (var roomID in lstRoomID)
                {
                    //获取到该房间下的所有床位
                    dtBed = _mTB_BedDAL.GetTable(new TB_Bed()
                    {
                        RoomID = roomID, SiteID = siteID
                    });
                    foreach (DataRow dr in dtBed.Rows)
                    {
                        if (Convert.ToInt32(dr["Status"]) == (int)TypeManager.BedStatus.Busy ||
                            Convert.ToInt32(dr["Status"]) == (int)TypeManager.BedStatus.Occupy)
                        {
                            continue;
                        }
                        mTB_AssignRoom = new TB_AssignRoom
                        {
                            RoomID  = roomID,
                            SiteID  = siteID,
                            BedID   = Convert.ToInt32(dr[TB_Bed.col_ID]),
                            Creator = operatorUser
                        };
                        if (_mTB_AssignRoomDAL.GetTable(mTB_AssignRoom).Select("[BedID]='" + dr[TB_Bed.col_ID] + "'").Length <= 0)
                        {
                            _mTB_AssignRoomDAL.Create(mTB_AssignRoom);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
Exemple #4
0
        private void Bind(int intCurrentIndex)
        {
            TB_AssignRoom mTB_AssignRoom = new TB_AssignRoom();
            AssignRoomBLL mAssignRoomBLL = new AssignRoomBLL();
            Pager         pager          = new Pager();
            DataTable     dtSource       = null;

            pager.CurrentPageIndex = intCurrentIndex;
            pager.srcOrder         = "  ID desc";

            dtSource             = mAssignRoomBLL.GetPagerData(ref pager, this.txtCardNo.Text.Trim(), this.ddlStatus.SelectedValue);
            GridView1.DataSource = dtSource;
            GridView1.DataBind();

            this.Pager1.ItemCount    = pager.TotalRecord;
            this.Pager1.PageCount    = pager.TotalPage;
            this.Pager1.CurrentIndex = pager.CurrentPageIndex;
            this.Pager1.PageSize     = pager.PageSize;
        }
Exemple #5
0
        /// <summary>
        /// 事务添加
        /// </summary>
        /// <param name="info"></param>
        /// <param name="tran"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public int Create(TB_AssignRoom info, DbTransaction tran, Database db)
        {
            DbCommand dbCommandWrapper = null;
            int       intId;
            string    strInsertSql   = @"INSERT INTO [TB_AssignRoom] ([RoomID]
      ,[isActive],[BedID],[SiteID],[Creator]) VALUES(@RoomID,@isActive,@BedID,@SiteID,@Creator)";
            string    strSelectIdSql = ";SELECT SCOPE_IDENTITY()";

            try
            {
                dbCommandWrapper = db.GetSqlStringCommand(strInsertSql + strSelectIdSql);
                #region Add parameters
                db.AddInParameter(dbCommandWrapper, "@RoomID", DbType.Int32, info.RoomID);
                db.AddInParameter(dbCommandWrapper, "@isActive", DbType.String, (int)TypeManager.IsActive.Valid);
                db.AddInParameter(dbCommandWrapper, "@BedID", DbType.String, info.BedID);
                db.AddInParameter(dbCommandWrapper, "@SiteID", DbType.String, info.SiteID);
                db.AddInParameter(dbCommandWrapper, "@Creator", DbType.String, info.Creator);
                #endregion
                if (tran == null)
                {
                    intId = Convert.ToInt32(db.ExecuteScalar(dbCommandWrapper));
                }
                else
                {
                    intId = Convert.ToInt32(db.ExecuteScalar(dbCommandWrapper, tran));
                }
                return(intId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (dbCommandWrapper != null)
                {
                    dbCommandWrapper = null;
                }
            }
        }