public JsonResult Insert_EnquiryMaster(EnquiryMasterVM requestModel) { bool result = false; string msg = "Failed to save record.."; string leadId = "", prospectid = ""; string[] data; leadId = EnquiryMethods.Insert_EnquiryMaster(requestModel, Session["DealerCode"].ToString()); if (!string.IsNullOrEmpty(leadId)) { data = leadId.Split(','); leadId = data[0].ToString(); prospectid = data[1].ToString(); result = true; msg = "Successfully Added"; } return(Json(new { Success = result, Message = msg, LeadId = leadId, ProspectId = prospectid }, JsonRequestBehavior.AllowGet)); }
public static string Insert_EnquiryMaster(EnquiryMasterVM model, string dealerCode) { string leadid = ""; string prospectid = ""; email = model.Email == null ? "" : model.Email; if (model.Enquiry_ID == "" || model.Enquiry_ID == null) { strAutoCode = sysfunc.AutoGen("CRM_EnquiryMaster", "Enquiry_ID", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("dd/MM/yyyy"), dealerCode); } else { strAutoCode = model.Enquiry_ID; } if (model.ProspectID == "" || model.ProspectID == "0" || model.ProspectID == null) { autoProspect_ID = sysfunc.AutoGen("CRM_Prospect", "ProspectID", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("dd/MM/yyyy"), dealerCode); } else { autoProspect_ID = model.ProspectID; } try { //var Serializer = new JavaScriptSerializer(); //DateTime leadDate = DateTime.ParseExact(model.EnqDate,"MM/dd/yyyy", CultureInfo.InvariantCulture); SqlParameter[] sqlParam = { new SqlParameter("@DealerCode", dealerCode), //0 new SqlParameter("@Enquiry_ID", strAutoCode), //1 new SqlParameter("@EnqDate", sysfunc.SaveDate(model.EnqDate)), //2 new SqlParameter("@Interest", model.Interest), //3 new SqlParameter("@ProspectID", autoProspect_ID), //4 new SqlParameter("@EmpCode", model.EmpCode), //5 new SqlParameter("@ProspectTypeID", model.ProspectTypeID), //6 new SqlParameter("@CompanyDetail", model.CompanyDetail), //7 new SqlParameter("@EnquiryMode", model.EnquiryModeID), //8 new SqlParameter("@EnquirySource", model.EnquirySourceID), //9 new SqlParameter("@Event_Campaign", model.Event), //10 new SqlParameter("@EnquiryStatus", (object)DBNull.Value), //11 new SqlParameter("@TestDriveGiven", (object)DBNull.Value), //12 new SqlParameter("@CashFinanced", model.CashFinanced), //13 new SqlParameter("@IsFinanced", model.IsFinanced), //14 new SqlParameter("@FinancedThrough", (object)DBNull.Value), //15 new SqlParameter("@FinancedDetail", (object)DBNull.Value), //16 new SqlParameter("@FinancedBank", model.FinancedBank), //17 new SqlParameter("@InsuranceThrough", (object)DBNull.Value), //18 new SqlParameter("@InsuranceDetail", (object)DBNull.Value), //19 new SqlParameter("@ProspectRequist", (object)DBNull.Value), //20 new SqlParameter("@Remarks", model.Remarks), //21 new SqlParameter("@NextFollowupDate", (object)DBNull.Value), //22 new SqlParameter("@NextFollowupTime", (object)DBNull.Value), //23 new SqlParameter("@ActionPlan", (object)DBNull.Value), //24 new SqlParameter("@Purpose", (object)DBNull.Value), //25 new SqlParameter("@LikelyPurchaseDate", (object)DBNull.Value), //26 new SqlParameter("@CreatedBy", model.CreatedBy), //27 new SqlParameter("@RefBy", (object)DBNull.Value), //28 new SqlParameter("@RegMobile", (object)DBNull.Value), //29 new SqlParameter("@FinanceAppliedDate", (object)DBNull.Value), //30 new SqlParameter("@FinanceApprovedDate", (object)DBNull.Value), //31 new SqlParameter("@ProspectLost", (object)DBNull.Value), //32 new SqlParameter("@LostReason", (object)DBNull.Value), //33 new SqlParameter("@LostByDealer", (object)DBNull.Value), //34 new SqlParameter("@LostByModel", (object)DBNull.Value), //35 new SqlParameter("@IsDeleted", model.IsDeleted), //36 new SqlParameter("@IsMatured", model.IsMatured), //37 new SqlParameter("@TransferStatus", (object)DBNull.Value), //38 new SqlParameter("@EnquiryType", model.EnquiryTypeID), //39 new SqlParameter("@Gridstate", false), //40 new SqlParameter("@PMatured", (object)DBNull.Value), //41 new SqlParameter("@PartiallyLost", false), //42 new SqlParameter("@UpdUser", AuthBase.UserId), //43 new SqlParameter("@UpdTerm", General.CurrentIP), //44 new SqlParameter("@SoftwareVersion", (object)DBNull.Value), //45 new SqlParameter("@Blocked", false), //46 new SqlParameter("@Campaign", model.Campaign), //47 new SqlParameter("@Replacement", (object)DBNull.Value), //48 new SqlParameter("@Addtional", (object)DBNull.Value), //49 new SqlParameter("@ExChange", (object)DBNull.Value), //50 new SqlParameter("@Mobile", model.Mobile), //51 new SqlParameter("@InvoiceDetail", model.InvoiceDetail), //52 new SqlParameter("@VehicleSegments", model.SegmentID) //53 }; if (ObjTrans.BeginTransaction(ref Trans) == true) { sysfunc.ExecuteSP_NonQuery("SP_Insert_EnquiryMaster", sqlParam, Trans); leadid = strAutoCode + "," + autoProspect_ID; IsSaved = true; mailMsg.AppendLine("<html><table>"); mailMsg.AppendLine("<tr><td>Sale Person : </td><td>" + sysfunc.GetStringValuesAgainstCodes("EmpCode", model.EmpCode, "EmpName", "DealerEmp", "", dealerCode) + "</td></tr>"); //mailMsg.Append(Environment.NewLine); mailMsg.AppendLine("<tr><td>Enquiry ID : </td><td>" + strAutoCode + "</td></tr>"); //mailMsg.Append(Environment.NewLine); mailMsg.AppendLine("<tr><td>Enquiry Date : </td><td>" + model.EnqDate + "</td></tr>"); //mailMsg.Append(Environment.NewLine); mailMsg.AppendLine("<tr><td>Source : </td><td>" + sysfunc.GetStringValuesAgainstCodes("EnquirySourceID", model.EnquirySourceID, "EnquirySource", "CRM_EnquirySource", "", dealerCode) + "</td></tr>"); //mailMsg.Append(Environment.NewLine); } // dt = DataAccess.getDataTable("SP_Insert_EnquiryMaster", sqlParam, General.GetBMSConString()); //if (dt.Rows.Count > 0) //{ //} } catch (Exception ex) { if (ObjTrans.sql.State == ConnectionState.Open) { leadid = null; ObjTrans.RollBackTransaction(ref Trans); } throw; } return(leadid); }