private void LoadPhnNoFromMaterial(Int64 id)
 {
     using (MaterialRT adGRt = new MaterialRT())
     {
         var adGiver = adGRt.GetMaterialByIID(id);
         var loc     = adGRt.GetLocationByMaterialIID(id);
         lblLocation.Text = loc.ToString();
         if (adGiver.UserPhoneNumber != null && adGiver.UserEmail == null)
         {
             lblContactNumber.Text = "Phone No. " + adGiver.UserPhoneNumber.Substring(0, 5) + "XXXXXX";
         }
         else if (adGiver.UserEmail != null && adGiver.UserPhoneNumber == null)
         {
             lblContactNumber.Text = "Email: " + adGiver.UserEmail.Substring(0, 5) + "XXXXXXXXXXX";
         }
         else if (adGiver.UserEmail != null && adGiver.UserPhoneNumber != null)
         {
             lblContactNumber.Text      = "Phone No. " + adGiver.UserPhoneNumber.Substring(0, 5) + "XXXXXX";
             lblEmail.Text              = "Email: " + adGiver.UserEmail.Substring(0, 5) + "XXXXXXXXXXX";
             lnkContact.CommandArgument = adGiver.IID.ToString();
         }
         else
         {
             lnkContact.CommandArgument = adGiver.IID.ToString();
         }
     }
 }
        protected void LoadGoogleMAP(Int64 locationID)
        {
            MaterialRT _materialRT = new MaterialRT();

            try
            {
                List <ProgramAddresses> AddressList = new List <ProgramAddresses>();
                string FullAddress = _materialRT.GetLocationByIID(locationID);

                //  string FullAddress=null;
                ProgramAddresses MapAddress = new ProgramAddresses();
                MapAddress.description = FullAddress;
                var locationService = new GoogleLocationService();
                var point           = locationService.GetLatLongFromAddress(FullAddress);
                MapAddress.lat = point.Latitude;
                MapAddress.lng = point.Longitude;
                AddressList.Add(MapAddress);
                string jsonString = new JavaScriptSerializer().Serialize(AddressList);
                //JsonSerializer<List<ProgramAddresses>>(AddressList);
                ScriptManager.RegisterArrayDeclaration(Page, "markers", jsonString);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "GoogleMap();", true);
            }

            catch (Exception ex)
            {
                LogFileWritten(ex.Message, ex.StackTrace);
            }
        }
