public bool HasRecord(long CustNo, DateTime PeriodDate) { DbManager db = new DbManager("IRMSConnectionString"); bool bResult = false; db.SelectCommand.CommandText = string.Format(@"select top 1 balance_qty, balance_amt, balance_cost from rptstockcard_new where dateto='{0}' and custno={1} order by id desc",PeriodDate.ToShortDateString(),CustNo); using (IDataReader dbReader = db.ExecuteReader()) { bResult = dbReader.Read(); dbReader.Close(); } return bResult; }
public void Test() { using (DbManager db = new DbManager()) { db.SetCommand("SELECT * FROM Person"); using (IDataReader rd = db./*[a]*/ExecuteReader/*[/a]*/()) { while (rd.Read()) { // ... } } } }
public bool FindPayableListByCustomerCode(string CustomerCode) { bool bResult = false; using (DbManager db = new DbManager()) { try { db.Command.CommandText = string.Format(@"select * from CUSTOMER_PAYABLE_TBL where CUSTCODE = '{0}'", CustomerCode); using (IDataReader dbReader = (IDataReader)db.ExecuteReader()) { CustomerPayableClass commpayable; payableList.Clear(); while (dbReader.Read()) { commpayable = new CustomerPayableClass(); commpayable.CustomerCode = CustomerCode; commpayable.PayableCode = dbReader.GetString(dbReader.GetOrdinal("PAYABLE_CODE")); commpayable.PayableAmount = (float)Convert.ToDecimal(dbReader.GetValue(dbReader.GetOrdinal("PAYABLE_AMOUNT"))); payableList.Add(commpayable); bResult = true; } dbReader.Close(); } } catch (Exception except) { throw new Exception("Error in retrieving payable obligation!"); } } return bResult; }
public bool FindCommissionListByCustomerCode(string CustomerCode) { bool bResult = false; using (DbManager db = new DbManager()) { try { db.Command.CommandText = string.Format(@"select * from CUSTOMER_COMMISSION_TBL where CUSTCODE = '{0}'",CustomerCode); using (IDataReader dbReader = (IDataReader)db.ExecuteReader()) { CustomerCommissionRate commrate; commList.Clear(); while (dbReader.Read()) { commrate = new CustomerCommissionRate(); commrate.CustomerCode = CustomerCode; commrate.FieldType = dbReader.GetString(dbReader.GetOrdinal("FIELD_TYPE")); commrate.FieldValue = (float)Convert.ToDecimal(dbReader.GetValue(dbReader.GetOrdinal("FIELD_VALUE"))); commrate.SalesType = dbReader.GetString(dbReader.GetOrdinal("SALES_TYPE")); commList.Add(commrate); bResult = true; } dbReader.Close(); } } catch (Exception except) { throw new Exception("Error in retrieving commission rates!"); } } return bResult; }