public void Init(SLoanListItem item) { LNum = item.LNum; SLNum = item.SLNum; pay = item.pay; TotalPay = item.TotalPay; date = item.date; }
public SLoanListItem(SLoanListItem item) { Init(item); }
private void LoanListView_ItemClick(object sender, ItemClickEventArgs e) { currItem.Init((LoanListItem)e.ClickedItem); if (currItem == null) { return; } if (currItem.loanNum == null) { return; } if (currItem.loanNum == "LOAN NUMBER") { TxtAlert.Text = "This is the head of table loan."; } else { _data.Clear(); _data.Add(_colHead); string sqlStr = "call showSLoan('" + currItem.loanNum + "');"; MySqlCommand cmd = new MySqlCommand(sqlStr, con); MySqlDataReader reader = null; double totalpay = 0, singlepay = 0, sum = 0; Double.TryParse(currItem.totalPay, out totalpay); try { reader = cmd.ExecuteReader(); SLoanListItem item = new SLoanListItem(); while (reader.Read()) { item.LNum = reader.GetString(0); item.SLNum = reader.GetString(1); item.pay = reader.GetString(2); item.TotalPay = reader.GetString(3); item.date = reader.GetDateTime(4).ToLongDateString(); _data.Add(new SLoanListItem(item)); Double.TryParse(item.TotalPay, out totalpay); Double.TryParse(item.pay, out singlepay); sum += singlepay; } if (Math.Abs(sum - totalpay) < 0.01) { TxtAlert.Text = "Done!"; } else if (Math.Abs(sum - 0) < 0.01) { TxtAlert.Text = "Not start yet!"; } else { TxtAlert.Text = "Loaning..."; } _TxtAlert.Text = "Query success!"; } catch (MySqlException ex) { _TxtAlert.Text = "Fail to execute sql command!\nError message: "; _TxtAlert.Text += ex.Message; } finally { reader.Close(); } TxtLNum.Text = currItem.loanNum; TxtTPay.Text = currItem.totalPay; TxtBName.Text = currItem.BName; TxtCID.Text = currItem.CID; } }