/// <summary>
 /// 添加一个用户
 /// 返回 true 表示成功
 /// 返回 false 表示该数据已存在
 /// </summary>
 /// <param name="_user"></param>
 /// <returns></returns>
 public bool AddData(Renting_Management_System.Models.UserMod _user)
 {
     user = new Renting_Management_System.Models.UserMod();
     user = SelectByID(_user.UserID);
     if (user == null)
     {
         StringBuilder insertStr = new StringBuilder();
         insertStr.Append("Insert Into [User] ");
         insertStr.Append("(用户编号,用户名称,性别,出生日期,用户密码,用户类代码,证件类代码,证件号码,联系方式,用户地址,用户描述,用户拒绝)");
         insertStr.Append(" Values ('");
         insertStr.Append(_user.UserID + "','");
         insertStr.Append(_user.UserName + "','");
         insertStr.Append(_user.Sex + "','");
         insertStr.Append(_user.BirthDate.Date.ToShortDateString()+ "','");
         insertStr.Append(_user.UserPassword + "','");
         insertStr.Append(_user.UserTypeCode + "','");
         insertStr.Append(_user.CertificateTypeCode + "','");
         insertStr.Append(_user.CertificateNumber + "','");
         insertStr.Append(_user.UserContact + "','");
         insertStr.Append(_user.UserAddress + "','");
         insertStr.Append(_user.UserDescription + "','");
         insertStr.Append(_user.UserDeny.ToString());
         insertStr.Append("')");
         da = new DBConnection();
         da.InsertQuery(insertStr.ToString());
         return true;
     }
     else
     { return false; }
 }
 /// <summary>
 /// 添加一个影像的信息
 /// 返回 true 表示成功,否侧该影像已存在
 /// </summary>
 /// <param name="_image"></param>
 /// <returns></returns>
 public bool AddData(Renting_Management_System.Models.ImageMod _image)
 {
     image = new Renting_Management_System.Models.ImageMod();
     image = SelectByID(_image.ImageID);
     if (image != null)
     { return false; }
     else
     {
         StringBuilder insertStr = new StringBuilder();
         insertStr.Append("Insert Into [Image] (影像编号,影像名称,用户编号,影类代码,地点代码,影像原价,影像租价,库存数量,货架号,出租状态,影像描述) ");
         insertStr.Append("Values ('");
         insertStr.Append(_image.ImageID + "','");
         insertStr.Append(_image.ImageName + "','");
         insertStr.Append(_image.UserID + "','");
         insertStr.Append(_image.ImageTypeCode + "','");
         insertStr.Append(_image.LocalCode + "',");
         insertStr.Append(_image.ImageCostPrice + ",");
         insertStr.Append(_image.ImageRentalPrice + ",");
         insertStr.Append(_image.StorageQuantity + ",'");
         insertStr.Append(_image.ShelvesNumber + "','");
         insertStr.Append(_image.RentState + "','");
         insertStr.Append(_image.ImageDescription);
         insertStr.Append("')");
         da = new DBConnection();
         da.InsertQuery(insertStr.ToString());
         return true;
     }
 }
 /// <summary>
 /// 添加一个租借的记录
 /// 返回 true 表示成功,否侧该记录已存在
 /// </summary>
 /// <param name="_rent"></param>
 /// <returns></returns>
 public bool AddData(Renting_Management_System.Models.RentMod _rent)
 {
     rent = new Renting_Management_System.Models.RentMod();
     rent =SelectBy_CustomerID_N_ImageID(_rent.CustomerID, _rent.ImageID);
     if (rent == null)
     {
         StringBuilder insertStr = new StringBuilder();
         insertStr.Append("Insert Into [Rent](影像编号,客户编号,用户编号,出租数量,出租日期,归还日期,出租押金,归还状态,描述)");
         insertStr.Append("Values ('");
         insertStr.Append(_rent.ImageID + "','");
         insertStr.Append(_rent.CustomerID + "','");
         insertStr.Append(_rent.UserID + "',");
         insertStr.Append(_rent.QuantityOfRent + ",'");
         insertStr.Append(_rent.RentDate.ToShortDateString() + "','");
         insertStr.Append(_rent.ReturnDate.ToShortDateString() + "',");
         insertStr.Append(_rent.Deposit + ",'");
         insertStr.Append(_rent.ReturnState + "','");
         insertStr.Append(_rent.Description + "'");
         da = new DBConnection();
         da.InsertQuery(insertStr.ToString());
         return true;
     }
     else
     {
         return false;
     }
 }
 /// <summary>
 /// 添加一个客户
 /// 返回 true 表示成功,否侧数据已存在
 /// </summary>
 /// <param name="_customer"></param>
 /// <returns></returns>
 public bool AddData(Renting_Management_System.Models.CustomerMod _customer)
 {
     customer = new Renting_Management_System.Models.CustomerMod();
     customer = SelectByID(_customer.CustomerID);
     if (customer == null)
     {
         StringBuilder insertStr = new StringBuilder();
         insertStr.Append("Insert Into [Customer]");
         insertStr.Append("(客户编号,客户类代码,客户名称,性别,出生日期,证件类代码,证件号码,客户地址,联系方式,客户状态,客户描述,客户拒绝)");
         insertStr.Append("Values ('");
         insertStr.Append(_customer.CustomerID + "','");
         insertStr.Append(_customer.CustomerTypeCode + "','");
         insertStr.Append(_customer.CustomerName + "','");
         insertStr.Append(_customer.Sex + "','");
         insertStr.Append(_customer.BirthDate.ToShortDateString() + "','");
         insertStr.Append(_customer.CertificateTypeCode + "','");
         insertStr.Append(_customer.CertificateNumber + "','");
         insertStr.Append(_customer.CustomerAddress + "','");
         insertStr.Append(_customer.CustomerContact + "','");
         insertStr.Append(_customer.CustomerState + "','");
         insertStr.Append(_customer.CustomerDescription + "','");
         insertStr.Append(_customer.CustomerDeny.ToString());
         insertStr.Append("')");
         da = new DBConnection();
         da.InsertQuery(insertStr.ToString());
         return true;
     }
     else
     { return false; }
 }
 /// <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>
 /// 删除一个影像
 /// 返回 true 表示成功,否侧数据不存在
 /// </summary>
 /// <param name="_image"></param>
 /// <returns></returns>
 public bool DeleteData(Renting_Management_System.Models.ImageMod _image)
 {
     image = new Renting_Management_System.Models.ImageMod();
     image = SelectByID(_image.ImageID);
     if (image == null)
     { return false; }
     else
     {
         StringBuilder deleteStr = new StringBuilder();
         deleteStr.Append("Delete From [Image] ");
         deleteStr.Append("Where 影像编号 = '");
         deleteStr.Append(_image.ImageID);
         deleteStr.Append("'");
         da = new DBConnection();
         da.DeleteQuery(deleteStr.ToString());
         return true;
     }
 }
 /// <summary>
 /// 删除一个客户
 /// 返回 true 表示成功,否侧数据不存在
 /// </summary>
 /// <param name="_customer"></param>
 /// <returns></returns>
 public bool DeleteData(Renting_Management_System.Models.CustomerMod _customer)
 {
     customer = new Renting_Management_System.Models.CustomerMod();
     customer = SelectByID(_customer.CustomerID);
     if (customer != null)
     {
         StringBuilder deleteStr = new StringBuilder();
         deleteStr.Append("Delete From [Customer]");
         deleteStr.Append("Where 客户编号 = '");
         deleteStr.Append(_customer.CustomerID);
         deleteStr.Append("'");
         da = new DBConnection();
         da.DeleteQuery(deleteStr.ToString());
         return true;
     }
     else
     { return false; }
 }
 /// <summary>
 /// 删除一个地点
 /// 返回 true 表示成功
 /// 返回 false 表示数据不存在
 /// </summary>
 /// <param name="_local"></param>
 /// <returns></returns>
 public bool DeleteData(Renting_Management_System.Models.LocalMod _local)
 {
     local = new Renting_Management_System.Models.LocalMod();
     local = SelectData(_local.LocalCode);
     if (local != null)
     {
         da = new DBConnection();
         StringBuilder deleteStr = new StringBuilder();
         deleteStr.Append("Delete From [Local] ");
         deleteStr.Append("Where 地点代码 = '");
         deleteStr.Append(_local.LocalCode);
         deleteStr.Append("'");
         da.DeleteQuery(deleteStr.ToString());
         return true;
     }
     else
         return false;
 }
 /// <summary>
 /// 删除一个用户
 /// 返回 true 表示删除成功
 /// 返回 false 表示数据不存在
 /// </summary>
 /// <param name="_userID"></param>
 /// <returns></returns>
 public bool DeleteData(string _userID)
 {
     user = new Renting_Management_System.Models.UserMod();
     user = SelectByID(_userID);
     if (user != null)
     {
         StringBuilder deleteStr = new StringBuilder();
         deleteStr.Append("Delete From [User]");
         deleteStr.Append("Where 用户编号 = '");
         deleteStr.Append(_userID);
         deleteStr.Append("'");
         da = new DBConnection();
         da.DeleteQuery(deleteStr.ToString());
         return true;
     }
     else
     { return false; }
 }
 /// <summary>
 /// 删除一个影类
 /// 返回 true 表示成功;
 /// 返回 false 表示该类不存在
 /// </summary>
 /// <param name="uType"></param>
 /// <returns></returns>
 public bool DeleteData(Renting_Management_System.Models.ImageTypeMod _imageType)
 {
     type = new Renting_Management_System.Models.ImageTypeMod();
     type = SelectData(_imageType.ImageTypeCode);
     if (type != null)
     {
         da = new DBConnection();
         StringBuilder deleteStr = new StringBuilder();
         deleteStr.Append("Delete From [ImageType] ");
         deleteStr.Append("Where 影类代码 = '");
         deleteStr.Append(_imageType.ImageTypeCode);
         deleteStr.Append("'");
         da.DeleteQuery(deleteStr.ToString());
         return true;
     }
     else
         return false;
 }
 /// <summary>
 /// 添加一个地点
 /// 返回 true 表示成功
 /// 返回 false 表示数据已存在
 /// </summary>
 /// <param name="_local"></param>
 /// <returns></returns>
 public bool AddData(Renting_Management_System.Models.LocalMod _local)
 {
     local = new Renting_Management_System.Models.LocalMod();
     local = SelectData(_local.LocalCode);
     if (local == null)
     {
         da = new DBConnection();
         StringBuilder insertStr = new StringBuilder();
         insertStr.Append("Insert Into [Local] (地点代码,地点名称) ");
         insertStr.Append("Values ('");
         insertStr.Append(_local.LocalCode + "','");
         insertStr.Append(_local.LocalName);
         insertStr.Append("')");
         da.InsertQuery(insertStr.ToString());
         return true;
     }
     else
         return false;
 }
 /// <summary>
 /// 添加一个影类
 /// 返回 true 表示成功
 /// 返回 false 表示数据已存在
 /// </summary>
 /// <param name="uType"></param>
 /// <returns></returns>
 public bool AddData(Renting_Management_System.Models.ImageTypeMod _imageType)
 {
     type = new Renting_Management_System.Models.ImageTypeMod();
     type = SelectData(_imageType.ImageTypeCode);
     if (type == null)
     {
         da = new DBConnection();
         StringBuilder insertStr = new StringBuilder();
         insertStr.Append("Insert Into [ImageType] (影类代码,影类名称) ");
         insertStr.Append("Values ('");
         insertStr.Append(_imageType.ImageTypeCode + "','");
         insertStr.Append(_imageType.ImageTypeName);
         insertStr.Append("')");
         da.InsertQuery(insertStr.ToString());
         return true;
     }
     else
         return false;
 }
 /// <summary>
 /// 删除一个租借记录
 /// 返回 true 表示成功,否侧该记录不存在
 /// </summary>
 /// <param name="_rent"></param>
 /// <returns></returns>
 public bool DeletData(Renting_Management_System.Models.RentMod _rent)
 {
     rent = new Renting_Management_System.Models.RentMod();
     rent =SelectBy_CustomerID_N_ImageID(_rent.CustomerID, _rent.ImageID);
     if (rent != null)
     {
         StringBuilder deleteStr = new StringBuilder();
         deleteStr.Append("Delete From [Rent]");
         deleteStr.Append("Where 客户编号 = '");
         deleteStr.Append(_rent.CustomerID);
         deleteStr.Append("' And 影像编号 = '");
         deleteStr.Append(_rent.ImageID);
         deleteStr.Append("'");
         da = new DBConnection();
         da.DeleteQuery(deleteStr.ToString());
         return true;
     }
     else
     {
         return false;
     }
 }
 /// <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="_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>
 /// 获取一个地点
 /// _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>
 /// 修改一个租借的记录
 /// 返回 true 表示成功,否侧该记录不存在
 /// </summary>
 /// <param name="_rent"></param>
 /// <returns></returns>
 public bool ModifyData(Renting_Management_System.Models.RentMod _rent)
 {
     rent = new Renting_Management_System.Models.RentMod();
     rent =SelectBy_CustomerID_N_ImageID(_rent.CustomerID, _rent.ImageID);
     if (rent != null)
     {
         StringBuilder updateStr = new StringBuilder();
         updateStr.Append("Update [Rent]");
         updateStr.Append("Set ");
         updateStr.Append("用户编号 = '");
         updateStr.Append(_rent.UserID);
         updateStr.Append("',出租数量 = ");
         updateStr.Append(_rent.QuantityOfRent);
         updateStr.Append(",出租日期 = '");
         updateStr.Append(_rent.RentDate.ToShortDateString());
         updateStr.Append("',归还日期 = '");
         updateStr.Append(_rent.ReturnDate.ToShortDateString());
         updateStr.Append("',出租押金 = ");
         updateStr.Append(_rent.Deposit);
         updateStr.Append(",归还状态 = '");
         updateStr.Append(_rent.ReturnState);
         updateStr.Append("',描述 = '");
         updateStr.Append(_rent.Description);
         updateStr.Append("'");
         updateStr.Append("Where 客户编号 = '");
         updateStr.Append(_rent.CustomerID);
         updateStr.Append("' And 影像编号 = '");
         updateStr.Append(_rent.ImageID);
         updateStr.Append("'");
         da = new DBConnection();
         da.UpdateQuery(updateStr.ToString());
         return true;
     }
     else
     {
         return false;
     }
 }
 /// <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>
 /// 修改一个地点名称
 /// 返回 true 表示成功
 /// 返回 false 表示数据不存在
 /// </summary>
 /// <param name="_local"></param>
 /// <returns></returns>
 public bool ModifyData(Renting_Management_System.Models.LocalMod _local)
 {
     local = new Renting_Management_System.Models.LocalMod();
     local = SelectData(_local.LocalCode);
     if (local != null)
     {
         da = new DBConnection();
         StringBuilder modifyStr = new StringBuilder();
         modifyStr.Append("Update [Local]");
         modifyStr.Append("Set 地点名称 = '");
         modifyStr.Append(_local.LocalName);
         modifyStr.Append("'");
         modifyStr.Append("Where 地点代码 = '");
         modifyStr.Append(_local.LocalCode);
         modifyStr.Append("'");
         da.UpdateQuery(modifyStr.ToString());
         return true;
     }
     else
         return false;
 }
 /// <summary>
 /// 修改一个影像的记录
 /// 返回 true 表示成功,否侧数据不存在
 /// </summary>
 /// <param name="_image"></param>
 /// <returns></returns>
 public bool ModifyData(Renting_Management_System.Models.ImageMod _image)
 {
     image = new Renting_Management_System.Models.ImageMod();
     image = SelectByID(_image.ImageID);
     if (image == null)
     { return false; }
     else
     {
         StringBuilder updateStr = new StringBuilder();
         updateStr.Append("Update [Image] ");
         updateStr.Append("Set ");
         updateStr.Append("影像名称 = '");
         updateStr.Append(_image.ImageName);
         updateStr.Append("',用户编号 = '");
         updateStr.Append(_image.UserID);
         updateStr.Append("',影类代码 = '");
         updateStr.Append(_image.ImageTypeCode);
         updateStr.Append("',地点代码 = '");
         updateStr.Append(_image.LocalCode);
         updateStr.Append("',影像原价 = ");
         updateStr.Append(_image.ImageCostPrice);
         updateStr.Append(",影像租价 = ");
         updateStr.Append(_image.ImageRentalPrice);
         updateStr.Append(",库存数量 = ");
         updateStr.Append(_image.StorageQuantity);
         updateStr.Append(",货架号 = '");
         updateStr.Append(_image.ShelvesNumber);
         updateStr.Append("',出租状态 = '");
         updateStr.Append(_image.RentState);
         updateStr.Append("',影像描述 = '");
         updateStr.Append(_image.ImageDescription);
         updateStr.Append("'");
         updateStr.Append("Where 影像编号 = '");
         updateStr.Append(_image.ImageID);
         updateStr.Append("'");
         da = new DBConnection();
         da.UpdateQuery(updateStr.ToString());
         return true;
     }
 }
 /// <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="_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>
 /// 获取所有租借记录,整个表的数据集
 /// 返回一个数据集
 /// </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>
 /// 获取一个影像类
 /// </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;
     }
 }
 public void Update(DataSet ds)
 {
     da = new Renting_Management_System.DAL.DBConnection();
     da.Refresh(ds);
 }
 /// <summary>
 /// 修改一个客户的记录
 /// 返回 true 表示成功,否侧表示数据不存在
 /// </summary>
 /// <param name="_customer"></param>
 /// <returns></returns>
 public bool ModifyData(Renting_Management_System.Models.CustomerMod _customer)
 {
     customer = new Renting_Management_System.Models.CustomerMod();
     customer = SelectByID(_customer.CustomerID);
     if (customer != null)
     {
         StringBuilder updateStr = new StringBuilder();
         updateStr.Append("Update [Customer] ");
         updateStr.Append("Set ");
         updateStr.Append("客户类代码 = '");
         updateStr.Append(_customer.CustomerTypeCode + "'");
         updateStr.Append(",客户名称 = '");
         updateStr.Append(_customer.CustomerName + "'");
         updateStr.Append(",性别 = '");
         updateStr.Append(_customer.Sex + "'");
         updateStr.Append(",出生日期 = '");
         updateStr.Append(_customer.BirthDate.ToShortDateString());
         updateStr.Append("',证件类代码 = '");
         updateStr.Append(_customer.CertificateTypeCode + "'");
         updateStr.Append(",证件号码 = '");
         updateStr.Append(_customer.CertificateNumber + "'");
         updateStr.Append(",客户地址 = '");
         updateStr.Append(_customer.CustomerAddress + "'");
         updateStr.Append(",联系方式 = '");
         updateStr.Append(_customer.CustomerContact + "'");
         updateStr.Append(",客户状态 = '");
         updateStr.Append(_customer.CustomerState + "'");
         updateStr.Append(",客户描述 = '");
         updateStr.Append(_customer.CustomerDescription + "'");
         updateStr.Append(",客户拒绝 = '");
         updateStr.Append(_customer.CustomerDeny.ToString() + "'");
         updateStr.Append("Where 客户编号 = '");
         updateStr.Append(_customer.CustomerID + "'");
         da = new DBConnection();
         da.UpdateQuery(updateStr.ToString());
         return true;
     }
     else
     { return false; }
 }
 /// <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>
 /// 修改一个影类名称
 /// 返回 true 表示成功
 /// 返回 false 表示该类不存在
 /// </summary>
 /// <param name="uType"></param>
 /// <returns></returns>
 public bool ModifyData(Renting_Management_System.Models.ImageTypeMod _imageType)
 {
     type = new Renting_Management_System.Models.ImageTypeMod();
     type = SelectData(_imageType.ImageTypeCode);
     if (type != null)
     {
         da = new DBConnection();
         StringBuilder modifyStr = new StringBuilder();
         modifyStr.Append("Update [ImageType] ");
         modifyStr.Append("Set 影类名称 = '");
         modifyStr.Append(_imageType.ImageTypeName + "'");
         modifyStr.Append("Where 影类代码 = '");
         modifyStr.Append(_imageType.ImageTypeCode + "'");
         da.UpdateQuery(modifyStr.ToString());
         return true;
     }
     else
         return false;
 }
 /// <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;
     }
 }