private void duesautoGenrate() { try { String sDate = DateTime.Now.ToString(); DateTime datevalue = (Convert.ToDateTime(sDate.ToString())); String dy = datevalue.Day.ToString(); String mn = datevalue.Month.ToString(); String yy = datevalue.Year.ToString(); if (dy == "01") { if (checktenantsDues() == false) { DataSet ds = ed.GetTenants(); foreach (DataRow dr in ds.Tables[0].Rows) { string mobile = Session["s_MobileNo"].ToString(); string PropertyName = dr["t_PropertyName"].ToString(); string PropertyVale = dr["t_PropertyVale"].ToString(); string tname = dr["t_Name"].ToString(); string tmobile = dr["t_MobileNo"].ToString(); string troomNo = dr["t_RoomNo"].ToString(); string tDuesType = "Room Rent"; string tDuesAmount = dr["t_RentMoney"].ToString(); DateTime duedate = System.DateTime.Now; string DueDate = duedate.ToString("dd/MM/yyyy"); string tDuesMonth = duedate.ToString("MMMM-yyyy"); string tRemark = "Rent of this month"; uc.AddTenantsDues(mobile, PropertyName, PropertyVale, tname, tmobile, troomNo, tDuesType, tDuesAmount, DueDate, tDuesMonth, tRemark); string textmsg = "Tenants " + tmobile + " Room " + troomNo + " Dues added Successfully !"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpopsuccess('" + textmsg + "')</script>", false); } } else { string text = "This Dues Already exist"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpoperror('" + text + "')</script>", false); } } } catch (Exception ex) { string text = ex.Message.ToString(); ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpoperror('" + text + "')</script>", false); } }