public List<CreateBookBorrow> SearchBookDate(SearchBookStatistics BookStatisticsData) { List<CreateBookBorrow> returnValue = new List<CreateBookBorrow>(); DataBase Base = new DataBase(); string ConditionReturn = this.SearchBookStatisticsConditionReturn(BookStatisticsData); using (SqlConnection Sqlconn = new SqlConnection(Base.GetConnString())) { try { StaffDataBase sDB = new StaffDataBase(); List<string> CreateFileName = sDB.getStaffDataName(HttpContext.Current.User.Identity.Name); Sqlconn.Open(); string sql = "SELECT COUNT(*) FROM BookManage WHERE isDeleted=0 AND BorrowerIdentity=1 " + ConditionReturn; SqlCommand cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@txtbookDateStartDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateStartDate); cmd.Parameters.Add("@txtbookDateEndDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateEndDate); CreateBookBorrow addValue = new CreateBookBorrow(); addValue.staffBorrowBookSum = cmd.ExecuteScalar().ToString(); sql = "SELECT COUNT(DISTINCT BorrowerID) FROM BookManage WHERE isDeleted=0 AND BorrowerIdentity=1 " + ConditionReturn; cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@txtbookDateStartDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateStartDate); cmd.Parameters.Add("@txtbookDateEndDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateEndDate); addValue.staffBorrowerSum = cmd.ExecuteScalar().ToString(); sql = "SELECT COUNT(*) FROM BookManage WHERE isDeleted=0 AND BorrowerIdentity=2 " + ConditionReturn; cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@txtbookDateStartDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateStartDate); cmd.Parameters.Add("@txtbookDateEndDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateEndDate); addValue.studentBorrowBookSum = cmd.ExecuteScalar().ToString(); sql = "SELECT COUNT(DISTINCT BorrowerID) FROM BookManage WHERE isDeleted=0 AND BorrowerIdentity=2 " + ConditionReturn; cmd = new SqlCommand(sql, Sqlconn); cmd.Parameters.Add("@txtbookDateStartDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateStartDate); cmd.Parameters.Add("@txtbookDateEndDate", SqlDbType.Date).Value = Chk.CheckStringtoDateFunction(BookStatisticsData.txtbookDateEndDate); addValue.studentBorrowerSum = cmd.ExecuteScalar().ToString(); addValue.bookBorrowStartDate = DateTime.Parse(BookStatisticsData.txtbookDateStartDate).ToString("yyyy-MM-dd"); addValue.bookBorrowEndDate = DateTime.Parse(BookStatisticsData.txtbookDateEndDate).ToString("yyyy-MM-dd"); addValue.checkNo = "1"; returnValue.Add(addValue); Sqlconn.Close(); } catch (Exception e) { CreateBookBorrow addValue = new CreateBookBorrow(); addValue.checkNo = "-1"; addValue.errorMsg = e.Message.ToString(); returnValue.Add(addValue); } } return returnValue; }
public List<CreateBookBorrow> searchBookDateData(SearchBookStatistics BookStatisticsData) { AdministrationDataBase aDB = new AdministrationDataBase(); aDB.libraryFunction(); List<CreateBookBorrow> returnValue = new List<CreateBookBorrow>(); if (int.Parse(aDB._StaffhaveRoles[3]) == 1) { returnValue = aDB.SearchBookDate(BookStatisticsData); } else { CreateBookBorrow addValue=new CreateBookBorrow(); addValue.checkNo = _noRole; addValue.errorMsg = _errorMsg; returnValue.Add(addValue); } return returnValue; }