private void Save(CustomerEnquiry CustEnq) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("@CommandText", "AddEnquiry"); dic.Add("@CustomerName", CustEnq.CustName); dic.Add("@PartName", CustEnq.PartName); dic.Add("@EnquiryNo", CustEnq.EnqNo); dic.Add("@CustomerDrawingPartNo", CustEnq.CustDrawing); dic.Add("@FMSINo", CustEnq.FmsiNo); dic.Add("@WVANo", CustEnq.WvaNo); dic.Add("@VehicleModelName", CustEnq.ModelName); dic.Add("@VehicleModelStartYear", CustEnq.ModelStartYr); dic.Add("@DWGRevisionNo", CustEnq.DwgRevNo); dic.Add("@EnquiryRecievedDate", CustEnq.EnqRecDt); dic.Add("@AnnualVolume", CustEnq.AnnualVol); dic.Add("@CreatedBy", CustEnq.CreatedBy); dic.Add("@CreatedOn", DateTime.Now); ProcParametersBe proc = new ProcParametersBe(); proc.storedProcName = "SP_CustomerEnquiry"; proc.objDictionary = dic; CommonDAL.GetResultDAL(proc); Response.Redirect("~/CustomerEnquiryList.aspx", false); }
public ActionResult SaveEnquiry(CustomerEnquiry enquiry) { var helper = new DataHelper(); helper.AddCustomerEnquiry(enquiry); return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); }
private void AddNewRowsToExcelFile(CustomerEnquiry customerEnquiry) { string filePath = System.Web.HttpContext.Current.Server.MapPath("~/DataSources/Customer_Enquiry.xlsx"); Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook xlWorkBook = xlApp.Workbooks.Open(filePath, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false); Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); Microsoft.Office.Interop.Excel.Range xlRange = xlWorkSheet.UsedRange; int rowNumber = xlRange.Rows.Count + 1; xlWorkSheet.Cells[rowNumber, 1] = customerEnquiry.CustomerName; xlWorkSheet.Cells[rowNumber, 2] = customerEnquiry.EmailAddress; xlWorkSheet.Cells[rowNumber, 3] = customerEnquiry.PhoneNumber; xlWorkSheet.Cells[rowNumber, 4] = customerEnquiry.Description; xlWorkSheet.Cells[rowNumber, 5] = customerEnquiry.ProductCode; xlWorkSheet.Cells[rowNumber, 6] = customerEnquiry.Quantity; xlWorkBook.SaveAs(filePath, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges, Missing.Value, Missing.Value, Missing.Value, Missing.Value); xlWorkBook.Close(); xlApp.Quit(); Marshal.ReleaseComObject(xlWorkSheet); Marshal.ReleaseComObject(xlWorkBook); Marshal.ReleaseComObject(xlApp); }
protected void btnSave_Click(object sender, EventArgs e) { UserAccount ssnUser = new UserAccount(); if (Session["UserInfo"] != null) { ssnUser = (UserAccount)Session["UserInfo"]; CustomerEnquiry CustEnq = new CustomerEnquiry(); CustEnq.CustName = txtCustName.Text; CustEnq.PartName = txtPartName.Text; CustEnq.EnqNo = txtEnqNo.Text; CustEnq.CustDrawing = txtCustDrawing.Text; CustEnq.FmsiNo = txtFmsiNo.Text; CustEnq.WvaNo = txtWvaNo.Text; CustEnq.ModelName = txtModelName.Text; CustEnq.ModelStartYr = txtModelStartYr.Text; CustEnq.DwgRevNo = txtDwgRevNo.Text; CustEnq.EnqRecDt = Convert.ToDateTime(txtEnqRecDt.Text); CustEnq.AnnualVol = Convert.ToInt32(txtAnnualVol.Text); CustEnq.CreatedBy = ssnUser.UserId; //CustEnq.CreatedOn = txtCreatedOn.Text; Save(CustEnq); } else { Response.Redirect("~/Default.aspx"); } }
public async Task <IActionResult> AddNewEnquiry([FromForm] CustomerEnquiry customerEnquiry) { string attachmentUrl = string.Empty; string fileTempPath = string.Empty; if (customerEnquiry.Attachment != null) { var fileName = $"{Guid.NewGuid()}-{customerEnquiry.Attachment.FileName}"; fileTempPath = @$ "{Path.GetTempPath()}{fileName}"; using (var stream = new FileStream(fileTempPath, FileMode.Create, FileAccess.ReadWrite)) { await customerEnquiry.Attachment.CopyToAsync(stream); attachmentUrl = await _blobStorageService.UploadBlobAsync(stream, fileName); } } var enquiry = new Enquiry { Id = Guid.NewGuid().ToString(), Title = customerEnquiry.Title, Content = customerEnquiry.Content, CustomerContactEmail = customerEnquiry.CustomerContactEmail, AttachmentUrl = attachmentUrl }; var createdEnquiry = await _enquiryRepository.AddAsync(enquiry); if (!string.IsNullOrEmpty(fileTempPath)) { System.IO.File.Delete(fileTempPath); } return(Ok(createdEnquiry)); }
// // GET: /CustomerMaster/Delete/5 public ActionResult DeleteConfirmed(int id) { CustomerEnquiry cenquery = db.CustomerEnquiries.Where(t => t.CustomerID == id).FirstOrDefault(); if (cenquery == null) { CustomerMaster customermaster = db.CustomerMasters.Find(id); UserRegistration a = (from c in db.UserRegistrations where c.UserName == customermaster.Email select c).FirstOrDefault(); if (customermaster == null) { return(HttpNotFound()); } else { db.CustomerMasters.Remove(customermaster); db.SaveChanges(); db.UserRegistrations.Remove(a); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully Deleted Customer."; return(RedirectToAction("Index")); } } else { TempData["SuccessMsg"] = "Customer Entry could not delete,because it has reference entries!"; return(RedirectToAction("Index")); } }
public ActionResult Edit(PickUpEnquiryVM v) { if (ModelState.IsValid) { CustomerEnquiry _enquiry = new CustomerEnquiry(); _enquiry.EnquiryID = v.EnquiryID; _enquiry.EnquiryNo = v.EnquiryNo; _enquiry.EnquiryDate = Convert.ToDateTime(v.EnquiryDate); _enquiry.AWBNo = v.AWBNo; _enquiry.DescriptionID = 4; _enquiry.ConsignerCountryId = v.ConsignerCountryId; _enquiry.ConsignerCityId = v.ConsignerCityId; _enquiry.ConsignerLocationId = v.ConsignerLocationId; _enquiry.ConsigneeCountryID = v.ConsigneeCountryID; _enquiry.ConsigneeCityId = v.ConsigneeCityId; _enquiry.ConsigneeLocationId = v.ConsigneeLocationId; _enquiry.ConsigneeLocationName = v.ConsigneeLocationName; _enquiry.ConsignorLocationName = v.ConsignorLocationName; _enquiry.Weight = v.Weight; _enquiry.AcCompanyID = 1; _enquiry.CustomerID = v.CustomerID; _enquiry.Consignee = v.Consignee; _enquiry.Consignor = v.Consignor; _enquiry.ConsignorAddress = v.ConsignorAddress; _enquiry.ConsignorAddress1 = v.ConsignorAddress1; _enquiry.ConsignorAddress2 = v.ConsignorAddress2; _enquiry.ConsigneeAddress = v.ConsigneeAddress; _enquiry.ConsigneeAddress1 = v.ConsigneeAddress1; _enquiry.ConsigneeAddress2 = v.ConsigneeAddress2; _enquiry.ConsignorPhone = v.ConsignorPhone; _enquiry.ConsigneePhone = v.ConsigneePhone; _enquiry.EmployeeID = v.EmployeeID; _enquiry.Remarks = v.Remarks; _enquiry.CollectedEmpID = v.CollectedEmpID; _enquiry.IsEnquiry = true; _enquiry.ShipmentType = v.ShipmentType; if (v.vehreq == true) { _enquiry.Vehicle = v.Vehicle; _enquiry.VehicleID = v.VehicleID; } _enquiry.ConsigneeContact = v.ConsigneeContact; _enquiry.ConsignorContact = v.ConsignorContact; _enquiry.EnteredByID = v.EnteredByID; _enquiry.ReadyTime = v.ReadyTime; _enquiry.OfficeTimeFrom = v.OfficeTimeFrom; _enquiry.OfficeTimeTo = v.OfficeTimeTo; _enquiry.RequestSource = v.RequestSource; db.Entry(_enquiry).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully Updated PickUp Enquiry."; return(RedirectToAction("Index")); } return(View()); }
public async Task SendEnquiryAsync(string attachmentFileName, CustomerEnquiry enquiry) { var multipartContent = new MultipartFormDataContent(); multipartContent.Add(new StringContent(enquiry.Title), "title"); multipartContent.Add(new StringContent(enquiry.Content), "content"); multipartContent.Add(new StringContent(enquiry.CustomerContactEmail), "customerContactEmail"); if (enquiry.Attachment != null) { multipartContent.Add(new StreamContent(enquiry.Attachment), "Attachment", attachmentFileName); } await _httpClient.PostAsync("api/enquiry", multipartContent); }
public ActionResult DeleteConfirmed(int id) { CustomerEnquiry a = db.CustomerEnquiries.Find(id); if (a == null) { return(HttpNotFound()); } else { db.CustomerEnquiries.Remove(a); TempData["SuccessMsg"] = "You have successfully Deleted PickUp Enquiry."; db.SaveChanges(); return(RedirectToAction("Index")); } }
private void BindControlVal(int customerEnqId) { CustomerEnquiry ObjBE = new CustomerEnquiry(); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("@CommandText", "GetEnqById"); dic.Add("@CustomerEnquiryId", customerEnqId); ProcParametersBe proc = new ProcParametersBe(); proc.storedProcName = "SP_CustomerEnquiry"; proc.objDictionary = dic; DataSet Ds = CommonDAL.GetResultDAL(proc); if (Ds != null) { for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { txtCustName.Text = Convert.ToString(Ds.Tables[0].Rows[i]["CustomerName"]); txtPartName.Text = Ds.Tables[0].Rows[i]["PartName"].ToString(); txtEnqNo.Text = Ds.Tables[0].Rows[i]["EnquiryNo"].ToString(); txtCustDrawing.Text = Ds.Tables[0].Rows[i]["CustomerDrawingPartNo"].ToString(); txtFmsiNo.Text = Ds.Tables[0].Rows[i]["FMSINo"].ToString(); txtWvaNo.Text = Ds.Tables[0].Rows[i]["WVANo"].ToString(); txtModelName.Text = Ds.Tables[0].Rows[i]["VehicleModelName"].ToString(); txtModelStartYr.Text = Ds.Tables[0].Rows[i]["VehicleModelStartYear"].ToString(); txtDwgRevNo.Text = Ds.Tables[0].Rows[i]["DWGRevisionNo"].ToString(); txtEnqRecDt.Text = Ds.Tables[0].Rows[i]["EnquiryRecievedDate"].ToString(); txtAnnualVol.Text = Ds.Tables[0].Rows[i]["AnnualVolume"].ToString(); ///txtCreatedOn.Text = Ds.Tables[0].Rows[i]["CreatedOn"].ToString(); } btnSave.Enabled = false; } else { btnSave.Enabled = true; } }
public bool SaveCustomerEnquiry(CustomerEnquiryDTO eDTO, CustomerEnquiryFollowupDTO efDTO, int exchangeVehicleId = 0, string mode = "") { var flag = false; try { using (var entities = new ManiMotorsEntities1()) { using (TransactionScope scope = new TransactionScope()) { if (mode != "EDIT") { try { CustomerEnquiry dbEnt = new CustomerEnquiry() { CustomerID = eDTO.CustomerID, ReferenceBy = eDTO.ReferenceBy, CashORFinance = eDTO.CashorFinance, SalesExecutive = eDTO.SalesExecutiveId, Model1 = eDTO.Model1, Model2 = eDTO.Model2, Model3 = eDTO.Model3, Color = eDTO.Color, TestDrive = eDTO.TestDrive, ExchangeVehicle = eDTO.IsExchangeVehicle, CompetitiveModel = eDTO.CompetitiveModel, VehicleStatusID = eDTO.VehicleStatusId, Createdby = eDTO.CreatedBy, CreatedDate = eDTO.CreatedDate, Modifiedby = eDTO.ModifiedBy, ModifiedDate = eDTO.ModifiedDate }; entities.CustomerEnquiries.Add(dbEnt); entities.SaveChanges(); var CustomerEnquiryID = dbEnt.CustomerEnquiryID; var lstCustomer = entities.CustomerEnquiryFollowUps.Where(i => i.CustomerEnquiryID == CustomerEnquiryID); foreach (var followup in lstCustomer) { followup.IsLatest = false; entities.SaveChanges(); } CustomerEnquiryFollowUp dbEntf = new CustomerEnquiryFollowUp() { CustomerID = efDTO.CustomerId, CustomerEnquiryID = CustomerEnquiryID, Description = efDTO.Description, FollowUpDate = efDTO.FollowUpDate, Createdby = eDTO.CreatedBy, CreatedDate = eDTO.CreatedDate, Modifiedby = eDTO.ModifiedBy, ModifiedDate = eDTO.ModifiedDate, IsLatest = true, }; entities.CustomerEnquiryFollowUps.Add(dbEntf); entities.SaveChanges(); if (exchangeVehicleId != 0) { var customerExchange = entities.CustomerExchangeVehicles.FirstOrDefault(ev => ev.CustomerExchangeVehicleID == exchangeVehicleId); customerExchange.CustomerEnquiryID = CustomerEnquiryID; entities.SaveChanges(); } scope.Complete(); } catch (Exception ex) { scope.Dispose(); throw; } } else { try { var ce = entities.CustomerEnquiries.FirstOrDefault(e => e.CustomerEnquiryID == eDTO.CustomerEnquiryID); ce.CustomerID = eDTO.CustomerID; ce.ReferenceBy = eDTO.ReferenceBy; ce.CashORFinance = eDTO.CashorFinance; ce.SalesExecutive = eDTO.SalesExecutiveId; ce.Model1 = eDTO.Model1; ce.Model2 = eDTO.Model2; ce.Model3 = eDTO.Model3; ce.Color = eDTO.Color; ce.TestDrive = eDTO.TestDrive; ce.ExchangeVehicle = eDTO.IsExchangeVehicle; ce.CompetitiveModel = eDTO.CompetitiveModel; ce.VehicleStatusID = eDTO.VehicleStatusId; ce.Createdby = eDTO.CreatedBy; ce.CreatedDate = eDTO.CreatedDate; ce.Modifiedby = eDTO.ModifiedBy; ce.ModifiedDate = eDTO.ModifiedDate; entities.SaveChanges(); var lstCustomer = entities.CustomerEnquiryFollowUps.Where(i => i.CustomerEnquiryID == eDTO.CustomerEnquiryID); foreach (var followup in lstCustomer) { followup.IsLatest = false; entities.SaveChanges(); } CustomerEnquiryFollowUp dbEntf = new CustomerEnquiryFollowUp() { CustomerID = efDTO.CustomerId, CustomerEnquiryID = eDTO.CustomerEnquiryID, Description = efDTO.Description, FollowUpDate = efDTO.FollowUpDate, Createdby = eDTO.CreatedBy, CreatedDate = eDTO.CreatedDate, Modifiedby = eDTO.ModifiedBy, ModifiedDate = eDTO.ModifiedDate, IsLatest = true, }; entities.CustomerEnquiryFollowUps.Add(dbEntf); entities.SaveChanges(); scope.Complete(); } catch (Exception ex) { scope.Dispose(); throw; } } } } flag = true; } catch (Exception ex) { throw ex; } return(flag); }
public ActionResult Create(PickUpEnquiryVM v) { int uid = Convert.ToInt32(Session["UserID"].ToString()); UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault(); int empid = u.UserID; string empname = u.UserName; CustomerEnquiry _enquiry = new CustomerEnquiry(); int id = (from c in db.CustomerEnquiries orderby c.EnquiryID descending select c.EnquiryID).FirstOrDefault(); _enquiry.EnquiryID = id + 1; _enquiry.EnquiryNo = (id + 1).ToString(); _enquiry.AWBNo = GetMaxAWBNo(); _enquiry.EnquiryDate = Convert.ToDateTime(v.EnquiryDate); _enquiry.DescriptionID = 4; _enquiry.ConsignerCountryId = v.ConsignerCountryId; _enquiry.ConsignerCityId = v.ConsignerCityId; _enquiry.ConsigneeLocationName = v.ConsigneeLocationName; _enquiry.ConsignorLocationName = v.ConsignorLocationName; _enquiry.ConsigneeCountryID = v.ConsigneeCountryID; _enquiry.ConsigneeCityId = v.ConsigneeCityId; _enquiry.Weight = v.Weight; _enquiry.AcCompanyID = 1; _enquiry.CustomerID = v.CustomerID; _enquiry.Consignee = v.Consignee; _enquiry.Consignor = v.Consignor; _enquiry.ConsignorAddress = v.ConsignorAddress; _enquiry.ConsignorAddress1 = v.ConsignorAddress1; _enquiry.ConsignorAddress2 = v.ConsignorAddress2; _enquiry.ConsigneeAddress = v.ConsigneeAddress; _enquiry.ConsigneeAddress1 = v.ConsigneeAddress1; _enquiry.ConsigneeAddress2 = v.ConsigneeAddress2; _enquiry.ConsignorPhone = v.ConsignorPhone; _enquiry.ConsigneePhone = v.ConsigneePhone; _enquiry.EmployeeID = v.EmployeeID; _enquiry.Remarks = v.Remarks; _enquiry.CollectedEmpID = v.CollectedEmpID; _enquiry.ShipmentType = v.ShipmentType; if (v.vehreq == true) { _enquiry.Vehicle = v.Vehicle; _enquiry.VehicleID = v.VehicleID; } _enquiry.ConsigneeContact = v.ConsigneeContact; _enquiry.ConsignorContact = v.ConsignorContact; _enquiry.EnteredByID = empid; _enquiry.IsEnquiry = true; _enquiry.ReadyTime = v.ReadyTime; _enquiry.OfficeTimeFrom = v.OfficeTimeFrom; _enquiry.OfficeTimeTo = v.OfficeTimeTo; _enquiry.RequestSource = v.RequestSource; db.CustomerEnquiries.Add(_enquiry); TempData["SuccessMsg"] = "You have successfully Added PickUp Enquiry."; db.SaveChanges(); return(RedirectToAction("Index")); return(View()); }
public ActionResult Edit(int id) { int uid = Convert.ToInt32(Session["UserID"].ToString()); UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault(); int empid = u.UserID; string empname = u.UserName; ViewBag.Country = db.CountryMasters.ToList(); ViewBag.Location = db.LocationMasters.ToList(); ViewBag.Vehicle = db.VehicleMasters.ToList(); ViewBag.Employee = db.EmployeeMasters.ToList(); ViewBag.Customer = db.CustomerMasters.ToList(); ViewBag.empname = empname; ViewBag.empid = empid; PickUpEnquiryVM v = new PickUpEnquiryVM(); CustomerEnquiry a = db.CustomerEnquiries.Find(id); if (a == null) { return(HttpNotFound()); } else { v.EnquiryID = a.EnquiryID; v.EnquiryNo = a.EnquiryNo; v.AWBNo = "101"; v.EnquiryDate = a.EnquiryDate; v.DescriptionID = 4; v.ConsignerCountryId = a.ConsignerCountryId; v.ConsignerCityId = a.ConsignerCityId; v.ConsignerLocationId = a.ConsignerLocationId; v.ConsigneeCountryID = a.ConsigneeCountryID; v.ConsigneeCityId = a.ConsigneeCityId; v.ConsigneeLocationId = a.ConsigneeLocationId; v.ConsigneeLocationName = a.ConsigneeLocationName; v.ConsignorLocationName = a.ConsignorLocationName; v.Weight = a.Weight; v.AcCompanyID = 1; v.CustomerID = a.CustomerID; v.Consignee = a.Consignee; v.Consignor = a.Consignor; v.ConsignorAddress = a.ConsignorAddress; v.ConsignorAddress1 = a.ConsignorAddress1; v.ConsignorAddress2 = a.ConsignorAddress2; v.ConsigneeAddress = a.ConsigneeAddress; v.ConsigneeAddress1 = a.ConsigneeAddress1; v.ConsigneeAddress2 = a.ConsigneeAddress2; v.ConsignorPhone = a.ConsignorPhone; v.ConsigneePhone = a.ConsigneePhone; v.EmployeeID = a.EmployeeID; v.Remarks = a.Remarks; v.CollectedEmpID = a.CollectedEmpID; v.ShipmentType = a.ShipmentType; if (a.VehicleID != null) { v.VehicleID = a.VehicleID.Value; v.Vehicle = a.Vehicle; v.vehreq = true; } else { v.vehreq = false; v.Vehicle = ""; } v.IsEnquiry = a.IsEnquiry; v.ConsigneeContact = a.ConsigneeContact; v.ConsignorContact = a.ConsignorContact; v.EnteredByID = empid; v.ReadyTime = a.ReadyTime; v.OfficeTimeFrom = a.OfficeTimeFrom; v.OfficeTimeTo = a.OfficeTimeTo; v.RequestSource = a.RequestSource; } var obj = (from c in db.CityMasters where c.CountryID == a.ConsignerCountryId select c).ToList(); ViewBag.City = (from c in db.CityMasters where c.CountryID == a.ConsignerCountryId select c).ToList(); ViewBag.CityConsignee = (from c in db.CityMasters where c.CountryID == a.ConsigneeCountryID select c).ToList(); return(View(v)); }
public void AddCustomerEnquiry(CustomerEnquiry customerEnquiry) { AddNewRowsToExcelFile(customerEnquiry); }
public void SaveCustomerInquiry(CustomerEnquiry ce) { db.SaveCustomerInquiry(ce); }