public object GetLocationForSearch(string locationName, string policeStationId, string districtId, string countryID) { try { var locationList = new LocationRT().GetLocationForSearch(locationName, policeStationId, districtId, countryID); return(locationList); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public object GetDistrictForSearch(string districtName, string countryID) { try { var districtList = new LocationRT().GetDistrictForSearch(districtName, countryID); return(districtList); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void FillMaterialFormForEdit(Int64 materialIID) { try { using (MaterialRT rt = new MaterialRT()) { hdMaterialID.Value = materialIID.ToString(); Material material = rt.GetMaterialByIID(materialIID); if (material == null) { Response.Redirect("~/ManageYourAds.aspx"); } if (!(material.BrandID == 0 || material.BrandID == null)) { txtBrandID.Text = material.BrandID.ToString(); using (BrandRT brandRt = new BrandRT()) { txtBrand.Text = brandRt.GetBrandByID((long)material.BrandID).Name; } } if (!(material.ModelID != 0 || material.ModelID != null)) { using (ModelRT aModelRt = new ModelRT()) { txtModel.Text = aModelRt.GetModelByID((int)material.ModelID).Name; } } if (!(material.ColorID != 0 || material.ColorID != null)) { using (ColorRT aColorRt = new ColorRT()) { txtModel.Text = aColorRt.GetColorByID((int)material.ColorID).Name; } } using (AdGiverRT adGiverRt = new AdGiverRT()) { txtUserID.Text = material.AdGiverID != 0 ? adGiverRt.GetAdGiverByIID((long)material.AdGiverID).EmailID : string.Empty; } txtTitleName.Text = material.TitleName; txtPrice.Text = material.Price.ToString(); txtDescription.Text = material.Description; txtCode.Text = material.Code; txtWeburl.Text = material.WebSiteUrl; txtYoutubeUrl.Text = material.YoutubeUrl; txtPhoneNumber.Text = material.UserPhoneNumber; chkNegotiable.Checked = material.IsNegotiablePrice; dropDownCategory.SelectedValue = material.CategoryID.ToString(); using (LocationRT aLocationRt = new LocationRT()) { txtLocationID.Text = material.LocationID.ToString(); long districtID = 0, policeStationID = 0; string districtName = string.Empty, polStationName = string.Empty, locationName = string.Empty; bool isReceiveInfo = aLocationRt.GetLocationInfoByIID(material.LocationID, ref districtID, ref districtName, ref policeStationID, ref polStationName, ref locationName); if (isReceiveInfo) { txtDistrictID.Text = districtID.ToString(); txtDistrict.Text = districtName.ToString(); txtPoliceStationID.Text = policeStationID.ToString(); txtPoliceStation.Text = polStationName.ToString(); txtLocation.Text = locationName.ToString(); } } DateTime addDate = material.AdDate; DateTime adDisplayLastDate = (DateTime)(material.AdDisplayLastDate ?? material.AdDate); int adDisplayTotalDate = (int)(adDisplayLastDate - addDate).TotalDays; txtPostVisibilityDay.Text = adDisplayTotalDate.ToString(); List <ControlAdmin.MaterialWF.ImageUrl> matPicTempFileUrlList = new List <ControlAdmin.MaterialWF.ImageUrl>(); using (PictureRT aPictureRt = new PictureRT()) { List <Picture> picList = new List <Picture>(); picList = aPictureRt.GetPictureByMaterialIID(Convert.ToInt64(materialIID)); if (picList.Count > 0) { foreach (var picture in picList) { ControlAdmin.MaterialWF.ImageUrl aImageUrl = new ControlAdmin.MaterialWF.ImageUrl(); aImageUrl.ImageUrlTemp = picture.UrlAddress; matPicTempFileUrlList.Add(aImageUrl); } } } Session["seMatPicTempFileName"] = matPicTempFileUrlList; datalistMatPic.DataSource = matPicTempFileUrlList; datalistMatPic.DataBind(); Session[sessMaterial] = material; } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private Material CreateMaterial() { Material material = new Material(); try { if (hdIsEdit.Value == "true") { material.IID = Convert.ToInt32(hdMaterialID.Value); } if (string.IsNullOrEmpty(txtLocation.Text.Trim())) { labelMessage.Text = "Please enter location"; return(null); } if (string.IsNullOrEmpty(txtDistrict.Text.Trim()) || string.IsNullOrEmpty(txtDistrictID.Text.Trim())) { labelMessage.Text = "Please enter district"; return(null); } if (string.IsNullOrEmpty(txtPoliceStation.Text.Trim()) || string.IsNullOrEmpty(txtPoliceStationID.Text.Trim())) { labelMessage.Text = "Please enter police station"; return(null); } material.TitleName = txtTitleName.Text.Trim(); using (AdGiverRT adGRt = new AdGiverRT()) { var adGiver = !txtUserID.Text.IsNullOrWhiteSpace() ? adGRt.GetAdGiverIDByEmail(txtUserID.Text) : null; material.AdGiverID = adGiver != null ? adGiver.IID : -1; } material.Code = txtCode.Text; material.Description = txtDescription.Text.Trim(); material.IsFeatured = chkIsFeatured.Checked; material.IsSpotlight = chkIsSpotlight.Checked; material.IsUrgent = chkIsUrgent.Checked; material.IsNegotiablePrice = chkNegotiable.Checked; material.YoutubeUrl = txtYoutubeUrl.Text; material.WebSiteUrl = txtWeburl.Text; material.UserPhoneNumber = txtPhoneNumber.Text; material.UserEmail = txtUserID.Text; using (LocationRT aLocationRt = new LocationRT()) { if (txtLocationID.Text != "" || txtLocationID.Text != string.Empty) { var loc = aLocationRt.GetLocationByIID(Convert.ToInt64(txtLocationID.Text)); if (txtLocation.Text.ToLower() != loc.CurrentLocation.ToLower()) { try { Location aLocation = new Location(); if (txtLocation.Text != "" || txtLocation.Text != string.Empty) { aLocation.CurrentLocation = txtLocation.Text; } aLocation.DistrictID = Convert.ToInt64(txtDistrictID.Text.Trim() != null ? txtDistrictID.Text.Trim() : null); aLocation.PoliceStationID = Convert.ToInt64(txtPoliceStationID.Text.Trim() != null ? txtPoliceStationID.Text.Trim() : null); aLocation.CountryID = Convert.ToInt32(hdCountryID.Value); aLocation.CurrentLocation = txtLocation.Text; aLocationRt.AddLocation(aLocation); material.LocationID = aLocation.IID; } catch (Exception exception) { throw new Exception(exception.Message, exception); } } else { material.LocationID = Convert.ToInt64(txtLocationID.Text); } } else { try { Location aLocation = new Location(); if (txtLocation.Text != "" || txtLocation.Text != string.Empty) { aLocation.CurrentLocation = txtLocation.Text; } aLocation.DistrictID = Convert.ToInt64(txtDistrictID.Text.Trim() != null ? txtDistrictID.Text.Trim() : null); aLocation.PoliceStationID = Convert.ToInt64(txtPoliceStationID.Text.Trim() != null ? txtPoliceStationID.Text.Trim() : null); aLocation.CountryID = Convert.ToInt32(hdCountryID.Value); aLocation.CurrentLocation = txtLocation.Text; aLocationRt.AddLocation(aLocation); material.LocationID = aLocation.IID; } catch (Exception exception) { throw new Exception(exception.Message, exception); } } } material.CategoryID = Convert.ToInt32(dropDownCategory.SelectedValue); //material.CategoryID = Convert.ToInt32(txtCategoryID.Value); if (txtModelID.Text != string.Empty || txtModelID.Text != "") { material.ModelID = Convert.ToInt64(txtModelID.Text); } if (txtBrandID.Text != string.Empty || txtBrandID.Text != "") { material.BrandID = Convert.ToInt64(txtBrandID.Text); } if (txtColorID.Text != string.Empty || txtColorID.Text != "") { material.ColorID = Convert.ToInt64(txtColorID.Text); } material.Price = Convert.ToDecimal(txtPrice.Text.Trim() != string.Empty ? txtPrice.Text.Trim() : "0"); material.TotalVisitor = 0; material.AdDate = GlobalRT.GetServerDateTime(); DateTime date = GlobalRT.GetServerDateTime(); material.AdDisplayLastDate = date.AddDays(Convert.ToDouble(txtPostVisibilityDay.Text.Trim() != string.Empty ? txtPostVisibilityDay.Text.Trim() : "10")); if (material.IID <= 0) { material.CreatedBy = Convert.ToInt64(Session["UserID"]); material.CreatedDate = GlobalRT.GetServerDateTime(); } else { Material mat = (Material)Session[sessMaterial]; material.CreatedBy = mat.CreatedBy; material.CreatedDate = mat.CreatedDate; material.ModifiedBy = Convert.ToInt64(Session["UserID"]); material.ModifiedDate = GlobalRT.GetServerDateTime(); } } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } return(material); }