private void insertintocustomerpaymentjobtable() { //last signed in CID = USERID// try { Customerdetails customer = c.GetCustomerRowById(Sign_in.cid); string sql = "INSERT INTO CustomerPaymentJob Values ('" + cid + "','" + LASTJID + "','" + LASTPAYID + "')"; Console.WriteLine(sql); SqlCommand cmd = new SqlCommand(sql, m_con); m_con.Open(); cmd.ExecuteReader(); //MessageBox.Show("Successful"); } catch (Exception ex) { MessageBox.Show("Something went wrong with inserting payment details"); } finally { m_con.Close(); } }
public Customerdetails GetCustomerRowById(String C_Id) { try { string sql = "select * from Customer where C_Id ='" + C_Id + "' "; SqlCommand cmd = new SqlCommand(sql, m_con); m_con.Open(); SqlDataReader dreader = cmd.ExecuteReader(); // We are going to store Customer data in this variable (Customer) Customerdetails cus = new Customerdetails(); if (dreader.Read()) { cus.C_Id = dreader[0].ToString(); cus.C_Type_Id = dreader[1].ToString(); cus.C_Name = dreader[2].ToString(); cus.C_Address = dreader[3].ToString(); cus.C_Email = dreader[4].ToString(); cus.C_Password = dreader[5].ToString(); dreader.Close(); return(cus); } else { return(null); } } catch (Exception ex) { return(null); } finally { m_con.Close(); } }