Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7.  
  8. namespace MSWP
  9. {
  10.     class DBAccess
  11.     {
  12.         SqlConnection conn;
  13.  
  14.         public DBAccess()
  15.         {
  16.             conn = ConnectionManager.GetConnection();
  17.         }
  18.  
  19.         public bool setSubsInfo(int MemID, int year, int amount, string date)
  20.         {
  21.             bool status = false;
  22.  
  23.  
  24.  
  25.             conn.Open();
  26.  
  27.  
  28.             SqlCommand newCmd = conn.CreateCommand();
  29.  
  30.             newCmd.Connection = conn;
  31.             newCmd.CommandType = CommandType.Text;
  32.  
  33.             newCmd.CommandText = "Insert into MemberSubscription values( " + MemID + "," + year + "," + amount + ",'" + date + "')";
  34.             newCmd.ExecuteNonQuery();
  35.  
  36.             status = true;
  37.  
  38.             conn.Close();
  39.  
  40.             return status;
  41.  
  42.         }
  43.  
  44.         public DataSet FillperInfoS1(int memID, string memName, string busName)
  45.         {
  46.             conn.Open();
  47.  
  48.  
  49.             SqlCommand newCmd2 = conn.CreateCommand();
  50.             newCmd2.Connection = conn;
  51.             newCmd2.CommandType = CommandType.Text;
  52.             newCmd2.CommandText = "select MemberID,NIC, FName, MName, LName, Address, Gender, SpouseName, Telephone_Home, Mobile, Marital_Status, DOB, DOM" +
  53.             "from dbo.personalinfo  where MemberID=" + memID + " OR LName LIKE'%" + memName + "%' OR Bname=' " + busName + "'";
  54.  
  55.             SqlDataAdapter da = new SqlDataAdapter(newCmd2);
  56.             DataSet ds = new DataSet();
  57.             da.Fill(ds, "personalinfo");
  58.             conn.Close();
  59.  
  60.             return ds;
  61.  
  62.         }
  63.  
  64.         public DataSet FillBusInfoS1(int memID, string memName, string busName)
  65.         {
  66.             conn.Open();
  67.  
  68.  
  69.             SqlCommand newCmd3 = conn.CreateCommand();
  70.             newCmd3.Connection = conn;
  71.             newCmd3.CommandType = CommandType.Text;
  72.             newCmd3.CommandText = "select MemberID,BusRegno,Bname,ownership,Postal_no,Street_1,Street_2,Street_3,City_town, floor,bus_category, incometaxNo,VATno, ETF, EPF, StartDate,NoofEmp" +
  73.             "from dbo.businessinfo  where MemberID=" + memID + " OR LName LIKE'%" + memName + "%' OR Bname=' " + busName + "'";
  74.             SqlDataAdapter da = new SqlDataAdapter(newCmd3);
  75.             DataSet ds = new DataSet();
  76.             da.Fill(ds, "businessinfo");
  77.             conn.Close();
  78.  
  79.             return ds;
  80.  
  81.         }
  82.  
  83.  
  84.         public DataSet FillBusInfoS2(string busCat, string st1, string st2, string st3, string city, string dateB, string monthB, string yearB, string yearM, string monthM, string dateM)
  85.         {
  86.             conn.Open();
  87.  
  88.  
  89.             SqlCommand newCmd4 = conn.CreateCommand();
  90.             newCmd4.Connection = conn;
  91.             newCmd4.CommandType = CommandType.Text;
  92.             newCmd4.CommandText = "select MemberID,BusRegno,Bname,ownership,Postal_no,Street_1,Street_2,Street_3,City_town, floor,bus_category, incometaxNo,VATno, ETF, EPF, StartDate,NoofEmp" +
  93.             "from dbo.businessinfo  where bus_category='" + busCat + "' or street1_1='" + st1 + "' or street_2='" + st2 + "' or street_3='" + st3 + "' or city_town='" + city +
  94.             "' or DOB='" + dateB + monthB + yearB + "' or DOM='" + dateM + monthM + yearM + "'";
  95.             SqlDataAdapter da = new SqlDataAdapter(newCmd4);
  96.             DataSet ds = new DataSet();
  97.             da.Fill(ds, "businessinfo");
  98.             conn.Close();
  99.  
  100.             return ds;
  101.  
  102.         }
  103.  
  104.         public DataSet FillperInfoS2(string busCat, string st1, string st2, string st3, string city, string dateB, string monthB, string yearB, string yearM, string monthM, string dateM)
  105.         {
  106.             conn.Open();
  107.  
  108.  
  109.             SqlCommand newCmd5 = conn.CreateCommand();
  110.             newCmd5.Connection = conn;
  111.             newCmd5.CommandType = CommandType.Text;
  112.             newCmd5.CommandText = "select MemberID,NIC, FName, MName, LName, Address, Gender, SpouseName, Telephone_Home, Mobile, Marital_Status, DOB, DOM" +
  113.             "from dbo.personalinfo where bus_category='" + busCat + "' or street1_1='" + st1 + "' or street_2='" + st2 + "' or street_3='" + st3 + "' or city_town='" + city +
  114.             "' or DOB='" + dateB + monthB + yearB + "' or DOM='" + dateM + monthM + yearM + "'";
  115.             SqlDataAdapter da = new SqlDataAdapter(newCmd5);
  116.             DataSet ds = new DataSet();
  117.             da.Fill(ds, "personalinfo");
  118.             conn.Close();
  119.  
  120.             return ds;
  121.  
  122.         }
  123.  
  124.  
  125.  
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement