here is my error

even i tried: dtp_ngaycap.Value it still confirms me that error.
here is the code of CNcommands class
public bool CNcommands(string commandType,string tenchunha,string nguoidaidien, string chucvu, int soCMDN, DateTime ngaycap, string diachi, string masothue, string nguoithuhuong, string sotaikhoan,string nganhang,string sodienthoai, string diachiemail, string diachinganhang, int maCN)
{
if (commandType == "insert")
{
string insertCN = "INSERT INTO [QLThueNha].[dbo].[ChuNha][MaChuNha],[TenChuNha],[Nguoidaidien],[Chucvu],[SoCMND],[Ngaycap],[Diachi],[Masothue],[Nguoithuhuong],[Sotaikhoan],[Nganhang],[Sodienthoai],[DiachimailCN],[Diachinganhang])VALUES('" + tenchunha + "','" + nguoidaidien + "','" + chucvu + "','" + soCMDN + "','" + ngaycap + "','" + diachi + "','" + masothue + "','" + nguoithuhuong + "','" + sotaikhoan + "','" + nganhang + "','" + sodienthoai + "','" + diachiemail + "','" + diachinganhang + "')";
if (executeQuery(insertCN, ref rowAffect_) == true && rowAffect_ == 1)
{
return true;
}
return true;
}
else if (commandType == "update")
{
string updateCN = "UPDATE [QLThueNha].[dbo].[ChuNha] SET [TenChuNha] = '" + tenchunha + "',[Nguoidaidien] = '" + nguoidaidien + "',[Chucvu] = '" + chucvu + "',[SoCMND] = '" + soCMDN + "',[Ngaycap] = '" + ngaycap + "',[Diachi] = '" + diachi + "',[Masothue] = '" + masothue + "',[Nguoithuhuong] = '" + nguoithuhuong + "',[Sotaikhoan] = '" + sotaikhoan + "',[Nganhang] = '" + nganhang + "',[Sodienthoai] = '" + sodienthoai + "',[DiachimailCN] = '" + diachiemail + "',[Diachinganhang] = '" + diachinganhang + "' WHERE <Search Conditions,,>";
if (executeQuery(updateCN, ref rowAffect_) == true && rowAffect_ == 1)
{
return true;
}
return true;
}
else
{
return false;
}
//if (commandType == "delete")
//{
// string deleteCN = "SET [TenChuNha] = '" + tenchunha + "',[Nguoidaidien] = '" + nguoidaidien + "',[Chucvu] = '" + chucvu + "',[SoCMND] = '" + soCMDN + "',[Ngaycap] = '" + ngaycap + "',[Diachi] = '" + diachi + "',[Masothue] = '" + masothue + "',[Nguoithuhuong] = '" + nguoithuhuong + "',[Sotaikhoan] = '" + sotaikhoan + "',[Nganhang] = '" + nganhang + "',[Sodienthoai] = '" + sodienthoai + "',[DiachimailCN] = '" + diachiemail + "',[Diachinganhang] = '" + diachinganhang + "' WHERE <Search Conditions,,>";
// if (executeQuery(deleteCN, ref rowAffect_) == true && rowAffect_ == 1)
// {
// return true;
// }
//}
}
FormatExceptionis thrown because of the last parameter you pass to theCNcommandsmethod:Check also the
Convert.ToDateTime("");//note if you are usingDateTimePickerthen no need to parse toConvert.ToDateTimebecause thedateTimePicker.ValueisDateTime.And also check
int.Parse(txt_sosmdn.Text)However you should also consider re-factoring your method.