private void BindBorrowListDataGrid(List<QueryElement> list)
        {
            BorrowORLoanCollection coll = BorrowedMethods.GetBorrowList(list);
            this.BorrowListDataGrid.DataSource = coll;
            this.BorrowListDataGrid.DataBind();
            for (int i = 0; i < coll.Count; i++)
            {
                CardInfo cardInfo = CardMethods.GetCardById(coll[i].BorrowORLoanAccountId);
                string bank = StaticRescourse.DisplayBank(cardInfo.BankId);
                this.BorrowListDataGrid.Items[i].Cells[4].Text = coll[i].BorrowedAccount + " " + bank;

                this.BorrowListDataGrid.Items[i].Cells[8].Text = coll[i].HappenedDate.ToString("yyyy-MM-dd");
                this.BorrowListDataGrid.Items[i].Cells[2].Text = StaticRescourse.DisplayBorrowORLoanType(coll[i].BorrowORLoanType);
                bool dateFlag = HelperCommon.CompareAccordToRequired(coll[i].ReturnDate);
                if (dateFlag)
                {
                    this.BorrowListDataGrid.Items[i].Cells[9].Text = coll[i].ReturnDate.ToString("yyyy-MM-dd");
                }
                else
                {
                    this.BorrowListDataGrid.Items[i].Cells[9].Text = string.Empty;
                }
                if (coll[i].Status == 2)
                {
                    this.BorrowListDataGrid.Items[i].Cells[10].Text = "已还";
                }
                else
                {
                    this.BorrowListDataGrid.Items[i].Cells[10].Text = "未还";
                }
            }
        }
Beispiel #2
0
        public static BorrowORLoanCollection GetBorrowList(List <QueryElement> list)
        {
            BorrowORLoanCollection coll = new BorrowORLoanCollection();
            StringBuilder          sb   = new StringBuilder();

            sb.Append(" select * from borrowing where BorrowORLoan=1");
            if (list.Count > 0)
            {
                MySqlParameter[] pars = new MySqlParameter[list.Count];
                for (int i = 0; i < list.Count; i++)
                {
                    QueryElement query = list[i];

                    if (query.QueryElementType == MySqlDbType.DateTime)
                    {
                        sb.AppendFormat(" {0} {1} {2} @{3} ", query.QueryLogic, query.Queryname, query.QueryOperation, query.Queryname + i);
                        pars[i] = new MySqlParameter("@" + query.Queryname + i, query.QueryElementType);
                    }
                    else
                    {
                        sb.AppendFormat(" {0} {1} {2} @{3} ", query.QueryLogic, query.Queryname, query.QueryOperation, query.Queryname);
                        pars[i] = new MySqlParameter("@" + query.Queryname, query.QueryElementType);
                    }
                    if (query.QueryOperation.Equals("like"))
                    {
                        pars[i].Value = "%" + query.Queryvalue + "%";
                    }
                    else
                    {
                        pars[i].Value = query.Queryvalue;
                    }
                }
                using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString(), pars))
                {
                    while (reader.Read())
                    {
                        coll.Add(new BorrowORLoanInfo(reader));
                    }
                }
            }
            else
            {
                using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString()))
                {
                    while (reader.Read())
                    {
                        coll.Add(new BorrowORLoanInfo(reader));
                    }
                }
            }
            return(coll);
        }