c# - How to resolve Format Exception Error in asp.net? -


i getting error while debugging.

when converting string date time object parse string take date before putting each variable in date time object

can 1 suggest me solution how resolve it?

 protected void btnsubmit_click(object sender, eventargs e)     {         var employeeid = payrollhelper.context.payroll_personaldetails.where(a => a.employee_code == txtemploycode.text).select(a => a.employee_id).first();         var source = payrollhelper.context.payroll_salarydetails.where(a => a.fkemployee_id == convert.toint32(employeeid) && a.salaryofmonth.value.month == convert.todatetime(lbmonth.text).month).select(a => a);          if (source.count() == 0)         {             var count = payrollhelper.context.payroll_advancemanagements.where(a => a.fkemployee_id == employeeid).select(a => a);             if (count.count() != 0)             {                 var salary_ad = payrollhelper.context.payroll_advancemanagements.where(a => a.fkemployee_id == employeeid).select(a => a).first();                 if ((salary_ad.salary_advance > salary_ad.refund_advance) && txtadvancededuction.text != "")                 {                     salary_ad.refund_advance = salary_ad.refund_advance + convert.todecimal(txtadvancededuction.text);                     payrollhelper.context.submitchanges();                     payroll_advancerefundbl obj = new payroll_advancerefundbl(convert.todecimal(txtadvancededuction.text), datetime.now, employeeid);                      if (obj.insert())                     {                      }                 }             }              bool cl = false;             if (viewstate["cl"] != "")             {                 cl = true;             }             payroll_salarydetailbl obj1 = new payroll_salarydetailbl(convert.todecimal(math.round(convert.todecimal(lbpay.text), 2)), convert.tosingle(math.round(convert.todouble(txtgeneralworkingdays.text), 2)), convert.tosingle(math.round(convert.todouble(lbnumberday.text), 2)), convert.todecimal(lbinsentive.text), convert.tostring(math.round(convert.todecimal(lbextrahour.text), 2)), convert.todecimal(math.round(convert.todecimal(lbbenifit.text), 2)), convert.todecimal(math.round(convert.todecimal(txtinvolument.text), 2)), convert.todecimal(math.round(convert.todecimal(lbgross.text), 2)), convert.todecimal(math.round(convert.todecimal(lbbasic.text), 2)), convert.todecimal(math.round(convert.todecimal(lbhra.text), 2)), convert.todecimal(math.round(convert.todecimal(lbcridttotal.text), 2)), convert.todecimal(math.ceiling(convert.todouble(lbnett.text))), convert.todecimal(math.round(convert.todecimal(lbsalaryad.text), 2)), convert.todecimal(math.round(convert.todecimal(txtadvancededuction.text), 2)), convert.todecimal(math.round(convert.todecimal(lbpf.text), 2)), convert.todecimal(math.round(convert.todecimal(lbesi.text), 2)), convert.todecimal(math.round(convert.todecimal(lbdeductiontotal.text), 2)), convert.todatetime(txtsalarydate.text).addmonths(-1), cl, convert.toint32(employeeid));             if (obj1.insert())             {              }         }   } 

what value getting lbmonth.text ?

if getting string january, february,.... need parse datetime.

for replace-

convert.todatetime(lbmonth.text).month 

with

datetime.parseexact(lbmonth.text, "mmmm", cultureinfo.currentculture).month 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -