private void GetRecords(int Id) { DataTable table = BAL_CMS.GetCMSByCMSId(Id); { txtLink.Text = Convert.ToString(table.Rows[0]["LinkName"]); txtDesc.Value = Convert.ToString(table.Rows[0]["Description"]); txtLink.Enabled = false; } }
protected void btnInActive_Click(object sender, EventArgs e) { if (BAL_CMS.ActivateRecords(ReturnIds(), false) == true) { ShowMessage("Record Deactivated succefully"); FillGrid(); } else { ShowMessage("Error in record deactivation."); } }
protected void btnDelete_Click(object sender, EventArgs e) { if (BAL_CMS.DeleteRecords(ReturnIds()) == true) { ShowMessage("Record Deleted Successfully."); FillGrid(); } else { ShowMessage("Error in record deletion."); } }
protected void imgbtn_Insert_Click(object sender, EventArgs e) { if (ValidateInput() == false) { Page.Validate("AddCategory"); if (Page.IsValid == true) { txtLink.Text = Server.HtmlEncode(txtLink.Text); if (!string.IsNullOrEmpty(lblMode.Text)) { if (BAL_CMS.UpdateCMS(txtLink.Text, txtDesc.Value, Convert.ToInt32(lblMode.Text)) == true) { ShowMessage("Record Updated Susseccfully."); //gvAdminList.DataBind(); //ClearInput(); FillGrid(); ClearInput(); } else { ShowMessage("Error in record updation."); } } else { if (BAL_CMS.InsertCMS(txtLink.Text, txtDesc.Value) == true) { ShowMessage("Record Inserted Susseccfully."); FillGrid(); ClearInput(); } else { ShowMessage("Error in record insertion."); } } } else { ShowMessage("Some Required Field Missing"); } } }
private void FillGrid() { int TotalCount; gvAdminList.PageIndex = gvIndex; DataTable table = BAL_CMS.GetCMSInfo(gvAdminList.PageIndex, gvAdminList.PageSize, gvAdminList.OrderBy, out TotalCount); gvAdminList.VirtualItemCount = TotalCount; gvAdminList.DataSource = table; gvAdminList.DataBind(); if (gvAdminList.Rows.Count > 0) { lblsearch2.Visible = true; ddlPerpage.Visible = true; lable123.Visible = true; } else { lblsearch2.Visible = false; ddlPerpage.Visible = false; lable123.Visible = false; } }
protected void hlCarButton_Click(object sender, EventArgs e) { if (Page.IsValid) { trError.Visible = false; if (Session["userdata"] != null) { string strCustomerName = Convert.ToString(Session["CustomerName"]); string phonenumber = Convert.ToString(Session["Phonenumber"]); string emailaddress = Convert.ToString(Session["EmailAddress"]); string zipcode = Convert.ToString(Session["PostCode"]); string carplate = Convert.ToString(Session["CarPlate"]); string carValuation = Convert.ToString(Session["Valuation"]); //Response.Write("Customer Name" + strCustomerName + "<br> Phone number" + phonenumber + " <br> Email " + emailaddress + " <br> Zipcode" + zipcode + "<br> CarPlate" + carplate); BAL_BookAppointment.UpdateAppointment("0", strCustomerName, phonenumber, emailaddress, zipcode, ddlChoosedate.SelectedItem.Text.ToString(), ddlAvailabletimeslot.SelectedItem.Text.ToString(), "0", carplate, carValuation, int.Parse(ddlChooseBranch.SelectedItem.Value)); Session["appdate"] = ddlChoosedate.SelectedItem.Text; Session["apptime"] = ddlAvailabletimeslot.SelectedItem.Text; /*email send code*/ //Appointment Confirmation Email String strCustFileName = Server.MapPath("~/MailContent") + "\\appconfirmation.html"; if (Session["branchname"] != null) { if (Session["branchname"].ToString().ToLower().Trim() == "bridgend") { strCustFileName = Server.MapPath("~/MailContent") + "\\bridgend-appconfirmation.html"; } else if (Session["branchname"].ToString().ToLower().Trim() == "bristol") { strCustFileName = Server.MapPath("~/MailContent") + "\\bristol-appconfirmation.html"; } else if (Session["branchname"].ToString().ToLower().Trim() == "cardiff") { strCustFileName = Server.MapPath("~/MailContent") + "\\cardiff-appconfirmation.html"; } else if (Session["branchname"].ToString().ToLower().Trim() == "swindon") { strCustFileName = Server.MapPath("~/MailContent") + "\\swindon-appconfirmation.html"; } } System.IO.StreamReader srCustHTML = new System.IO.StreamReader(strCustFileName); System.Text.StringBuilder sbMessage = new System.Text.StringBuilder(srCustHTML.ReadToEnd()); srCustHTML.Close(); sbMessage.Replace("@title", Convert.ToString(Session["saluation"])); sbMessage.Replace("@surname", Convert.ToString(Session["Lastname"])); sbMessage.Replace("@valuation", Convert.ToString(Session["CarValuation"])); sbMessage.Replace("@apptime", Convert.ToString(Session["apptime"]).Replace(" ", string.Empty)); sbMessage.Replace("@appdate", Convert.ToString(Session["appdate"])); sbMessage.Replace("@branch", Convert.ToString(Session["branchname"])); sbMessage.Replace("@carnumber", Convert.ToString(Session["CarPlate"])); sbMessage.Replace("@registration", ((clsCarselection)(Session["userdata"])).Registration); sbMessage.Replace("@vehicle", ((clsCarselection)(Session["userdata"])).Model); sbMessage.Replace("@mileage", ((clsCarselection)(Session["userdata"])).cs2_CurrentMileage); sbMessage.Replace("@footerValue", BAL_CMS.GetDetailsByLinkName("Home Page Footer")); string brnchEmailAddress = string.Empty; string ccEmail = string.Empty; switch (Session["branchname"].ToString().ToLower().Trim()) { case "bridgend": sbMessage.Replace("@officenumber", ConfigurationManager.AppSettings["Bridgend_Phone"].ToString()); sbMessage.Replace("@address", ConfigurationManager.AppSettings["Bridgend_Address"].ToString()); brnchEmailAddress = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); ccEmail = ConfigurationManager.AppSettings["Cardiff_Email"].ToString(); break; case "cardiff": brnchEmailAddress = ConfigurationManager.AppSettings["Cardiff_Email"].ToString(); sbMessage.Replace("@officenumber", ConfigurationManager.AppSettings["Cardiff_Phone"].ToString()); sbMessage.Replace("@address", ConfigurationManager.AppSettings["Cardiff_Address"].ToString()); ccEmail = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); break; case "swansea": brnchEmailAddress = ConfigurationManager.AppSettings["Swansea_Email"].ToString(); sbMessage.Replace("@officenumber", ConfigurationManager.AppSettings["Swansea_Phone"].ToString()); sbMessage.Replace("@address", ConfigurationManager.AppSettings["Swansea_Address"].ToString()); ccEmail = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); break; case "newport": brnchEmailAddress = ConfigurationManager.AppSettings["Newport_Email"].ToString(); sbMessage.Replace("@officenumber", ConfigurationManager.AppSettings["Newport_Phone"].ToString()); sbMessage.Replace("@address", ConfigurationManager.AppSettings["Newport_Address"].ToString()); ccEmail = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); break; case "bristol": brnchEmailAddress = ConfigurationManager.AppSettings["Bristol_Email"].ToString(); sbMessage.Replace("@officenumber", ConfigurationManager.AppSettings["Bristol_Phone"].ToString()); sbMessage.Replace("@address", ConfigurationManager.AppSettings["Bristol_Address"].ToString()); ccEmail = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); break; case "gloucester": brnchEmailAddress = ConfigurationManager.AppSettings["gloucester_email"].ToString(); sbMessage.Replace("@officenumber", ConfigurationManager.AppSettings["gloucester_phone"].ToString()); sbMessage.Replace("@address", ConfigurationManager.AppSettings["gloucester_address"].ToString()); ccEmail = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); break; case "swindon": brnchEmailAddress = ConfigurationManager.AppSettings["swindon_email"].ToString(); sbMessage.Replace("@officenumber", ConfigurationManager.AppSettings["swindon_phone"].ToString()); sbMessage.Replace("@address", ConfigurationManager.AppSettings["swindon_address"].ToString()); ccEmail = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); break; default: brnchEmailAddress = ""; sbMessage.Replace("@officenumber", "01452835619"); sbMessage.Replace("@address", ""); ccEmail = ConfigurationManager.AppSettings["adminEmailAddress"].ToString(); break; } log.Debug("Sending appointment emails"); Utilities.SendMail(ConfigurationManager.AppSettings["adminEmailAddress"], brnchEmailAddress, "Appointment Confirmation Email " + ((clsCarselection)(Session["userdata"])).CarPlate, sbMessage.ToString(), ccEmail); //Utilities.SendMail("*****@*****.**", "*****@*****.**", "Appointment Confirmation Email " + ((clsCarselection)(Session["userdata"])).CarPlate, sbMessage.ToString()); Utilities.SendMail(ConfigurationManager.AppSettings["adminEmailAddress"], Convert.ToString(Session["EmailAddress"]), "Appointment Confirmation Email " + ((clsCarselection)(Session["userdata"])).CarPlate, sbMessage.ToString(), string.Empty); /*email send code*/ Utilities.RemoveFollowup(emailaddress); Response.Redirect("~/appointment_confirmation.aspx"); lblError.Text = "Appointment booking succesfully"; } else { trError.Visible = true; lblError.Text = "Please contact your Administrator"; } } }
protected void btnGetValuation_Click(object sender, EventArgs e) { try { if (Page.IsValid) { log.Debug("Entered code"); Session["saluation"] = ddlSaluation.SelectedItem.Text; Session["CustomerName"] = txtFirstName.Text + " " + txtLastName.Text; Session["Lastname"] = txtLastName.Text; Session["Phonenumber"] = txtPhoneNumber.Text; Session["EmailAddress"] = txtEmailAddress.Text; Session["PostCode"] = txtPostcode.Text; Session["CarPlate"] = ((clsCarselection)(Session["userdata"])).CarPlate; if (!chkAgree.Checked) { lblMsg.ForeColor = System.Drawing.Color.Red; lblMsg.Text = "Please select"; return; } if (Session["userdata"] != null) { try { DataTable dt = new DataTable(); /*Session["getCurrentTime"] = System.DateTime.Now;*/ log.Debug("Getting valuation"); /*here we have called -1 year*/ dt = BAL_Valuation.GetValuation(((clsCarselection)(Session["userdata"])).CapId.ToString(), -1, Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Month, ((clsCarselection)(Session["userdata"])).cs2_CurrentMileage + "!!" + Convert.ToString(Session["SValuation"])); if (dt != null) { int iYear = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Year; int iMonth = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Month; DataTable dt1 = new DataTable(); dt1 = BAL_Valuation.GetValuation(((clsCarselection)(Session["userdata"])).CapId.ToString(), iYear, iMonth, ((clsCarselection)(Session["userdata"])).cs2_CurrentMileage + "!!" + Convert.ToString(Session["SValuation"])); if (dt1.Rows.Count > 0) { dt.Clear(); dt = dt1; } //if (dt.Rows.Count == 0) //{ // int iYear = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Year; // int iMonth = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Month; // dt = BAL_Valuation.GetValuation(((clsCarselection)(Session["userdata"])).CapId.ToString(), iYear, iMonth, ((clsCarselection)(Session["userdata"])).cs2_CurrentMileage + "!!" + Convert.ToString(Session["SValuation"])); //} //else //{ // if (Convert.ToInt32(dt.Rows[0]["Uvt_Month"]) != Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Month) // { // int iYear = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Year; // int iMonth = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Month; // dt = BAL_Valuation.GetValuation(((clsCarselection)(Session["userdata"])).CapId.ToString(), iYear, iMonth, ((clsCarselection)(Session["userdata"])).cs2_CurrentMileage + "!!" + Convert.ToString(Session["SValuation"])); // } //} } else { int iYear = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Year; int iMonth = Convert.ToDateTime(((clsCarselection)(Session["userdata"])).FirstRegister).Month; dt = BAL_Valuation.GetValuation(((clsCarselection)(Session["userdata"])).CapId.ToString(), iYear, iMonth, ((clsCarselection)(Session["userdata"])).cs2_CurrentMileage + "!!" + Convert.ToString(Session["SValuation"])); } if (dt != null) { if (dt.Rows.Count > 0) { //mail code string strMessage = "Value of Car : Retail - " + dt.Rows[0]["uvt_retail"].ToString() + " | | | Average : " + dt.Rows[0]["uvt_average"].ToString() + " | | | Below - " + dt.Rows[0]["uvt_below"].ToString(); log.Debug(strMessage); // CODE BY MARK double capAvg = 0; double capClean = 0; double capBelow = 0; double dCapAvg = 0; double dCapClean = 0; double dCapBelow = 0; double.TryParse(dt.Rows[0]["uvt_average"].ToString(), out capAvg); double.TryParse(dt.Rows[0]["uvt_clean"].ToString(), out capClean); double.TryParse(dt.Rows[0]["uvt_below"].ToString(), out capBelow); string strAvg = string.Empty; dCapAvg = capAvg; dCapBelow = capBelow; dCapClean = capClean; if (capAvg > 0 && capClean > 0) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(BAL_Valuation.GetValAdjustmentXML()); // Establish what figures we are going to use //objcls.IsVan if (((clsCarselection)(Session["userdata"])).IsVan == false) { //getting new valuation capAvg = BAL_Rules.GetValuationBasedonRules(capAvg); capClean = BAL_Rules.GetValuationBasedonRules(capClean); capBelow = BAL_Rules.GetValuationBasedonRules(capBelow); log.Debug("New Car Value Based on the Rules -> Clean - " + capClean.ToString() + " | | | Average : " + capAvg.ToString() + " | | | Below - " + capBelow.ToString()); switch (xmlDoc.SelectSingleNode("ValResource/ValType").InnerText) { case "0": { strAvg = capClean.ToString("F0"); break; } case "1": { strAvg = capAvg.ToString("F0"); break; } case "2": { strAvg = capBelow.ToString("F0"); break; } case "3": // Custom calculation { strAvg = ((capAvg + capClean) / 2).ToString("F0"); break; } } } else { // Its a van switch (xmlDoc.SelectSingleNode("ValResource/VanValType").InnerText) { case "0": { strAvg = capClean.ToString("F0"); break; } case "1": { strAvg = capAvg.ToString("F0"); break; } case "2": { strAvg = capBelow.ToString("F0"); break; } case "3": // Custom calculation { strAvg = ((capAvg + capClean) / 2).ToString("F0"); break; } } } // Now check if we are adding any additional stuff double pounds = 0; double percent = 0; if (((clsCarselection)(Session["userdata"])).IsVan == false) { double.TryParse(xmlDoc.SelectSingleNode("ValResource/PoundsMarkup").InnerText, out pounds); double.TryParse(xmlDoc.SelectSingleNode("ValResource/PercentMarkup").InnerText, out percent); } else { double.TryParse(xmlDoc.SelectSingleNode("ValResource/VanPounds").InnerText, out pounds); double.TryParse(xmlDoc.SelectSingleNode("ValResource/VanPercent").InnerText, out percent); } if (pounds != 0) { double tempVal = double.Parse(strAvg); tempVal += pounds; strAvg = tempVal.ToString("F0"); } if (percent != 0) { double tempVal = double.Parse(strAvg); tempVal += ((tempVal / 100) * percent); strAvg = tempVal.ToString("F0"); } } else { strAvg = dt.Rows[0]["uvt_average"].ToString(); } if (!string.IsNullOrEmpty(strAvg)) { if (strAvg.Contains(".")) { string[] temp = strAvg.Split('.'); if (temp[1].Length < 2) { temp[1] = temp[1] + "00"; strAvg = temp[0].ToString() + "." + temp[1].Substring(0, temp[1].Length - 1); } } } // ROUNDING - move this into it's own class at some point double adjAverage = double.Parse(strAvg); if (adjAverage <= 1000) { strAvg = ((double)Math.Round(((double)adjAverage) / 10, 0, MidpointRounding.AwayFromZero) * 10).ToString(); } else if (adjAverage <= 10000) { strAvg = ((double)Math.Round(((double)adjAverage) / 25, 0, MidpointRounding.AwayFromZero) * 25).ToString(); } else if (adjAverage <= 30000) { strAvg = ((double)Math.Round(((double)adjAverage) / 50, 0, MidpointRounding.AwayFromZero) * 50).ToString(); } else if (adjAverage > 30000) { strAvg = ((double)Math.Round(((double)adjAverage) / 100, 0, MidpointRounding.AwayFromZero) * 100).ToString(); } String strCustFileName = Server.MapPath("~/MailContent") + "\\email.html"; StreamReader srCustHTML = new StreamReader(strCustFileName); StringBuilder sbMessage = new StringBuilder(srCustHTML.ReadToEnd()); srCustHTML.Close(); sbMessage.Replace("@avgValue", strAvg); string strFirstName = ddlSaluation.SelectedItem.Text + " " + txtLastName.Text.ToString().Substring(0, 1).ToUpper() + txtLastName.Text.ToString().Substring(1).ToLower(); sbMessage.Replace("@firstname", strFirstName); sbMessage.Replace("@footerValue", BAL_CMS.GetDetailsByLinkName("Home Page Footer")); // This is nonsense - use one valuation session variable! Session["CarValuation"] = strAvg; Session["Valuation"] = strAvg; Utilities.SendMail(ConfigurationManager.AppSettings["adminEmailAddress"], txtEmailAddress.Text, "Value of Vehicle : " + ((clsCarselection)(Session["userdata"])).CarPlate, sbMessage.ToString(), string.Empty); /*Administrator email*/ string strBodyWork = string.Empty; DataTable dtBodyWork = ((clsCarselection)(Session["userdata"])).cs3_BodyWork; if (dtBodyWork != null) { if (dtBodyWork.Rows.Count > 0) { strBodyWork = ""; } } String strFileName = Server.MapPath("~/MailContent") + "\\carregistrationdetail.html"; StreamReader srHTML = new StreamReader(strFileName); StringBuilder sb = new StringBuilder(srHTML.ReadToEnd()); sb.Replace("@registration", ((clsCarselection)(Session["userdata"])).Registration); sb.Replace("@valuation", "£" + Convert.ToString(strAvg)); sb.Replace("@capclean", "£" + Convert.ToString(BAL_Rules.RoundingValues(dCapClean))); sb.Replace("@capaverage", "£" + Convert.ToString(BAL_Rules.RoundingValues(dCapAvg))); sb.Replace("@capbelow", "£" + Convert.ToString(BAL_Rules.RoundingValues(dCapBelow))); sb.Replace("@manufacturer", ((clsCarselection)(Session["userdata"])).Manufacturer); sb.Replace("@model@", ((clsCarselection)(Session["userdata"])).Model); sb.Replace("@modelyear@", ((clsCarselection)(Session["userdata"])).ModelYear); sb.Replace("@colour", ((clsCarselection)(Session["userdata"])).Colour); sb.Replace("@transmission", ((clsCarselection)(Session["userdata"])).Transmission); sb.Replace("@enginesize", ((clsCarselection)(Session["userdata"])).EngineSize); sb.Replace("@firstregistered", ((clsCarselection)(Session["userdata"])).FirstRegister); sb.Replace("@noofdoors", ((clsCarselection)(Session["userdata"])).NoOfDoors); sb.Replace("@bodystyle", ((clsCarselection)(Session["userdata"])).BodyStyle); sb.Replace("@cs2_currentmileage", ((clsCarselection)(Session["userdata"])).cs2_CurrentMileage); sb.Replace("@cs2_carimport", ((clsCarselection)(Session["userdata"])).cs2_CarImport); sb.Replace("@cs2_pregistration", ((clsCarselection)(Session["userdata"])).cs2_PRegistration); sb.Replace("@cs2_insurance", ((clsCarselection)(Session["userdata"])).cs2_Insurance); sb.Replace("@cs2_powners", ((clsCarselection)(Session["userdata"])).cs2_POwners); sb.Replace("@cs2_shistory", ((clsCarselection)(Session["userdata"])).cs2_SHistory); sb.Replace("@cs2_mot", ((clsCarselection)(Session["userdata"])).cs2_MOT); sb.Replace("@cs2_vcondition", ((clsCarselection)(Session["userdata"])).cs2_VCondition); sb.Replace("@cs2_v5", ((clsCarselection)(Session["userdata"])).cs2_V5); sb.Replace("@cs2_ofinance", ((clsCarselection)(Session["userdata"])).cs2_OFinance); sb.Replace("@title", ddlSaluation.SelectedItem.Text); sb.Replace("@firstname", txtFirstName.Text); sb.Replace("@lastname", txtLastName.Text); sb.Replace("@phonenumber", txtPhoneNumber.Text); sb.Replace("@emailaddress", txtEmailAddress.Text); sb.Replace("@postcode", txtPostcode.Text); //Utilities.SendMail("*****@*****.**", "*****@*****.**", "Detailed Report " + ((clsCarselection)(Session["userdata"])).CarPlate, sb.ToString()); Utilities.SendMail(ConfigurationManager.AppSettings["adminEmailAddress"], ConfigurationManager.AppSettings["adminEmailAddress"], "Detailed Report " + ((clsCarselection)(Session["userdata"])).CarPlate, sb.ToString(), string.Empty); Utilities.LogVisitor(ddlSaluation.SelectedItem.Text, txtFirstName.Text, txtLastName.Text, txtEmailAddress.Text, ((clsCarselection)(Session["userdata"])).CarPlate.ToString(), Convert.ToString(strAvg)); Response.Redirect("~/yourvaluation.aspx", false); } else { ShowMessage("There seems to be a problem with your particular plate, please call the office on 0845 519 0898 and we will provide you with an instant quote over the phone."); } } else { ShowMessage("There seems to be a problem with your particular plate, please call the office on 0845 519 0898 and we will provide you with an instant quote over the phone."); } } catch (Exception ex) { ShowMessage("There seems to be a problem with your particular plate, please call the office on 0845 519 0898 and we will provide you with an instant quote over the phone."); //ShowMessage(ex.Message); } } } } catch (Exception ex) { log.Error("Error in Val", ex); } }