public int AddInquiryDetails(InquiryDetails quiryDetails) { try { DALComponent objDALRegister = new DALComponent(); objDALRegister.SetParameters("@InquiryID", SqlDbType.Int, 4, quiryDetails.InquiryID); objDALRegister.SetParameters("@InquiryTitle", SqlDbType.VarChar, 100, quiryDetails.InquiryTitle); objDALRegister.SetParameters("@Description", SqlDbType.VarChar, 300, quiryDetails.Description); objDALRegister.SetParameters("@Keywords", SqlDbType.VarChar, 300, quiryDetails.Keywords); objDALRegister.SetParameters("@CategoryId", SqlDbType.Int, 4, quiryDetails.CategoryId); objDALRegister.SetParameters("@ServiceId", SqlDbType.Int, 4, quiryDetails.ServiceId); objDALRegister.SetParameters("@CustomerId", SqlDbType.Int, 4, quiryDetails.CustomerId); objDALRegister.SetParameters("@CityId", SqlDbType.Int, 4, quiryDetails.CityId); objDALRegister.SetParameters("@ImagePath", SqlDbType.VarChar, 500, quiryDetails.ImagePath); objDALRegister.SetParameters("@VideoPath", SqlDbType.VarChar, 200, quiryDetails.VideoPath); objDALRegister.SetParameters("@idvalue", SqlDbType.Int, true); objDALRegister.SqlCommandText = "[CreateInquiryDetails]"; int x = objDALRegister.CreateRecord(); object y = objDALRegister.GetParameters("@idvalue"); if (quiryDetails.InquiryID != 0) return quiryDetails.InquiryID; else return Int32.Parse(y.ToString()); } catch (SqlException sqlEx) { throw new ApplicationException("Data error=" + sqlEx.Message.ToString()); } catch (Exception ex) { throw new ApplicationException("Error=" + ex.Message.ToString()); } }
protected void btnPost_Click(object sender, EventArgs e) { #region .. VALIDATION .. int intError = 0; string strErrorMsg = ""; if (txtQuoteTitle.Value.ToString() == "") { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> Quiry Title should not be empty. <br/>"; intError++; } if (ddlCategory.SelectedIndex == 0) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> Please Select Category. <br/>"; intError++; } if (FileUpload1.PostedFile.ContentLength == 0 || Request.Form["fileName1"] == null) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> Please Upload atleast one image. <br/>"; intError++; } if (FileUpload1.PostedFile != null) { if (FileUpload1.PostedFile.ContentLength > (50 * 1024)) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> " + FileUpload1.PostedFile.FileName + " Exceeds maximum limit 50 KB. <br/>"; intError++; } } if (FileUpload2.PostedFile != null) { if (FileUpload2.PostedFile.ContentLength > (50 * 1024)) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> " + FileUpload2.PostedFile.FileName + " Exceeds maximum limit 50 KB. <br/>"; intError++; } } if (FileUpload3.PostedFile != null) { if (FileUpload3.PostedFile.ContentLength > (50 * 1024)) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> " + FileUpload3.PostedFile.FileName + " Exceeds maximum limit 50 KB. <br/>"; intError++; } } if (FileUpload4.PostedFile != null) { if (FileUpload4.PostedFile.ContentLength > (50 * 1024)) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> " + FileUpload4.PostedFile.FileName + " Exceeds maximum limit 50 KB. <br/>"; intError++; } } if (FileUpload5.PostedFile != null) { if (FileUpload5.PostedFile.ContentLength > (50 * 1024)) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> " + FileUpload5.PostedFile.FileName + " Exceeds maximum limit 50 KB. <br/>"; intError++; } } if (FileUploadVid.PostedFile != null) { if (FileUploadVid.PostedFile.ContentLength > (500 * 1024)) { strErrorMsg += " <img src='image/error.jpg' height='40px' width='40px' /> " + FileUploadVid.PostedFile.FileName + " Exceeds maximum limit 500 KB. <br/>"; intError++; } } #endregion if (intError == 0) { InquiryDetails objQuiry = new InquiryDetails(); objQuiry.InquiryID = 0; objQuiry.InquiryTitle = txtQuoteTitle.Value.ToString(); objQuiry.Description = txtQuoteDesc.Value.ToString(); objQuiry.Keywords = "";// txtQuoteKey.Value.ToString(); objQuiry.CategoryId = Convert.ToInt32(ddlCategory.Value.ToString()); objQuiry.CustomerId = Convert.ToInt32(Session["LoginId"].ToString()); objQuiry.CityId = 0; objQuiry.ImagePath = ""; objQuiry.VideoPath = ""; objService = new ServeAtDoorstepService(); int intQuoId = objService.AddInquiryDetails(objQuiry); #region .. CREATE INQUIRY IMAGE .. string path = string.Empty; string strImgFinalPath = ""; string finalPath = string.Empty; string filePath = string.Empty; int iLoginId = Convert.ToInt32(Session["LoginId"].ToString()); string sFilename = ""; if (FileUpload1.PostedFile != null) { HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { DirectoryInfo dirInfo = null; fileSavePath = "/Data/IQU_" + iLoginId + "_" + intQuoId + "/Images/"; path = Server.MapPath("~" + fileSavePath); if (!Directory.Exists(path)) { dirInfo = Directory.CreateDirectory(path); } sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload1.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); } } strImgFinalPath = finalPath; if (FileUpload2.PostedFile != null) { HttpPostedFile myFile = FileUpload2.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload2.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload3.PostedFile != null) { HttpPostedFile myFile = FileUpload3.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload3.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload4.PostedFile != null) { HttpPostedFile myFile = FileUpload4.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload4.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload5.PostedFile != null) { HttpPostedFile myFile = FileUpload5.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload5.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } sFilename = ""; finalPath = ""; if (FileUploadVid.PostedFile != null) { HttpPostedFile myFile = FileUploadVid.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { DirectoryInfo dirInfo = null; fileSavePath = "/Data/IQU_" + iLoginId + "_" + intQuoId + "/Video/"; path = Server.MapPath("~" + fileSavePath); if (!Directory.Exists(path)) { dirInfo = Directory.CreateDirectory(path); } sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUploadVid.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); } } string strVidFinalPath = finalPath; InquiryDetails objIQ = new InquiryDetails(); objIQ.InquiryID = intQuoId; objIQ.ImagePath = strImgFinalPath; objIQ.VideoPath = strVidFinalPath; objService.UpdateInquiryImages(objIQ); #endregion #region .. GET CUSTOMER CITY AND ZIPCODE .. string strCusCity = ""; string strCusZipcode = ""; string strVACity = ""; string strVAZipcode = ""; DataTable dtCus = objService.GetCustomerById(Convert.ToInt32(Session["LoginId"].ToString())); if (dtCus.Rows.Count > 0) { strCusCity = dtCus.Rows[0]["CityName"].ToString(); strCusZipcode = dtCus.Rows[0]["ZipCode"].ToString(); } #endregion DataTable dt = objService.SelectVendorByCategory(objQuiry.CategoryId); if (dt.Rows.Count > 0) { for (int intVen = 0; intVen < dt.Rows.Count; intVen++) { string sVenEmail = dt.Rows[intVen]["VendorEmail"].ToString(); #region .. GET VENDOR AREA .. strVACity = ""; strVAZipcode = ""; DataTable dtVenArea = objService.SelectAreaByVendorId(Convert.ToInt32(dt.Rows[intVen]["VendorID"].ToString())); if (dtVenArea.Rows.Count > 0) { for (int k = 0; k < dtVenArea.Rows.Count; k++) { strVACity = dtVenArea.Rows[k]["VACityName"].ToString(); strVAZipcode = dtVenArea.Rows[k]["VAZipcode"].ToString(); if (strVAZipcode == strCusZipcode) { VendorMessageDetails objVenMsgDet = new VendorMessageDetails(); objVenMsgDet.VendorMessageId = 0; objVenMsgDet.VendorId = Convert.ToInt32(dt.Rows[intVen]["VendorID"].ToString()); objVenMsgDet.SendCustomerId = objQuiry.CustomerId; objVenMsgDet.QuiryId = intQuoId; objVenMsgDet.CategoryId = Convert.ToInt32(objQuiry.CategoryId); objVenMsgDet.MessageTitle = txtQuoteTitle.Value.ToString(); objVenMsgDet.Description = txtQuoteDesc.Value.ToString(); objVenMsgDet.Status = "0"; int intVenMsg = objService.AddVendorMessage(objVenMsgDet); } } } #endregion } } divErrorMessage.InnerHtml = ""; divMessage.InnerHtml = "Your Inquiry posted sucessfully."; txtQuoteTitle.Value = ""; txtQuoteDesc.Value = ""; ddlCategory.SelectedIndex = 0; } else { divErrorMessage.InnerHtml = strErrorMsg; } }
public void UpdateInquiryImages(InquiryDetails quiryDetails) { try { DALComponent objDAL = new DALComponent(); objDAL.SetParameters("@inquiryId", SqlDbType.Int, 4, quiryDetails.InquiryID); objDAL.SetParameters("@imagepath", SqlDbType.VarChar, 500, quiryDetails.ImagePath); objDAL.SetParameters("@videopath", SqlDbType.VarChar, 200, quiryDetails.VideoPath); objDAL.SqlCommandText = "[UpdateInquiryImages]"; int x = objDAL.UpdateRecord(); } catch (SqlException sqlEx) { throw new ApplicationException("Data error=" + sqlEx.Message.ToString()); } catch (Exception ex) { throw new ApplicationException("Error=" + ex.Message.ToString()); } }