示例#1
0
        public void GetNotInsEquipByWareId(HttpContext context)
        {
            string callback = context.Request["jsoncallback"];
            //当前页
            int startIndex = Convert.ToInt32(context.Request["startIndex"]);
            //页容量
            int    pageSize  = Convert.ToInt32(context.Request["pageSize"]);
            int    curwareid = Convert.ToInt32(context.Request["curwareid"]);
            string name      = context.Request["name"];
            string model     = context.Request["model"];
            string selwareid = context.Request["selwareid"];

            EmsModel.InstrumentEquip insE = new EmsModel.InstrumentEquip();
            if (!string.IsNullOrEmpty(name))
            {
                insE.Name = name;
            }
            if (!string.IsNullOrEmpty(model))
            {
                insE.Model = model;
            }
            insE.WarehouseId = curwareid;
            insE.IsDelete    = 0;
            //序列化
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            EmsModel.JsonModel mod = new EmsBLL.InstrumentEquip().GetJsonModel(insE, startIndex, pageSize, "!=", selwareid);
            //输出Json
            HttpContext.Current.Response.Write(callback +
                                               "({\"result\":" + jss.Serialize(mod) + "})");

            HttpContext.Current.Response.End();
        }
        /// <summary>
        /// 由一行数据得到一个实体
        /// </summary>
        private EmsModel.InstrumentEquip GetEmsModel(DbDataReader dr)
        {
            EmsModel.InstrumentEquip EmsModel = new EmsModel.InstrumentEquip();
            DbDataReaderToModel(EmsModel, dr);

            return(EmsModel);
        }
        /// <summary>
        /// 由DataTable得到泛型数据列表
        /// </summary>
        internal List <EmsModel.InstrumentEquip> GetListJoin(DataTable dt)
        {
            List <EmsModel.InstrumentEquip> lst = new List <EmsModel.InstrumentEquip>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                EmsModel.InstrumentEquip mod = new EmsModel.InstrumentEquip();
                DataRowToModelJoin(mod, dt.Rows[i]);
                lst.Add(mod);
            }

            return(lst);
        }
 /// <summary>
 /// 由一行DataRow数据得到一个实体
 /// </summary>
 internal void DataRowToModelJoin(EmsModel.InstrumentEquip EmsModel, DataRow dr)
 {
     EmsModel.Id            = dr["Id"] as int?; EmsModel.Number = dr["Number"] as string; EmsModel.Name = dr["Name"] as string; EmsModel.Model = dr["Model"] as string; EmsModel.Count = dr["Count"] as int?; EmsModel.Unit = dr["Unit"] as string; EmsModel.Type = dr["Type"] as int?; EmsModel.WarehouseId = dr["WarehouseId"] as int?; EmsModel.Company = dr["Company"] as string; EmsModel.Remarks = dr["Remarks"] as string; EmsModel.Creator = dr["Creator"] as string; EmsModel.CreateTime = dr["CreateTime"] as DateTime?; EmsModel.Editor = dr["Editor"] as string; EmsModel.UpdateTime = dr["UpdateTime"] as DateTime?; EmsModel.IsDelete = dr["IsDelete"] as Byte?; EmsModel.UseStatus = dr["UseStatus"] as Byte?;
     EmsModel.WarehouseName = dr["WarehouseName"] as string; //额外添加的字段WarehouseName
     EmsModel.CreateName    = dr["CreateName"] as string;    //额外添加的字段CreateName
 }
        public int GetListByPageCountAndWareid(EmsModel.InstrumentEquip EmsMod, string joinStr, string selwareid)
        {
            string sql      = GetListSql();
            string strWhere = "";

            List <DbParameter> parmsList = new List <DbParameter>();

            if (!string.IsNullOrEmpty(selwareid))
            {
                strWhere += " and inse.WarehouseId=@sel_WarehouseId "; parmsList.Add(dbHelper.CreateInDbParameter("@sel_WarehouseId", DbType.String, selwareid));
            }
            if (EmsMod.Number != null)
            {
                strWhere += " and inse.Number=@in_Number "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Number", DbType.String, EmsMod.Number));
            }
            if (EmsMod.Name != null)
            {
                strWhere += " and inse.Name like '%'+@in_Name+'%' "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Name", DbType.String, EmsMod.Name));
            }
            if (EmsMod.Model != null)
            {
                strWhere += " and inse.Model like '%'+@in_Model+'%' "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Model", DbType.String, EmsMod.Model));
            }
            if (EmsMod.Count != null)
            {
                strWhere += " and inse.Count=@in_Count "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Count", DbType.String, EmsMod.Count));
            }
            if (EmsMod.Unit != null)
            {
                strWhere += " and inse.Unit=@in_Unit "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Unit", DbType.String, EmsMod.Unit));
            }
            if (EmsMod.Type != null)
            {
                strWhere += " and inse.Type=@in_Type "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Type", DbType.String, EmsMod.Type));
            }
            if (EmsMod.WarehouseId != null)
            {
                strWhere += " and inse.WarehouseId " + joinStr + "@in_WarehouseId "; parmsList.Add(dbHelper.CreateInDbParameter("@in_WarehouseId", DbType.String, EmsMod.WarehouseId));
            }
            if (EmsMod.Company != null)
            {
                strWhere += " and inse.Company=@in_Company "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Company", DbType.String, EmsMod.Company));
            }
            if (EmsMod.Remarks != null)
            {
                strWhere += " and inse.Remarks=@in_Remarks "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Remarks", DbType.String, EmsMod.Remarks));
            }
            if (EmsMod.Creator != null)
            {
                strWhere += " and inse.Creator=@in_Creator "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Creator", DbType.String, EmsMod.Creator));
            }
            if (EmsMod.CreateTime != null)
            {
                strWhere += " and inse.CreateTime=@in_CreateTime "; parmsList.Add(dbHelper.CreateInDbParameter("@in_CreateTime", DbType.String, EmsMod.CreateTime));
            }
            if (EmsMod.Editor != null)
            {
                strWhere += " and inse.Editor=@in_Editor "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Editor", DbType.String, EmsMod.Editor));
            }
            if (EmsMod.UpdateTime != null)
            {
                strWhere += " and inse.UpdateTime=@in_UpdateTime "; parmsList.Add(dbHelper.CreateInDbParameter("@in_UpdateTime", DbType.String, EmsMod.UpdateTime));
            }
            if (EmsMod.IsDelete != null)
            {
                strWhere += " and inse.IsDelete=@in_IsDelete "; parmsList.Add(dbHelper.CreateInDbParameter("@in_IsDelete", DbType.String, EmsMod.IsDelete));
            }
            if (EmsMod.UseStatus != null)
            {
                strWhere += " and UseStatus=@in_UseStatus "; parmsList.Add(dbHelper.CreateInDbParameter("@in_UseStatus", DbType.String, EmsMod.UseStatus));
            }

            DbParameter[] parms = parmsList.ToArray();//将参数集合转换为对应的数组;

            return(GetRecordCount(sql + strWhere, parms));
        }
        ///<summary>
        ///获取泛型数据列表 分页
        /// </summary>
        public List <EmsModel.InstrumentEquip> GetListByPageAndWareid(EmsModel.InstrumentEquip EmsMod, int startIndex, int endIndex, string joinStr, string selwareid)
        {
            string sql = GetListSql();
            //条件
            string strWhere = "";
            //排序
            string orderby = "UseStatus,T.ID desc ";
            //参数
            List <DbParameter> parmsList = new List <DbParameter>();

            if (!string.IsNullOrEmpty(selwareid))
            {
                strWhere += " and inse.WarehouseId=@sel_WarehouseId "; parmsList.Add(dbHelper.CreateInDbParameter("@sel_WarehouseId", DbType.String, selwareid));
            }
            if (EmsMod.Number != null)
            {
                strWhere += " and inse.Number=@in_Number "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Number", DbType.String, EmsMod.Number));
            }
            if (EmsMod.Name != null)
            {
                strWhere += " and inse.Name like '%'+@in_Name+'%' "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Name", DbType.String, EmsMod.Name));
            }
            if (EmsMod.Model != null)
            {
                strWhere += " and inse.Model like '%'+@in_Model+'%' "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Model", DbType.String, EmsMod.Model));
            }
            if (EmsMod.Count != null)
            {
                strWhere += " and inse.Count=@in_Count "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Count", DbType.String, EmsMod.Count));
            }
            if (EmsMod.Unit != null)
            {
                strWhere += " and inse.Unit=@in_Unit "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Unit", DbType.String, EmsMod.Unit));
            }
            if (EmsMod.Type != null)
            {
                strWhere += " and inse.Type=@in_Type "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Type", DbType.String, EmsMod.Type));
            }
            if (EmsMod.WarehouseId != null)
            {
                strWhere += " and inse.WarehouseId " + joinStr + "@in_WarehouseId "; parmsList.Add(dbHelper.CreateInDbParameter("@in_WarehouseId", DbType.String, EmsMod.WarehouseId));
            }
            if (EmsMod.Company != null)
            {
                strWhere += " and inse.Company=@in_Company "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Company", DbType.String, EmsMod.Company));
            }
            if (EmsMod.Remarks != null)
            {
                strWhere += " and inse.Remarks=@in_Remarks "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Remarks", DbType.String, EmsMod.Remarks));
            }
            if (EmsMod.Creator != null)
            {
                strWhere += " and inse.Creator=@in_Creator "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Creator", DbType.String, EmsMod.Creator));
            }
            if (EmsMod.CreateTime != null)
            {
                strWhere += " and inse.CreateTime=@in_CreateTime "; parmsList.Add(dbHelper.CreateInDbParameter("@in_CreateTime", DbType.String, EmsMod.CreateTime));
            }
            if (EmsMod.Editor != null)
            {
                strWhere += " and inse.Editor=@in_Editor "; parmsList.Add(dbHelper.CreateInDbParameter("@in_Editor", DbType.String, EmsMod.Editor));
            }
            if (EmsMod.UpdateTime != null)
            {
                strWhere += " and inse.UpdateTime=@in_UpdateTime "; parmsList.Add(dbHelper.CreateInDbParameter("@in_UpdateTime", DbType.String, EmsMod.UpdateTime));
            }
            if (EmsMod.IsDelete != null)
            {
                strWhere += " and inse.IsDelete=@in_IsDelete "; parmsList.Add(dbHelper.CreateInDbParameter("@in_IsDelete", DbType.String, EmsMod.IsDelete));
            }
            if (EmsMod.UseStatus != null)
            {
                strWhere += " and UseStatus=@in_UseStatus "; parmsList.Add(dbHelper.CreateInDbParameter("@in_UseStatus", DbType.String, EmsMod.UseStatus));
            }
            DbParameter[] parms = parmsList.ToArray();//将参数集合转换为对应的数组;
            DataSet       ds    = GetListByPage(sql + strWhere, orderby, startIndex, endIndex, parms);

            return(GetListJoin(ds.Tables[0]));
        }