public static List <Account> GetAccountLog() { List <Account> accountLogList = new List <Account>(); string conStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; SqlConnection conn = new SqlConnection(conStr); try { DataTable dt = new DataTable(); string query = "SELECT STARTING_BALANCE,ENTRY_DATE,INCOME_AMOUNT,EXPENSE_AMOUNT,DESCRIPTION,CLOSING_BALANCE FROM MasterDB.dbo.ACCOUNTLOG_ENTRY"; SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); conn.Close(); da.Dispose(); //(erow.SNO == null) ? string.Empty : erow.SNO.ToString() foreach (DataRow row in dt.Rows) { var obj = new Account() { StartingBalance = (int)HandleNulls.CheckNullInt(row["STARTING_BALANCE"]), EntryDate = (DateTime)row["ENTRY_DATE"], //OutstandingAmt = (int)row["OUTSTANDING_AMOUNT"], AmountGiven = (int)HandleNulls.CheckNullInt(row["EXPENSE_AMOUNT"]), Description = (string)HandleNulls.CheckNullString(row["DESCRIPTION"]), CollectionAmt = (int)HandleNulls.CheckNullInt(row["INCOME_AMOUNT"]), ClosingBalance = (int)HandleNulls.CheckNullInt(row["CLOSING_BALANCE"]), }; accountLogList.Add(obj); } } catch (DbException dbException) { MessageBox.Show("Error!! DB Exception GetAccountLog"); ExceptionHandler.HandleException(dbException); } catch (Exception exception) { MessageBox.Show("Error!! General Exception GetAccountLog"); ExceptionHandler.HandleException(exception); } finally { conn.Close(); } return(accountLogList); }
public static List <User> GetUserList() { List <User> Employee = new List <User>(); string conStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; SqlConnection conn = new SqlConnection(conStr); try { DataTable dt = new DataTable(); string query = "select ID,UserName,Address,Mobile,InitialAmount,DateOfJoining,DueDate,CurrentAmount from [MasterDB].[dbo].[USER_MAINTENANCE]"; SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); conn.Close(); da.Dispose(); foreach (DataRow row in dt.Rows) { var obj = new User() { ID = (string)HandleNulls.CheckNullString(row["ID"]), UserName = (string)HandleNulls.CheckNullString(row["UserName"]), Address = (string)HandleNulls.CheckNullString(row["Address"]), Mobile = (string)HandleNulls.CheckNullString(row["Mobile"]), InitialAmt = (int)HandleNulls.CheckNullInt(row["InitialAmount"]), DateOfJoining = (DateTime)row["DateOfJoining"], DueDate = (DateTime)row["DueDate"], CurrentAmt = (int)HandleNulls.CheckNullInt(row["CurrentAmount"]), }; Employee.Add(obj); } } catch (DbException dbException) { MessageBox.Show("Error!! DB Exception GetUserList"); ExceptionHandler.HandleException(dbException); } catch (Exception exception) { MessageBox.Show("Error!! General Exception GetUserList"); ExceptionHandler.HandleException(exception); } finally { conn.Close(); } return(Employee); }
public static List <Master> GetMasterLog() { string conStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; SqlConnection conn = new SqlConnection(conStr); List <Master> masterLogList = new List <Master>(); try { DataTable dt = new DataTable(); string query = "SELECT STARTING_BALANCE,ENTRY_DATE,INCOME_AMOUNT,EXPENSE_AMOUNT,DESCRIPTION,CLOSING_BALANCE FROM MasterDB.dbo.MASTERLOG_ENTRY"; SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); conn.Close(); da.Dispose(); foreach (DataRow row in dt.Rows) { var obj = new Master() { OpeningBalance = (int)HandleNulls.CheckNullInt(row["STARTING_BALANCE"]), EntryDate = (DateTime)HandleNulls.CheckNullDateTime(row["ENTRY_DATE"]), Description = (string)HandleNulls.CheckNullString(row["DESCRIPTION"]), IncomeAmount = (int)HandleNulls.CheckNullInt(row["INCOME_AMOUNT"]), ExpenseAmount = (int)HandleNulls.CheckNullInt(row["EXPENSE_AMOUNT"]), ClosingBalance = (int)HandleNulls.CheckNullInt(row["CLOSING_BALANCE"]), }; masterLogList.Add(obj); } } catch (DbException dbException) { MessageBox.Show("Error!! DB Exception GetMasterLog"); ExceptionHandler.HandleException(dbException); } catch (Exception exception) { MessageBox.Show("Error!! General Exception GetMasterLog"); ExceptionHandler.HandleException(exception); } finally { conn.Close(); } return(masterLogList); }
public static List <User> GetUserBasedOnID(string UserID) { string conStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; SqlConnection conn = new SqlConnection(conStr); List <User> selectedUser = new List <User>(); try { DataTable dt = new DataTable(); string getUser = "******"; string query = string.Format(getUser, UserID); SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); conn.Close(); da.Dispose(); foreach (DataRow row in dt.Rows) { var obj = new User() { UserName = (string)HandleNulls.CheckNullString(row["UserName"]), CurrentAmt = (int)HandleNulls.CheckNullInt(row["CurrentAmount"]), }; selectedUser.Add(obj); } } catch (DbException dbException) { MessageBox.Show("Error!! DB Exception GetUserBasedOnID"); ExceptionHandler.HandleException(dbException); } catch (Exception exception) { MessageBox.Show("Error!! General Exception GetUserBasedOnID"); ExceptionHandler.HandleException(exception); } finally { conn.Close(); } return(selectedUser); }