DateTime? LastSentEmailDate = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.SentDateTime).FirstOrDefault();
if (LastSentEmailDate != null)
{
DateTime CurrentDate = DateTime.Now;
var diffTimes = Convert.ToInt32((TimeSpan)(CurrentDate - LastSentEmailDate)); //difference as time you can use as miliseconds interval.TotalMilliSeconds ---Error Occurs here
int diffSentCount = 0;
int? diffMaxCount = 0;
diffSentCount = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.Count).FirstOrDefault();
diffMaxCount = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.MaxCount).FirstOrDefault();
int? difftotalcount = diffMaxCount - diffSentCount;
if (diffTimes <= 3600000 && difftotalcount > 0)
{
//Just sends mails
}
else
{
ShowAlert("You Reach maximum limit of sending mail.please try after some time", this);
}
}
else
{
db.ExecuteCommand(@"UPDATE [dbo].[tbl_From_master] SET [SentDateTime] = '" + DateTime.MinValue + "' WHERE [Id]='" + db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.Id).FirstOrDefault() + "'");
}
}
}
现在我已经知道如何实现此目标,请帮助我.....