Exemple #3
0
        private Material CreateMaterial()
        {
            Session["UserID"] = "1";
            Material material = new Material();

            try
            {
                using (MaterialRT receiverTransfer = new MaterialRT())
                {
                    if (hdIsEdit.Value == "true")
                    {
                        material.IID = Convert.ToInt32(hdMaterialID.Value);
                    }
                    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         = GetCodeForMaterial();
                    material.Description  = txtDescription.Text.Trim();
                    material.IsFeatured   = chkIsFeatured.Checked;
                    material.IsSpotlight  = chkIsSpotlight.Checked;
                    material.IsUrgent     = chkIsUrgent.Checked;
                    material.LocationID   = Convert.ToInt64(txtLocation.Text);
                    material.CategoryID   = Convert.ToInt32(txtCategory.Text);
                    material.ModelID      = Convert.ToInt64(txtModel.Text);
                    material.BrandID      = Convert.ToInt64(txtModel.Text);
                    material.ColorID      = Convert.ToInt64(txtColor.Text);
                    material.Price        = Convert.ToDecimal(txtPrice.Text);
                    material.TotalVisitor = 0;


                    material.AdDate            = Convert.ToDateTime(txtDate.Text);
                    material.AdDisplayLastDate = Convert.ToDateTime(txtDisplayLastDate.Text);

                    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);
        }
Exemple #4
0
 public DefaultInner()
 {
     this._materialRT          = new MaterialRT();
     this._categoryRT          = new CategoryRT();
     this._visitorIPMACAddress = new VisitorIPMACAddress();
     this._countryRT           = new CountryRT();
     this._divisionOrStateRT   = new DivisionOrStateRT();
 }
Exemple #5
0
        protected void btnPostAd_Click(object sender, EventArgs e)
        {
            try
            {
                using (MaterialRT receiverTransfer = new MaterialRT())
                {
                    AdGiverRT adGiverRt = new AdGiverRT();
                    string    matCode   = string.Empty;
                    AdGiver   adGiver   = new AdGiver();
                    Material  material  = CreateMaterial();

                    if (material.AdGiverID == -1)
                    {
                        adGiver = CreateAdGiver();
                        if (adGiver != null)
                        {
                            adGiverRt.AddAdGiver(adGiver);
                            material.AdGiverID = adGiverRt.GetAdGiverIDByEmail(adGiver.EmailID).IID;
                            receiverTransfer.AddMaterial(material);
                            matCode = material.Code;
                        }
                    }
                    else
                    {
                        receiverTransfer.AddMaterial(material);
                        matCode = material.Code;
                    }

                    if (material.IID > 0)
                    {
                        labelMessage.Text      = "Your ad successfully posted...and your material code is " + matCode;
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                        ClearField();
                    }
                    else if (adGiver == null)
                    {
                        labelMessage.Text      = "This email already taken...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        labelMessage.Text      = "Data not saved...";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Exemple #6
0
        private string GetCodeForMaterial()
        {
            string   startCode = "000001";
            decimal  newCode   = 0;
            DateTime date      = GlobalRT.GetServerDateTime();

            try
            {
                using (MaterialRT receiverTransfer = new MaterialRT())
                {
                    string lastCode     = receiverTransfer.GetLastCode().ToString();
                    string currentYear  = date.Year.ToString();
                    string currentMonth = date.Month.ToString();
                    if (currentMonth.Length == 1)
                    {
                        currentMonth = 0 + currentMonth;
                    }
                    if (lastCode.Equals("0"))
                    {
                        lastCode = startCode;
                    }
                    string lastCodeYearMonth    = lastCode.Substring(0, 6);
                    string currentCodeYearMonth = currentYear + currentMonth;

                    if (lastCodeYearMonth == currentCodeYearMonth)
                    {
                        newCode = Convert.ToDecimal(lastCode) + 1;
                    }
                    else
                    {
                        newCode = Convert.ToDecimal(currentYear + currentMonth + startCode);
                    }
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
            return(newCode.ToString());
        }
 protected void lnkContact_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "ContactInfo")
     {
         try
         {
             lblContactNumber.Text = string.Empty;
             lblEmail.Text         = string.Empty;
             int DetailID = Convert.ToInt32(e.CommandArgument);
             hdContactInfo.Value = DetailID.ToString();
             using (MaterialRT receiverTransfer = new MaterialRT())
             {
                 Material adGiver = receiverTransfer.GetMaterialByIID(DetailID);
                 if (adGiver.UserPhoneNumber != null && adGiver.UserEmail == null)
                 {
                     lblContactNumber.Text = "Phone No. " + adGiver.UserPhoneNumber;
                 }
                 else if (adGiver.UserEmail != null && adGiver.UserPhoneNumber == null)
                 {
                     lblContactNumber.Text = "Email: " + adGiver.UserEmail;
                 }
                 else if (adGiver.UserEmail != null && adGiver.UserPhoneNumber != null)
                 {
                     lblContactNumber.Text = "Phone No. " + adGiver.UserPhoneNumber;
                     lblEmail.Text         = "Email: " + adGiver.UserEmail;
                 }
                 else
                 {
                     lblContactNumber.Text      = "No Contact Info is provided";
                     lblContactNumber.ForeColor = System.Drawing.Color.CornflowerBlue;
                 }
             }
         }
         catch (Exception ex)
         {
             lblFvrt.Text      = "Error : " + ex.Message;
             lblFvrt.ForeColor = System.Drawing.Color.Red;
         }
     }
 }
Exemple #8
0
        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);
            }
        }
Exemple #9
0
        protected void btnUpdatePost_Click(object sender, EventArgs e)
        {
            try
            {
                hdIsEdit.Value = "true";
                int    imgCount   = 0;
                int    materialID = 0;
                string matCode    = string.Empty;
                if (!TextControlCheckBeforeSave())
                {
                    return;
                }
                Material material = CreateMaterial();
                if (material == null)
                {
                    return;
                }
                List <ControlAdmin.MaterialWF.ImageUrl> matPicUrlList = new List <ControlAdmin.MaterialWF.ImageUrl>();

                btnMatPicUpload_Click(sender, e);

                var matPicListForTempUrl = (List <ControlAdmin.MaterialWF.ImageUrl>)Session["seMatPicTempFileName"];
                matPicUrlList = matPicListForTempUrl.Where(url => url.ImageUrlTemp.StartsWith("~/Image/MatTempImage")).ToList();//Set for temp img update
                List <Picture> pictureColl = new List <Picture>();
                matCode = material.Code;

                if (matPicUrlList.Count == 0)
                {
                    Picture aPicture = new Picture();
                    aPicture.MaterialID = material.IID;
                    string permanentImagePath = new ConstantCollection().noImageUrl;
                    aPicture.UrlAddress = permanentImagePath;
                    pictureColl.Add(aPicture);
                }
                else if (matPicUrlList.Count > 0)
                {
                    int tempImgCount = 0;
                    using (PictureRT aPictureRt = new PictureRT())
                    {
                        try
                        {
                            var imgList = aPictureRt.GetAllPicturesAccordingToMaterialID(material.IID).ToList();
                            if (imgList.Count > 0)
                            {
                                var picCount =
                                    (Path.GetFileNameWithoutExtension(
                                         Server.MapPath(
                                             aPictureRt.GetAllPicturesAccordingToMaterialID(material.IID)
                                             .OrderByDescending(pic => pic.UrlAddress)
                                             .FirstOrDefault()
                                             .UrlAddress)).Substring(13));

                                imgCount     = Convert.ToInt32(picCount) + 1;
                                tempImgCount = imgCount;
                            }
                            else
                            {
                                imgCount = 1;//set image number if no image found
                            }
                        }
                        catch (Exception exception)
                        {
                            throw new Exception(exception.Message, exception);
                        }
                    }

                    foreach (var imageUrl in matPicUrlList)
                    {
                        Picture aPicture = new Picture();
                        aPicture.MaterialID = material.IID;
                        // string permanentImagePathToSave = Server.MapPath("~/Image/MatImage/") + matCode + "_" + count + (Path.GetExtension(imageUrl.ImageUrlTemp));//image path to save folder
                        string permanentImagePath = "~/Image/MatImage/" + matCode + "_" + imgCount + (Path.GetExtension(Server.MapPath(imageUrl.ImageUrlTemp)));//image path to save db
                        aPicture.UrlAddress = permanentImagePath;
                        // File.Move(Server.MapPath(imageUrl.ImageUrlTemp), permanentImagePathToSave);//move pic to permanent folder from tempPic folder
                        pictureColl.Add(aPicture);
                        imgCount++;
                    }
                    imgCount = tempImgCount;
                }

                if (material.AdGiverID != -1)
                {
                    using (MaterialRT aMaterialRt = new MaterialRT())
                    {
                        aMaterialRt.UpdateMaterial(material);
                    }


                    if (matPicUrlList.Count > 0)
                    {
                        using (PictureRT aPictureRt = new PictureRT())
                        {
                            foreach (var pic in pictureColl)
                            {
                                aPictureRt.AddMaterialPicture(pic);
                            }
                        }


                        foreach (var imageUrl in matPicUrlList)
                        {
                            Picture aPicture = new Picture();
                            aPicture.MaterialID = material.IID;
                            string permanentImagePathToSave = Server.MapPath("~/Image/MatImage/") + matCode + "_" + imgCount + (Path.GetExtension(imageUrl.ImageUrlTemp)); //image path to save folder
                            string permanentImagePath       = "~/Image/MatImage/" + matCode + "_" + imgCount + (Path.GetExtension(Server.MapPath(imageUrl.ImageUrlTemp))); //image path to save db
                            aPicture.UrlAddress = permanentImagePath;
                            File.Move(Server.MapPath(imageUrl.ImageUrlTemp), permanentImagePathToSave);                                                                    //move pic to permanent folder from tempPic folder
                            imgCount++;
                        }
                    }
                    Session["seMatPicTempFileName"] = null;
                    Response.Redirect("~/ManageYourAds.aspx");
                    //labelMessage.Text = "Your post is successfully added, Your Post Code is " + matCode + " ..!!";
                    //labelMessage.ForeColor = System.Drawing.Color.Green;
                    //labelMessage.Focus();
                    ClearField();
                }
                else
                {
                    labelMessage.Text = String.Format("Please register frist. You can register here. <a href=\"{0}\">{1}</a>",
                                                      HttpUtility.HtmlEncode("UserRegistrationPage.aspx"), HttpUtility.HtmlEncode("Register now"));

                    labelMessage.ForeColor = System.Drawing.Color.Red;
                    labelMessage.Focus();
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
                labelMessage.Focus();
            }
        }
Exemple #10
0
        protected void btnPostAd_Click(object sender, EventArgs e)
        {
            try
            {
                int    materialID = 0;
                string matCode    = string.Empty;
                if (!TextControlCheckBeforeSave())
                {
                    return;
                }
                Material material = CreateMaterial();
                if (material == null)
                {
                    return;
                }
                List <ImageUrl> matPicUrlList = new List <ImageUrl>();
                if (MatPicUpload.HasFile)
                {
                    btnMatPicUpload_Click(sender, e);
                }
                //else
                //{
                //    labelMessage.Text = "Select Image";

                //}

                matPicUrlList = (List <ImageUrl>)Session["seMatPicTempFileName"];
                List <Picture> pictureColl = new List <Picture>();
                matCode = material.Code;
                if (matPicUrlList == null)
                {
                    Picture aPicture = new Picture();
                    aPicture.MaterialID = material.IID;
                    string permanentImagePath = new ConstantCollection().noImageUrl;
                    aPicture.UrlAddress = permanentImagePath;
                    pictureColl.Add(aPicture);
                }
                else if (matPicUrlList.Count > 0)
                {
                    int count = 1;
                    foreach (var imageUrl in matPicUrlList)
                    {
                        Picture aPicture = new Picture();
                        aPicture.MaterialID = material.IID;
                        string permanentImagePathToSave = Server.MapPath("~/Image/MatImage/") + matCode + "_" + count + (Path.GetExtension(imageUrl.ImageUrlTemp)); //image path to save folder
                        string permanentImagePath       = "~/Image/MatImage/" + matCode + "_" + count + (Path.GetExtension(Server.MapPath(imageUrl.ImageUrlTemp))); //image path to save db
                        aPicture.UrlAddress = permanentImagePath;
                        // File.Move(Server.MapPath(imageUrl.ImageUrlTemp), permanentImagePathToSave);//move pic to permanent folder from tempPic folder
                        pictureColl.Add(aPicture);
                        count++;
                    }
                }



                if (material.AdGiverID != -1)
                {
                    string materialAllChildXML = ConversionXML.ConvertObjectToXML <Material, Picture>(material, pictureColl, string.Empty);
                    materialID = MaterialRT.InsertMaterialAndAllChildXML(materialAllChildXML);

                    if (materialID == -100)
                    {
                        labelMessage.Text      = "Network connection fail ... Please try again..!!";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                    else if (materialID == -101)
                    {
                        labelMessage.Text      = "Network connection fail ... Please try again..!!";
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                    else if (materialID > 0)
                    {
                        if (matPicUrlList.Count > 0)
                        {
                            int count = 1;
                            foreach (var imageUrl in matPicUrlList)
                            {
                                Picture aPicture = new Picture();
                                aPicture.MaterialID = material.IID;
                                string permanentImagePathToSave = Server.MapPath("~/Image/MatImage/") + matCode + "_" + count + (Path.GetExtension(imageUrl.ImageUrlTemp)); //image path to save folder
                                string permanentImagePath       = "~/Image/MatImage/" + matCode + "_" + count + (Path.GetExtension(Server.MapPath(imageUrl.ImageUrlTemp))); //image path to save db
                                aPicture.UrlAddress = permanentImagePath;
                                File.Move(Server.MapPath(imageUrl.ImageUrlTemp), permanentImagePathToSave);                                                                 //move pic to permanent folder from tempPic folder
                                count++;
                            }
                        }


                        labelMessage.Text      = "Your post is successfully added, Your Post Code is " + matCode + " ..!!";
                        labelMessage.ForeColor = System.Drawing.Color.Green;
                        ClearField();
                    }
                }
                else
                {
                    labelMessage.Text = String.Format("Please register first. You can register here. <a href=\"{0}\">{1}</a>",
                                                      HttpUtility.HtmlEncode("UserRegistrationPage.aspx"), HttpUtility.HtmlEncode("Register now"));

                    labelMessage.ForeColor = System.Drawing.Color.Red;
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Exemple #11
0
        private Material CreateMaterial()
        {
            Material material = new Material();

            try
            {
                using (MaterialRT receiverTransfer = new MaterialRT())
                {
                    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(dropdownPoliceStation.SelectedValue))
                    {
                        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(txtEmail.Text) : null;
                        material.AdGiverID = adGiver != null ? adGiver.IID : -1;
                        material.AdTypeID  = adGiver.ClientTypeID;
                    }
                    if (txtEmail.Text != string.Empty && txtPhoneNumber.Text != string.Empty)
                    {
                        material.UserEmail       = txtEmail.Text;
                        material.UserPhoneNumber = txtPhoneNumber.Text;
                    }
                    else if (txtEmail.Text == string.Empty && txtPhoneNumber.Text != string.Empty)
                    {
                        material.UserEmail       = null;
                        material.UserPhoneNumber = txtPhoneNumber.Text;
                    }
                    else if (txtEmail.Text != string.Empty && txtPhoneNumber.Text == string.Empty)
                    {
                        material.UserEmail       = txtEmail.Text;
                        material.UserPhoneNumber = null;
                    }
                    //else
                    //{
                    //    material.UserEmail =null;
                    //    material.UserPhoneNumber = null;

                    //}
                    material.Code        = GetCodeForMaterial();
                    material.Description = Server.HtmlEncode(txtDescription.Text);
                    material.IsFeatured  = chkIsFeatured.Checked;
                    material.IsSpotlight = chkIsSpotlight.Checked;
                    material.IsUrgent    = chkIsUrgent.Checked;

                    //for dropdown
                    if (txtLocation.Text != "" || txtLocation.Text != string.Empty)
                    {
                        using (LocationRT aLocationRt = new LocationRT())
                        {
                            Location aLocation = new Location();
                            aLocation.CurrentLocation = txtLocation.Text;
                            aLocation.DistrictID      = Convert.ToInt64(dropdownDistrict.SelectedValue);
                            aLocation.PoliceStationID = Convert.ToInt64(dropdownPoliceStation.SelectedValue);
                            aLocation.CountryID       = Convert.ToInt32(hdCountryID.Value);
                            aLocation.CurrentLocation = txtLocation.Text;
                            aLocationRt.AddLocation(aLocation);
                            material.LocationID = aLocation.IID;
                        }
                    }


                    //if (txtLocationID.Text != "" || txtLocationID.Text != string.Empty)
                    //{
                    //    material.LocationID = Convert.ToInt64(txtLocationID.Text);
                    //}
                    //else
                    //{
                    //    try
                    //    {
                    //        using (LocationRT aLocationRt = new LocationRT())
                    //        {
                    //            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.Value != string.Empty || txtModelID.Value != "")
                    {
                        material.ModelID = Convert.ToInt64(txtModelID.Value);
                    }
                    if (txtBrandID.Value != string.Empty || txtBrandID.Value != "")
                    {
                        material.BrandID = Convert.ToInt64(txtBrandID.Value);
                    }
                    if (txtColorID.Value != string.Empty || txtColorID.Value != "")
                    {
                        material.ColorID = Convert.ToInt64(txtColorID.Value);
                    }
                    material.IsNegotiablePrice = chkNegotiable.Checked;
                    material.WebSiteUrl        = txtWeburl.Text;
                    material.YoutubeUrl        = txtYoutubeUrl.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);
        }