コード例 #1
0
ファイル: Warehouse_Func.cs プロジェクト: xcxlTeam/xcxl
        private WarehouseInfo GetModelFromDataReader(SqlDataReader dr)
        {
            WarehouseInfo model = new WarehouseInfo();

            model.ID              = dr["ID"].ToInt32();
            model.WarehouseNo     = dr["WAREHOUSENO"].ToDBString();
            model.WarehouseName   = dr["WAREHOUSENAME"].ToDBString();
            model.WarehouseType   = dr["WAREHOUSETYPE"].ToInt32();
            model.ContactUser     = dr["CONTACTUSER"].ToDBString();
            model.ContactPhone    = dr["CONTACTPHONE"].ToDBString();
            model.HouseCount      = dr["HOUSECOUNT"].ToInt32();
            model.HouseUsingCount = dr["HOUSEUSINGCOUNT"].ToInt32();
            model.Address         = dr["ADDRESS"].ToDBString();
            model.LocationDesc    = dr["LOCATIONDESC"].ToDBString();
            model.WarehouseStatus = dr["WarehouseStatus"].ToInt32();
            model.IsDel           = dr["ISDEL"].ToInt32();
            model.Creater         = dr["CREATER"].ToDBString();
            model.CreateTime      = dr["CREATETIME"].ToDateTime();
            model.Modifyer        = dr["MODIFYER"].ToDBString();
            model.ModifyTime      = dr["MODIFYTIME"].ToDateTimeNull();

            if (Common_Func.readerExists(dr, "IsChecked"))
            {
                model.BIsChecked = dr["IsChecked"].ToBoolean();
            }
            if (Common_Func.readerExists(dr, "StrWarehouseStatus"))
            {
                model.StrWarehouseStatus = dr["StrWarehouseStatus"].ToDBString();
            }
            if (Common_Func.readerExists(dr, "AreaCount"))
            {
                model.AreaCount = dr["AreaCount"].ToInt32();
            }
            if (Common_Func.readerExists(dr, "AreaUsingCount"))
            {
                model.AreaUsingCount = dr["AreaUsingCount"].ToInt32();
            }

            model.HouseRate = model.HouseCount >= 1 ? model.HouseUsingCount.ToDecimal() / model.HouseCount.ToDecimal() : 0;
            model.AreaRate  = model.AreaCount >= 1 ? model.AreaUsingCount.ToDecimal() / model.AreaCount.ToDecimal() : 0;

            return(model);
        }
コード例 #2
0
ファイル: Warehouse_Func.cs プロジェクト: xcxlTeam/xcxl
 public bool SaveWarehouse(ref WarehouseInfo model, UserInfo user, ref string strError)
 {
     try
     {
         if (model.ID <= 0)
         {
             model.Creater = user.UserNo;
         }
         else
         {
             model.Modifyer = user.UserNo;
         }
         return(_db.SaveWarehouse(ref model));
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
コード例 #3
0
ファイル: Warehouse_Func.cs プロジェクト: xcxlTeam/xcxl
        public WarehouseInfo GetWarehouseInfo(string WarehouseNo)
        {
            WarehouseInfo model = new WarehouseInfo();

            try
            {
                if (string.IsNullOrEmpty(WarehouseNo))
                {
                    model.Status  = "E";
                    model.Message = "仓库编码不能为空!";
                    return(model);
                }
                model.WarehouseNo = WarehouseNo;
                using (SqlDataReader dr = _db.GetWarehouseBycWhCode(model))
                {
                    if (dr.Read())
                    {
                        model.WarehouseNo   = dr["cwhcode"].ToDBString();
                        model.WarehouseName = dr["cwhname"].ToDBString();
                        model.Status        = "S";
                        return(model);
                    }
                    else
                    {
                        model.Status  = "E";
                        model.Message = "找不到任何数据";
                        return(model);
                    }
                }
            }
            catch (Exception ex)
            {
                model.Status  = "E";
                model.Message = ex.Message;
                return(model);
            }
            finally
            {
            }
        }
コード例 #4
0
        public bool DeleteWarehouseByID(WarehouseInfo model)
        {
            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000),

                new SqlParameter("@v_ID", model.ID.ToSqlValue()),
            };
            param[0].Direction = ParameterDirection.Output;

            OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_DeleteWarehouseByID", param);

            string ErrorMsg = param[0].Value.ToDBString();

            if (ErrorMsg.StartsWith("执行错误"))
            {
                throw new Exception(ErrorMsg);
            }
            else
            {
                return(true);
            }
        }
コード例 #5
0
        public bool SaveWarehouse(ref WarehouseInfo model)
        {
            model.CreateTime = DateTime.Now;
            model.ModifyTime = DateTime.Now;
            SqlParameter[] param = GetParameterFromModel(model);

            OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_SaveWarehouse", param);

            string ErrorMsg = param[0].Value.ToDBString();

            if (ErrorMsg.StartsWith("执行错误"))
            {
                throw new Exception(ErrorMsg);
            }
            else
            {
                model.ID         = param[1].Value.ToInt32();
                model.CreateTime = param[param.Length - 3].Value.ToDateTime();
                model.ModifyTime = param[param.Length - 1].Value.ToDateTimeNull();
                return(true);
            }
        }
コード例 #6
0
        public bool ExistsWarehouseNo(WarehouseInfo model, bool bIncludeDel)
        {
            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000),

                new SqlParameter("@v_WarehouseNo", model.WarehouseNo.ToSqlValue()),
                new SqlParameter("@IncludeDel", bIncludeDel.ToSqlValue()),
            };
            param[0].Direction = ParameterDirection.Output;

            OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_ExistsWarehouseNo", param);

            string ErrorMsg = param[0].Value.ToDBString();

            if (ErrorMsg.StartsWith("执行错误"))
            {
                throw new Exception(ErrorMsg);
            }
            else
            {
                return(string.IsNullOrEmpty(ErrorMsg));
            }
        }
