TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
naga jyothi
NA
62
111k
How to pass date parameter by using MS_Access
Aug 6 2012 11:35 PM
//DAl code
public bool Insert(BOL.bolEmpLoanInstallments obj)
{
dbConnection conn =new dbConnection();
string sql = "insert into EmpLoanInstallments(AppId,EmpId,LoanID,LoanType,NoOfInstallments,Premium,Amountsanctioned,LDate,Status,Paymentthrough,Activationstatus,RemainingAmount,Interest) values(@AppId,@EmpId,@LoanID,@LoanType,@NoOfInstallments,@Premium,@Amountsanctioned,'@Date,'pending',@Paymentthrough,@Activationstatus,@RemainingAmount,@Interest)";
OleDbParameter[] oleDbParameters = new OleDbParameter[12];
oleDbParameters[0] = new OleDbParameter("@AppId", OleDbType.Integer);
oleDbParameters[0].Value = obj.AppId;
oleDbParameters[1] = new OleDbParameter("@EmpId", OleDbType.VarChar);
oleDbParameters[1].Value = obj.EmpId;
//sqlParameters[1] = new SqlParameter("@LoanID", SqlDbType.VarChar);
//sqlParameters[1].Value = obj.LoanID;
oleDbParameters[2] = new OleDbParameter("@NoOfInstallments", OleDbType.Integer);
oleDbParameters[2].Value = obj.NoOfInstallments;
oleDbParameters[3] = new OleDbParameter("@Premium", OleDbType.Decimal);
oleDbParameters[3].Value = obj.Premium;
oleDbParameters[4] = new OleDbParameter("@AmountSanctioned", OleDbType.Decimal);
oleDbParameters[4].Value = obj.AmountSanctioned;
oleDbParameters[5] = new OleDbParameter("# @Date#", OleDbType.Date);
oleDbParameters[5].Value = obj.LDate;
oleDbParameters[6] = new OleDbParameter("@LoanType", OleDbType.VarChar);
oleDbParameters[6].Value = obj.LoanType;
oleDbParameters[7] = new OleDbParameter("@LoanID", OleDbType.VarChar);
oleDbParameters[7].Value = obj.LoanID;
oleDbParameters[8] = new OleDbParameter("@Paymentthrough", OleDbType.VarChar);
oleDbParameters[8].Value = obj.Paymentthrough;
oleDbParameters[9] = new OleDbParameter("@Activationstatus", OleDbType.VarChar);
oleDbParameters[9].Value = obj.Activationstatus;
oleDbParameters[10] = new OleDbParameter("@RemainingAmount", OleDbType.Decimal);
oleDbParameters[10].Value = obj.RemainingAmount;
oleDbParameters[11] = new OleDbParameter("@Interest", OleDbType.VarChar);
oleDbParameters[11].Value = obj.Interest;
return conn.executeInsertQuery(sql, oleDbParameters);
}
//Bol Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PayRoll.BOL
{
class bolEmpLoanInstallments
{
DAL.dalEmpLoanInstallments dalObj= new PayRoll.DAL.dalEmpLoanInstallments();
private Int32 m_Srlno;
private string m_AppId;
private string m_EmpId;
private string m_Loanid;
private string m_Loantype,m_Status;
private string m_NoOfInstallments;
private Decimal m_Premium;
private Decimal m_Amountsanctioned;
private DateTime m_date;
private string m_Paymentthrough;
private string m_Activationstatus;
private Decimal m_RemainingAmount;
private string m_Interest;
/// <constructor>
/// Constructor bolEmpLoanInstallments
/// </constructor>
public bolEmpLoanInstallments()
{
//Initialize the variable here
}
/// <summary>
/// ColumnName:Srlno
/// Data Type:int
/// Length:0
/// </summary>
public Int32 Srlno
{
get
{
return m_Srlno;
}
set
{
m_Srlno = value;
}
}
/// <summary>
/// ColumnName:Empid
/// Data Type:VarChar
/// Length:20
/// </summary>
public string AppId
{
get
{
return m_AppId;
}
set
{
m_AppId = value;
}
}
public string EmpId
{
get
{
return m_EmpId;
}
set
{
if (value == "")
{
throw new InvalidData("Please select Employee Id", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (value.Length > 20)
{
throw new InvalidData("The Empid is more length", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
m_EmpId = value;
}
}
/// <summary>
/// ColumnName:Loanid
/// Data Type:VarChar
/// Length:50
/// </summary>
public string LoanID
{
get
{
return m_Loanid;
}
set
{
if (value== "")
{
throw new InvalidData("Please Select Loan ID", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (value.Length > 50)
{
throw new InvalidData("The Loanid is more length", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
m_Loanid = value;
}
}
/// <summary>
/// ColumnName:Loantype
/// Data Type:VarChar
/// Length:50
/// </summary>
public string LoanType
{
get
{
return m_Loantype;
}
set
{
if (value == "")
{
throw new InvalidData("Please select Loan type", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (value.Length > 50)
{
throw new InvalidData("The Loantype is more length", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
m_Loantype = value;
}
}
/// <summary>
/// ColumnName:Installmentamountpermonth
/// Data Type:decimal
/// Length:0
/// </summary>
public string NoOfInstallments
{
get
{
return m_NoOfInstallments;
}
set
{
m_NoOfInstallments = value;
}
}
public string Interest
{
get
{
return m_Interest;
}
set
{
if (value == "")
{
throw new InvalidData("Please Enter Interest", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
m_Interest = value;
}
}
/// <summary>
/// ColumnName:Amountsanctioned
/// Data Type:decimal
/// Length:0
/// </summary>
public Decimal AmountSanctioned
{
get
{
return m_Amountsanctioned;
}
set
{
//if (value == 0)
//{
// throw new InvalidData("Please enter the amount");
//}
m_Amountsanctioned = value;
}
}
public Decimal RemainingAmount
{
get
{
return m_RemainingAmount;
}
set
{
m_RemainingAmount = value;
}
}
/// <summary>
/// ColumnName:Approveddate
/// Data Type:datetime
/// Length:0
/// </summary>
public Decimal Premium
{
get
{
return m_Premium;
}
set
{
m_Premium = value;
}
}
/// <summary>
/// ColumnName:Paiddate
/// Data Type:datetime
/// Length:0
/// </summary>
public DateTime LDate
{
get
{
return m_date;
}
set
{
m_date = value;
}
}
public string Status
{
get
{
return m_Status;
}
set
{
if (value.Length == 0)
{
throw new InvalidData("Please select Loan Status", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (value.Length > 50)
{
throw new InvalidData("The LoanStatus is more length", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
m_Status = value;
}
}
public string Paymentthrough
{
get
{
return m_Paymentthrough;
}
set
{
if (value == "")
{
throw new InvalidData("Please enter payment through", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
m_Paymentthrough = value;
}
}
public string Activationstatus
{
get
{
return m_Activationstatus;
}
set
{
m_Activationstatus = value;
}
}
public bool Insert ()
{
dalObj.Insert(this);
return true;
}
public bool Update()
{
dalObj.Update(this);
return true;
}
public bool Update1()
{
dalObj.Update1(this);
return true;
}
}
}
//Presentation layer code
BOL.bolEmpLoanInstallments obj = new PayRoll.BOL.bolEmpLoanInstallments();
String Sql = ""+cmbempid.Text+"";
String[] Empid =Sql.Split('(');
obj.AppId = txtloanappId.Text;
obj.EmpId = Empid[0].ToString();
// obj.LoanType = cmbloanidapplication.Text;
//obj.LoanID = txtLoanID.Text;
obj.LoanID = LnId;
obj.LoanType = LType;
//obj.LoanID = LnId;
obj.AmountSanctioned = Convert.ToDecimal(txtamount.Text);
obj.Premium = Convert.ToDecimal(txtpremiumamount.Text);
obj.NoOfInstallments = Convert.ToString(nudinstallments.Value);
obj.Interest = Convert.ToString(nudinterest.Value);
obj.LDate = Convert.ToDateTime(dtpdate.Value);
obj.Paymentthrough = cmbPaymentthrough.Text;
obj.Activationstatus = "0";
obj.RemainingAmount = Convert.ToDecimal(txtamount.Text);
obj.Insert();
MessageBox.Show("Record Saved sucessfully", "Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information );
clear();
txtloanappId.Text = dbConnection.GetNextNumber("EmpLoanInstallments", "AppId").ToString();
my problem is not insert the data into database because exception occur in date format so please rectify the error
Reply
Answers (
0
)
Range of Double
Inherit a c# class in vb.net