예제 #1
0
        /// <summary>
        /// 设置实验室使用状态
        /// </summary>
        /// <param name="InfoID">要设置的实验室ID</param>
        /// <param name="IsUse">是否使用 0:空闲 1使用</param>
        /// <returns>返回是否设置成功</returns>
        public JsonResult SetUse(int InfoID, int IsUse)
        {
            E_tb_Laboratory eLaboratory = tLaboratory.GetModel(InfoID);

            eLaboratory.IsUse = IsUse;
            string str = (tLaboratory.Update(eLaboratory)) ? "设置成功!" : "设置失败!";

            return(Json(str, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_tb_Laboratory GetModel(int LaboratoryID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 LaboratoryID,AreaID,LaboratoryName,LaboratoryTypeID,Directions,UpdateTime,OrderID,IsUse from tb_Laboratory ");
            strSql.Append(" where LaboratoryID=@LaboratoryID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LaboratoryID", SqlDbType.Int, 4)
            };
            parameters[0].Value = LaboratoryID;

            E_tb_Laboratory model = new E_tb_Laboratory();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["LaboratoryID"].ToString() != "")
                {
                    model.LaboratoryID = int.Parse(ds.Tables[0].Rows[0]["LaboratoryID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AreaID"].ToString() != "")
                {
                    model.AreaID = int.Parse(ds.Tables[0].Rows[0]["AreaID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LaboratoryName"] != null)
                {
                    model.LaboratoryName = ds.Tables[0].Rows[0]["LaboratoryName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LaboratoryTypeID"].ToString() != "")
                {
                    model.LaboratoryTypeID = int.Parse(ds.Tables[0].Rows[0]["LaboratoryTypeID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Directions"] != null)
                {
                    model.Directions = ds.Tables[0].Rows[0]["Directions"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UpdateTime"].ToString() != "")
                {
                    model.UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderID"].ToString() != "")
                {
                    model.OrderID = int.Parse(ds.Tables[0].Rows[0]["OrderID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsUse"].ToString() != "")
                {
                    model.IsUse = int.Parse(ds.Tables[0].Rows[0]["IsUse"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 显示详情页
        /// </summary>
        /// <param name="EditType">编辑类型</param>
        /// <returns>返回编辑结果</returns>
        public ActionResult LaboratoryEdit(E_tb_Laboratory eLaboratory, string EditType, int?InfoID)
        {
            ViewData["AreaList"] = GetAreaList();
            DataTable typelist = tTypeDict.GetList("SubjectID=4").Tables[0];

            ViewData["LaboratoryTypeList"] = PageTools.GetSelectList(typelist, "TypeID", "TypeName", false);
            if (EditType == "Edit")
            {
                eLaboratory = tLaboratory.GetModel(Convert.ToInt32(InfoID));
            }
            eLaboratory.UserAreaID    = Convert.ToInt32(CurrentUserInfo.AreaID);
            eLaboratory.UserDataRange = CurrentUserInfo.DataRange;
            eLaboratory.EditType      = EditType;
            return(View(eLaboratory));
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_tb_Laboratory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Laboratory set ");
            strSql.Append("AreaID=@AreaID,");
            strSql.Append("LaboratoryName=@LaboratoryName,");
            strSql.Append("LaboratoryTypeID=@LaboratoryTypeID,");
            strSql.Append("Directions=@Directions,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("OrderID=@OrderID,");
            strSql.Append("IsUse=@IsUse");
            strSql.Append(" where LaboratoryID=@LaboratoryID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AreaID",           SqlDbType.Int,        4),
                new SqlParameter("@LaboratoryName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@LaboratoryTypeID", SqlDbType.Int,        4),
                new SqlParameter("@Directions",       SqlDbType.Text),
                new SqlParameter("@UpdateTime",       SqlDbType.DateTime),
                new SqlParameter("@OrderID",          SqlDbType.Int,        4),
                new SqlParameter("@IsUse",            SqlDbType.Int,        4),
                new SqlParameter("@LaboratoryID",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AreaID;
            parameters[1].Value = model.LaboratoryName;
            parameters[2].Value = model.LaboratoryTypeID;
            parameters[3].Value = model.Directions;
            parameters[4].Value = model.UpdateTime;
            parameters[5].Value = model.OrderID;
            parameters[6].Value = model.IsUse;
            parameters[7].Value = model.LaboratoryID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <E_tb_Laboratory> DataTableToList(DataTable dt)
        {
            List <E_tb_Laboratory> modelList = new List <E_tb_Laboratory>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                E_tb_Laboratory model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new E_tb_Laboratory();
                    if (dt.Rows[n]["LaboratoryID"].ToString() != "")
                    {
                        model.LaboratoryID = int.Parse(dt.Rows[n]["LaboratoryID"].ToString());
                    }
                    if (dt.Rows[n]["AreaID"].ToString() != "")
                    {
                        model.AreaID = int.Parse(dt.Rows[n]["AreaID"].ToString());
                    }
                    model.LaboratoryName = dt.Rows[n]["LaboratoryName"].ToString();
                    if (dt.Rows[n]["LaboratoryTypeID"].ToString() != "")
                    {
                        model.LaboratoryTypeID = int.Parse(dt.Rows[n]["LaboratoryTypeID"].ToString());
                    }
                    model.Directions = dt.Rows[n]["Directions"].ToString();
                    if (dt.Rows[n]["UpdateTime"].ToString() != "")
                    {
                        model.UpdateTime = DateTime.Parse(dt.Rows[n]["UpdateTime"].ToString());
                    }
                    if (dt.Rows[n]["OrderID"].ToString() != "")
                    {
                        model.OrderID = int.Parse(dt.Rows[n]["OrderID"].ToString());
                    }
                    if (dt.Rows[n]["IsUse"].ToString() != "")
                    {
                        model.IsUse = int.Parse(dt.Rows[n]["IsUse"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
예제 #6
0
        /// <summary>
        /// 保存实验室信息
        /// 作者:小朱
        /// </summary>
        /// <param name="eLaboratory">要处理的对象</param>
        /// <returns>返回是否处理成功</returns>
        public string SaveLadoratory(E_tb_Laboratory eLaboratory)
        {
            string msg = "0";

            if (CurrentUserInfo.DataRange != 1) //若当前用户不是超级管理员 则数据为自己所属区域的数据
            {
                eLaboratory.AreaID = CurrentUserInfo.AreaID;
            }
            if (eLaboratory.EditType == "Add")
            {
                tLaboratory.Add(eLaboratory);
                msg = "1";
            }
            else
            {
                tLaboratory.Update(eLaboratory);
                msg = "1";
            }
            return(msg);
        }
예제 #7
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(E_tb_Laboratory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Laboratory(");
            strSql.Append("AreaID,LaboratoryName,LaboratoryTypeID,Directions,UpdateTime,OrderID,IsUse)");
            strSql.Append(" values (");
            strSql.Append("@AreaID,@LaboratoryName,@LaboratoryTypeID,@Directions,@UpdateTime,@OrderID,@IsUse)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AreaID",           SqlDbType.Int,        4),
                new SqlParameter("@LaboratoryName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@LaboratoryTypeID", SqlDbType.Int,        4),
                new SqlParameter("@Directions",       SqlDbType.Text),
                new SqlParameter("@UpdateTime",       SqlDbType.DateTime),
                new SqlParameter("@OrderID",          SqlDbType.Int,        4),
                new SqlParameter("@IsUse",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AreaID;
            parameters[1].Value = model.LaboratoryName;
            parameters[2].Value = model.LaboratoryTypeID;
            parameters[3].Value = model.Directions;
            parameters[4].Value = model.UpdateTime;
            parameters[5].Value = model.OrderID;
            parameters[6].Value = model.IsUse;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(E_tb_Laboratory model)
 {
     return(dal.Update(model));
 }
예제 #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(E_tb_Laboratory model)
 {
     return(dal.Add(model));
 }