コード例 #7
0
ファイル: Warehouse_Func.cs プロジェクト: xcxlTeam/xcxl
        public bool GetWarehouseList(ref List <WarehouseInfo> modelList, WarehouseInfo model, UserInfo user, ref string strError)
        {
            List <WarehouseInfo> lstModel = new List <WarehouseInfo>();

            try
            {
                using (SqlDataReader dr = Common_DB.QueryAll("V_Warehouse", GetFilterSql(model, user), "*", "Order By WarehouseNo,ID Desc"))
                {
                    while (dr.Read())
                    {
                        lstModel.Add(GetModelFromDataReader(dr));
                    }
                }

                modelList = lstModel;
                return(true);
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
コード例 #8
0
        private SqlParameter[] GetParameterFromModel(WarehouseInfo model)
        {
            int i;

            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000),

                new SqlParameter("@v_ID", model.ID.ToSqlValue()),
                new SqlParameter("@v_WarehouseNo", model.WarehouseNo.ToSqlValue()),
                new SqlParameter("@v_WarehouseName", model.WarehouseName.ToSqlValue()),
                new SqlParameter("@v_WarehouseType", model.WarehouseType.ToSqlValue()),
                new SqlParameter("@v_ContactUser", model.ContactUser.ToSqlValue()),
                new SqlParameter("@v_ContactPhone", model.ContactPhone.ToSqlValue()),
                new SqlParameter("@v_HouseCount", model.HouseCount.ToSqlValue()),
                new SqlParameter("@v_HouseUsingCount", model.HouseUsingCount.ToSqlValue()),
                new SqlParameter("@v_Address", model.Address.ToSqlValue()),
                new SqlParameter("@v_LocationDesc", model.LocationDesc.ToSqlValue()),
                new SqlParameter("@v_WarehouseStatus", model.WarehouseStatus.ToSqlValue()),
                new SqlParameter("@v_IsDel", model.IsDel.ToSqlValue()),
                new SqlParameter("@v_Creater", model.Creater.ToSqlValue()),
                new SqlParameter("@v_CreateTime", model.CreateTime.ToSqlValue()),
                new SqlParameter("@v_Modifyer", model.Modifyer.ToSqlValue()),
                new SqlParameter("@v_ModifyTime", model.ModifyTime.ToSqlValue()),
            };

            i = 0;
            param[i++].Direction = ParameterDirection.Output;
            param[i++].Direction = ParameterDirection.InputOutput;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.InputOutput;
            param[i++].Direction = ParameterDirection.Input;
            param[i++].Direction = ParameterDirection.InputOutput;

            i = 0;
            param[i++].Size = 1000;
            param[i++].Size = 18;
            param[i++].Size = 20;
            param[i++].Size = 50;
            param[i++].Size = 18;
            param[i++].Size = 50;
            param[i++].Size = 50;
            param[i++].Size = 18;
            param[i++].Size = 18;
            param[i++].Size = 50;
            param[i++].Size = 200;
            param[i++].Size = 18;
            param[i++].Size = 18;
            param[i++].Size = 50;
            param[i++].Size = 30;
            param[i++].Size = 50;
            param[i++].Size = 30;

            return(param);
        }
コード例 #9
0
ファイル: Warehouse_Func.cs プロジェクト: xcxlTeam/xcxl
        private string GetFilterSql(WarehouseInfo model, UserInfo user)
        {
            try
            {
                string strSql   = " Where ISNULL(IsDel,1) = 1 ";
                bool   hadWhere = true;


                if (!string.IsNullOrEmpty(model.WarehouseNo))
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " (WarehouseNo LIKE '%" + model.WarehouseNo + "%' OR WarehouseName Like '%" + model.WarehouseNo + "%') ";
                    hadWhere = true;
                }

                //if (!string.IsNullOrEmpty(model.WarehouseName))
                //{
                //    strSql = Common_Func.AddWhereAnd(strSql, hadWhere);
                //    strSql += " WarehouseName LIKE '%" + model.WarehouseName + "%' ";
                //    hadWhere = true;
                //}

                if (!string.IsNullOrEmpty(model.HouseNo))
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " ID In (Select WarehouseID From T_House Where HouseNo LIKE '%" + model.HouseNo + "%' OR HouseName Like '%" + model.HouseNo + "%') ";
                    hadWhere = true;
                }

                //if (!string.IsNullOrEmpty(model.HouseName))
                //{
                //    strSql = Common_Func.AddWhereAnd(strSql, hadWhere);
                //    strSql += " ID In (Select WarehouseID From T_House Where HouseName LIKE '%" + model.HouseName + "%') ";
                //    hadWhere = true;
                //}

                if (!string.IsNullOrEmpty(model.Address))
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " Address Like '%" + model.Address + "%' ";
                    hadWhere = true;
                }

                if (!string.IsNullOrEmpty(model.Creater))
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " Creater Like '%" + model.Creater + "%' ";
                    hadWhere = true;
                }

                if (model.StartTime != null)
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " CreateTime >= " + model.StartTime.ToDateTime().Date.ToSqlTimeString() + " ";
                    hadWhere = true;
                }

                if (model.EndTime != null)
                {
                    strSql   = Common_Func.AddWhereAnd(strSql, hadWhere);
                    strSql  += " CreateTime <= " + model.EndTime.ToDateTime().AddDays(1).Date.ToSqlTimeString() + " ";
                    hadWhere = true;
                }


                return(strSql);
            }
            catch
            {
                return(string.Empty);
            }
        }