/// <summary> /// 获取所有数据,整个表的记录 /// </summary> /// <returns></returns> public DataSet GetAll() { da = new DBConnection(); DataSet ds = new DataSet(); ds = da.SelectQuery("Select * from [ImageType]"); ds.Tables[0].TableName = "ImageType"; return ds; }
/// <summary> /// 获取所有数据、整个表的记录 /// </summary> /// <returns></returns> public DataSet GetAll() { da = new DBConnection(); DataSet ds = new DataSet(); StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * From [Local]"); ds = da.SelectQuery(selectStr.ToString()); ds.Tables[0].TableName = "Local"; return ds; }
/// <summary> /// 获取一个影像类 /// </summary> /// <param name="_userTypeCode"></param> /// <returns></returns> public Renting_Management_System.Models.ImageTypeMod SelectData(string _imageTypeCode) { da = new DBConnection(); DataSet ds = new DataSet(); StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * From [ImageType] "); selectStr.Append("Where 影类代码 = '"); selectStr.Append(_imageTypeCode); selectStr.Append("'"); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count == 0) { return null; } else { type = new Renting_Management_System.Models.ImageTypeMod(); type.ImageTypeCode = ds.Tables[0].Rows[0][0].ToString().Trim(); type.ImageTypeName = ds.Tables[0].Rows[0][1].ToString().Trim(); return type; } }
/// <summary> /// 获取所有租借记录,整个表的数据集 /// 返回一个数据集 /// </summary> /// <returns></returns> public DataSet GetAll() { DataSet ds = new DataSet(); da = new DBConnection(); ds = da.SelectQuery("Select * From [Rent]"); ds.Tables[0].TableName = "Rent"; return ds; }
/// <summary> /// 通过客户编号和影像编号,获取一个租借记录 /// 返回 null 表示记录不存在,否侧返回一个租借的记录 /// </summary> /// <param name="_customerID"></param> /// <param name="_imageID"></param> /// <returns></returns> public Renting_Management_System.Models.RentMod SelectBy_CustomerID_N_ImageID(string _customerID, string _imageID) { StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * From [Rent] "); selectStr.Append("Where 客户编号 = '"); selectStr.Append(_customerID); selectStr.Append("' And 影像编号 = '"); selectStr.Append(_imageID); selectStr.Append("'"); da = new DBConnection(); DataSet ds = new DataSet(); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count == 0) { return null; } else { rent = new Renting_Management_System.Models.RentMod(); rent.ImageID = ds.Tables[0].Rows[0]["影像编号"].ToString().Trim(); rent.CustomerID = ds.Tables[0].Rows[0]["客户编号"].ToString().Trim(); rent.UserID = ds.Tables[0].Rows[0]["用户编号"].ToString().Trim(); rent.QuantityOfRent = int.Parse(ds.Tables[0].Rows[0]["影像编号"].ToString().Trim()); rent.RentDate = DateTime.Parse(ds.Tables[0].Rows[0]["出租日期"].ToString().Trim()); rent.ReturnDate = DateTime.Parse(ds.Tables[0].Rows[0]["归还日期"].ToString().Trim()); rent.Deposit = int.Parse(ds.Tables[0].Rows[0]["出租押金"].ToString().Trim()); rent.ReturnState = ds.Tables[0].Rows[0]["归还状态"].ToString().Trim(); rent.Description = ds.Tables[0].Rows[0]["描述"].ToString().Trim(); return rent; } }
/// <summary> /// 通过用户编号获取一个租借记录的数据集 /// 返回 null 表示记录不存在,否侧返回一个租借记录的数据集 /// </summary> /// <param name="_userID"></param> /// <returns></returns> public DataSet SelectByUserID(string _userID) { StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * From [Rent]"); selectStr.Append("Where 用户编号 = '"); selectStr.Append(_userID); selectStr.Append("'"); da = new DBConnection(); DataSet ds = new DataSet(); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count == 0) { return null; } else { return ds; } }
/// <summary> /// 通过客户类代码获取一个客户的数据集,null 表示没有任何记录 /// </summary> /// <param name="_customerTypeCode"></param> /// <returns></returns> public DataSet SelectByTypeCode(string _customerTypeCode) { StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * from [Customer] "); selectStr.Append("Where 客户类代码 = '"); selectStr.Append(_customerTypeCode); selectStr.Append("'"); da = new DBConnection(); DataSet ds = new DataSet(); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count != 0) { return ds; } else { return null; } }
/// <summary> /// 通过客户名称获取一个客户,null 表示数据不存在 /// </summary> /// <param name="_customerName"></param> /// <returns></returns> public Renting_Management_System.Models.CustomerMod SelectByName(string _customerName) { StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * from [Customer]"); selectStr.Append("Where 客户名称 = '"); selectStr.Append(_customerName); selectStr.Append("'"); da = new DBConnection(); DataSet ds = new DataSet(); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count != 0) { customer = new Renting_Management_System.Models.CustomerMod(); customer.CustomerID = ds.Tables[0].Rows[0]["客户编号"].ToString().Trim(); customer.CustomerTypeCode = ds.Tables[0].Rows[0]["客户类代码"].ToString().Trim(); customer.CustomerName = ds.Tables[0].Rows[0]["客户名称"].ToString().Trim(); customer.Sex = char.Parse(ds.Tables[0].Rows[0]["性别"].ToString().Trim()); customer.BirthDate = DateTime.Parse(ds.Tables[0].Rows[0]["出生日期"].ToString().Trim()); customer.CertificateTypeCode = ds.Tables[0].Rows[0]["证件类代码"].ToString().Trim(); customer.CertificateNumber = ds.Tables[0].Rows[0]["证件号码"].ToString().Trim(); customer.CustomerAddress = ds.Tables[0].Rows[0]["客户地址"].ToString().Trim(); customer.CustomerContact = ds.Tables[0].Rows[0]["联系方式"].ToString().Trim(); customer.CustomerState = ds.Tables[0].Rows[0]["客户状态"].ToString().Trim(); customer.CustomerDescription = ds.Tables[0].Rows[0]["客户描述"].ToString().Trim(); customer.CustomerDeny = bool.Parse(ds.Tables[0].Rows[0]["客户拒绝"].ToString().Trim()); return customer; } else { return null; } }
/// <summary> /// 获取所有数据,整个表的记录 /// 返回一个数据集 /// </summary> /// <returns></returns> public DataSet GetAll() { da = new DBConnection(); DataSet ds = new DataSet(); string selectStr = "Select * From [Image]"; ds = da.SelectQuery(selectStr); ds.Tables[0].TableName = "Image"; return ds; }
/// <summary> /// 通过影像名称获取一个影像的记录 /// 返回 null 表示数据不存在,否侧返回一个影像的记录 /// </summary> /// <param name="_imageName"></param> /// <returns></returns> public Renting_Management_System.Models.ImageMod SelectByName(string _imageName) { StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * From [Image] "); selectStr.Append("Where 影像名称 = '"); selectStr.Append(_imageName); selectStr.Append("'"); DataSet ds = new DataSet(); da = new DBConnection(); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count == 0) { return null; } else { image = new Renting_Management_System.Models.ImageMod(); image.ImageID = ds.Tables[0].Rows[0]["影像编号"].ToString().Trim(); image.ImageName = ds.Tables[0].Rows[0]["影像名称"].ToString().Trim(); image.UserID = ds.Tables[0].Rows[0]["用户编号"].ToString().Trim(); image.ImageTypeCode = ds.Tables[0].Rows[0]["影类代码"].ToString().Trim(); image.LocalCode = ds.Tables[0].Rows[0]["地点代码"].ToString().Trim(); image.ImageCostPrice = int.Parse(ds.Tables[0].Rows[0]["影像原价"].ToString().Trim()); image.ImageRentalPrice = int.Parse(ds.Tables[0].Rows[0]["影像租价"].ToString().Trim()); image.StorageQuantity = int.Parse(ds.Tables[0].Rows[0]["库存数量"].ToString().Trim()); image.ShelvesNumber = ds.Tables[0].Rows[0]["货架号"].ToString().Trim(); image.RentState = ds.Tables[0].Rows[0]["出租状态"].ToString().Trim(); image.ImageDescription = ds.Tables[0].Rows[0]["影像描述"].ToString().Trim(); return image; } }
/// <summary> /// 获取一个地点 /// _localCode 为地点代码 /// </summary> /// <param name="_localCode"></param> /// <returns></returns> public Renting_Management_System.Models.LocalMod SelectData(string _localCode) { da = new DBConnection(); DataSet ds = new DataSet(); StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * From [Local]"); selectStr.Append("Where 地点代码 = '"); selectStr.Append(_localCode); selectStr.Append("'"); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count == 0) { return null; } else { local = new Renting_Management_System.Models.LocalMod(); local.LocalCode = ds.Tables[0].Rows[0][0].ToString().Trim(); local.LocalName = ds.Tables[0].Rows[0][1].ToString().Trim(); return local; } }
/// <summary> /// 通过用户名称可以获取一个用户 /// 返回null 表示没有改用户 /// </summary> /// <param name="_userName"></param> /// <returns></returns> public Renting_Management_System.Models.UserMod SelectByName(string _userName) { StringBuilder selectStr = new StringBuilder(); selectStr.Append("Select * From [User]"); selectStr.Append("Where 用户名称 = '"); selectStr.Append(_userName); selectStr.Append("'"); da = new DBConnection(); DataSet ds = new DataSet(); ds = da.SelectQuery(selectStr.ToString()); if (ds.Tables[0].Rows.Count == 0) { return null; } else { user = new Renting_Management_System.Models.UserMod(); user.UserID = ds.Tables[0].Rows[0]["用户编号"].ToString().Trim(); user.UserName = ds.Tables[0].Rows[0]["用户名称"].ToString().Trim(); user.Sex = char.Parse(ds.Tables[0].Rows[0]["性别"].ToString().Trim()); if (ds.Tables[0].Rows[0]["出生日期"].ToString().Trim() != "") { user.BirthDate = DateTime.Parse(ds.Tables[0].Rows[0]["出生日期"].ToString().Trim()); } user.UserPassword = ds.Tables[0].Rows[0]["用户密码"].ToString().Trim(); user.UserTypeCode = ds.Tables[0].Rows[0]["用户类代码"].ToString().Trim(); user.CertificateTypeCode = ds.Tables[0].Rows[0]["证件类代码"].ToString().Trim(); user.CertificateNumber = ds.Tables[0].Rows[0]["证件号码"].ToString().Trim(); user.UserContact = ds.Tables[0].Rows[0]["联系方式"].ToString().Trim(); user.UserAddress = ds.Tables[0].Rows[0]["用户地址"].ToString().Trim(); user.UserDescription = ds.Tables[0].Rows[0]["用户描述"].ToString().Trim(); if (ds.Tables[0].Rows[0]["用户拒绝"].ToString().Trim() != "") { user.UserDeny = bool.Parse(ds.Tables[0].Rows[0]["用户拒绝"].ToString().Trim()); } return user; } }