Book_Return_form
Book_tag_id=textbox1
Member_id=textbox2
Book_return_on=textbox3
Book_due_date=textbox4
Fine=textbox5
In this form when I put book-tag_id the rest items come automatically a/c to database and I hv done all till textbox4(book_due_date).
Now problem is with fine(textbox5)
Fine is calculated acc to membership_type,there are three types of membership silver,gold,platinum
Fines are:silver=30,gold=20,platinum=30 so the calculated fine a/c membership come on text box

As (return_date-due_date)-30,20or10 ,till now I m working with dataadapter but now I want to work with dll class,I make a dll class and know how to add reference to project but I m missing smthing in my code while I m making class.(so help me in code)
I made a stored procedure with name(member_details)colums:tag_id,member_id,membership_type_id,membership_type(eg:909,5,1,silver)
My full code for dll class is:
Firstly,I make class name transcation_details

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace selectfinedetails
{
    public class TransactionService
    {

        SqlConnection cs;
       

        private void OpenConnection()
        {

            cs = new SqlConnection();
            cs.ConnectionString = "Data Source=IRIS-CSG-174;Initial Catalog=library_system;Integrated Security=True";

            cs.Open();
  
        }
        public membership_details calculatefine()
        {
            OpenConnection();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Exec member_fine_detail";
          SqlParameter prm1=new SqlParameter("member_id", SqlDbType.Int);
            cmd.Parameters.Add(prm1);
         
            SqlParameter prm2=new SqlParameter("fine_per_day", SqlDbType.Int);
            cmd.Parameters.Add(prm2);
            prm1.Direction=ParameterDirection.Output;
            prm2.Direction=ParameterDirection.ReturnValue;
        
             membership_details myObjec = new membership_details();
            cmd.ExecuteNonQuery();
             SqlDataReader sdr = cmd.ExecuteReader();
             myObjec.fine_per_day = //cmd.CommandText;(this is error)
             
            return myObjec;

but I this above code I m missing smthing,as this code will result nthing as to calculate fine with member_id…so what code I will add in it and in as calculatefine()

Dim myCommand As New SqlCommand("connectionstring", myConnection)

myCommand.CommandType = CommandType.StoredProcedure
Dim paraProjectName As New SqlParameter("@ProjectName", SqlDbType.NVarChar, 50)
paraProjectName.Value = CmbProjectName.SelectedItem.Value
myCommand.Parameters.Add(paraProjectName)

Try
' Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
TimeId = paramID.Value
Catch
' failed to create a new user
TimeId = 0

Finally

' Close the Connection
If myConnection.State = ConnectionState.Open Then
myConnection.Close()
End If

End Try

Book_Return_form
Book_tag_id=textbox1
Member_id=textbox2
Book_return_on=textbox3
Book_due_date=textbox4
Fine=textbox5
In this form when I put book-tag_id the rest items come automatically a/c to database and I hv done all till textbox4(book_due_date).
Now problem is with fine(textbox5)
Fine is calculated acc to membership_type,there are three types of membership silver,gold,platinum
Fines are:silver=30,gold=20,platinum=30 so the calculated fine a/c membership come on text box

As (return_date-due_date)-30,20or10 ,till now I m working with dataadapter but now I want to work with dll class,I make a dll class and know how to add reference to project but I m missing smthing in my code while I m making class.(so help me in code)
I made a stored procedure with name(member_details)colums:tag_id,member_id,membership_type_id,membership_type(eg:909,5,1,silver)
My full code for dll class is:
Firstly,I make class name transcation_details

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace selectfinedetails
{
    public class TransactionService
    {

        SqlConnection cs;
       

        private void OpenConnection()
        {

            cs = new SqlConnection();
            cs.ConnectionString = "Data Source=IRIS-CSG-174;Initial Catalog=library_system;Integrated Security=True";

            cs.Open();
  
        }
        public membership_details calculatefine()
        {
            OpenConnection();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Exec member_fine_detail";
          SqlParameter prm1=new SqlParameter("member_id", SqlDbType.Int);
            cmd.Parameters.Add(prm1);
         
            SqlParameter prm2=new SqlParameter("fine_per_day", SqlDbType.Int);
            cmd.Parameters.Add(prm2);
            prm1.Direction=ParameterDirection.Output;
            prm2.Direction=ParameterDirection.ReturnValue;
        
             membership_details myObjec = new membership_details();
            cmd.ExecuteNonQuery();
             SqlDataReader sdr = cmd.ExecuteReader();
             myObjec.fine_per_day = //cmd.CommandText;(this is error)
             
            return myObjec;

but I this above code I m missing smthing,as this code will result nthing as to calculate fine with member_id…so what code I will add in it and in as calculatefine()

Try below code
Dim myCommand As New SqlCommand("connectionstring", myConnection)

myCommand.CommandType = CommandType.StoredProcedure
Dim paraProjectName As New SqlParameter("@ProjectName", SqlDbType.NVarChar, 50)
paraProjectName.Value = CmbProjectName.SelectedItem.Value
myCommand.Parameters.Add(paraProjectName)

Try
' Open the connection and execute the Command
myConnection.Open()
myCommand.ExecuteNonQuery()
TimeId = paramID.Value
Catch
' failed to create a new user
TimeId = 0

Finally

' Close the Connection
If myConnection.State = ConnectionState.Open Then
myConnection.Close()
End If

End Try

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.