Ejemplo n.º 1
0
        protected void btnDeactive_Click(object sender, EventArgs e)
        {
            try
            {
                using (AdGiverRT receiverTransfer = new AdGiverRT())
                {
                    string  userEmailId    = Convert.ToString(Session["UserName"]);
                    AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);

                    if (adgiverEmailId != null)
                    {
                        using (UserInformationRT receiverTransferuserinfo = new UserInformationRT())
                        {
                            UserInfo UserDeactive = CreateUserDeactive();
                            receiverTransferuserinfo.UpdateUserDeactive(userEmailId, UserDeactive.Comments, UserDeactive.LeavingCausesID, UserDeactive.IsActiveUser);
                            Session["UserName"] = null;
                            Response.Redirect("~/");
                        }
                    }
                    else
                    {
                        lblAccountdetails.Text      = "Account is not Deactivated Yet";
                        lblAccountdetails.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            catch (Exception ex)
            {
                lblAccountdetails.Text      = "Error : " + ex.Message;
                lblAccountdetails.ForeColor = System.Drawing.Color.Red;
            }
        }
Ejemplo n.º 2
0
        public AdGiver CreateAdGiver()
        {
            AdGiver adgiver = new AdGiver();

            try
            {
                using (AdGiverRT adGiverRt = new AdGiverRT())
                {
                    bool IsThisEmailAlreadyExist = adGiverRt.GetAdGiverIDByEmail(txtEmail.Text) != null;
                    if (IsThisEmailAlreadyExist)
                    {
                        return(null);
                    }

                    adgiver.Name         = txtAdGiverName.Text;
                    adgiver.ClientTypeID = Convert.ToInt32(dropDownClientType.SelectedValue);
                    adgiver.NationalID   = txtNationalID.Text;
                    adgiver.CompanyOrOrganizationName = txtCompanyName.Text;
                    adgiver.ComOrOrgAddress           = txtCompanyAddress.Text;
                    adgiver.ComOrOrgPhone             = txtCompanyPhoneNo.Text;
                    adgiver.EmailID    = txtEmail.Text;
                    adgiver.PhoneNo1   = txtContactNo.Text;
                    adgiver.PhoneNo2   = txtPhNoOptional.Text;
                    adgiver.LocationID = Convert.ToInt32(txtLocation.Text);
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
            return(adgiver);
        }
Ejemplo n.º 3
0
 protected void btnChngPass_Click(object sender, EventArgs e)
 {
     try
     {
         using (AdGiverRT receiverTransfer = new AdGiverRT())
         {
             string  userEmailId    = Convert.ToString(Session["UserName"]);
             string  password       = txtCurrentPass.Text;
             AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);
             string  UserpassWord   = StringCipher.Decrypt(receiverTransfer.GetPasswordIDByEmail(userEmailId).LoginPassword);
             if (adgiverEmailId != null && UserpassWord == password)
             {
                 using (UserInformationRT receiverTransferuserinfo = new UserInformationRT())
                 {
                     UserInfo UserInfoPassword = CreateUserInfoPassword();
                     receiverTransferuserinfo.UpdateUserInfoPassword(userEmailId, StringCipher.Encrypt(UserInfoPassword.LoginPassword));
                     lblAccountdetails.Text      = "Password successfully updated...";
                     lblAccountdetails.ForeColor = System.Drawing.Color.Green;
                 }
             }
             else
             {
                 lblAccountdetails.Text      = "Current Password is not Valid";
                 lblAccountdetails.ForeColor = System.Drawing.Color.Red;
             }
         }
     }
     catch (Exception ex)
     {
         lblAccountdetails.Text      = "Error : " + ex.Message;
         lblAccountdetails.ForeColor = System.Drawing.Color.Red;
     }
     clearfield();
 }
Ejemplo n.º 4
0
        public object GetAllAdGiverForAdminSearch(string adGiverName)
        {
            List <AdGiver> list = null;

            try
            {
                list = new AdGiverRT().GetAdGiverForAdminMaterialSearch(adGiverName);

                var adGiverList = (from adGiver in list
                                   select new { adGiver.IID, adGiver.EmailID }).ToList();

                return(adGiverList);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (list != null && list.Count > 0)
                {
                    list = list.Take(25).ToList();
                }
            }
            return(null);
        }
        public void RegisteredUserListView()
        {
            try
            {
                using (AddGiverTracingRT receiverTransfer = new AddGiverTracingRT())
                {
                    Int64 userId = Convert.ToInt64(Session["RegistereduserID"]);
                    List <AdGiverTracing> adgivertracing = receiverTransfer.GetAdGiverTracingByIID(userId);

                    if (adgivertracing != null && adgivertracing.Count > 0)
                    {
                        lvRegisteredUserAddGiverTracing.DataSource = receiverTransfer.GetAdGiverTracingListViewByIID(Convert.ToInt64(userId));
                        lvRegisteredUserAddGiverTracing.DataBind();
                        using (AdGiverRT receiverTransferAdgiver = new AdGiverRT())
                        {
                            AdGiver e = receiverTransferAdgiver.GetAdGiverByIID(Convert.ToInt64(userId));
                            labelDisplayName.Text  = "Welcome " + e.Name;
                            labelDisplayEmail.Text = "Your Email Address : " + e.EmailID;
                            labellistview.Text     = e.Name + "'s Add Giver Tracing Information";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                labelMessageRegisteredUserAddGiverTracing.Text      = "Error : " + ex.Message;
                labelMessageRegisteredUserAddGiverTracing.ForeColor = System.Drawing.Color.Red;
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            try
            {
                using (AdGiverRT receiverTransfer = new AdGiverRT())
                {
                    string  userEmailId    = Convert.ToString(Session["UserName"]);
                    AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);

                    if (adgiverEmailId != null)
                    {
                        AdGiver adGiverNamePhn = CreateadGiverNamePhn();
                        receiverTransfer.UpdateadGiverAccNamePhn(userEmailId, adGiverNamePhn.Name, adGiverNamePhn.PhoneNo1);
                        lblAccountdetails.Text      = "Name and Phone No. successfully updated...";
                        lblAccountdetails.ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        lblAccountdetails.Text      = "Name and Phone No. not updated...";
                        lblAccountdetails.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            catch (Exception ex)
            {
                lblAccountdetails.Text      = "Error : " + ex.Message;
                lblAccountdetails.ForeColor = System.Drawing.Color.Red;
            }
            //clearfield();
            showUserNamePhn();
        }
Ejemplo n.º 8
0
        private void LoadMaterial(string catID, string userID, string matCode, string fromDate, string toDate)
        {
            using (MaterialAdGiverRT receiverTransfer = new MaterialAdGiverRT())
            {
                Int64?categoryID;

                DateTime?fD;
                DateTime?tD;


                if (catID != string.Empty || catID != "")
                {
                    categoryID = Convert.ToInt32(catID);
                }
                else
                {
                    categoryID = null;
                }

                if (matCode == string.Empty || matCode == "")
                {
                    matCode = null;
                }

                if (fromDate != string.Empty || fromDate != "")
                {
                    fD = Convert.ToDateTime(fromDate);
                }
                else
                {
                    fD = null;
                }

                if (toDate != string.Empty || toDate != "")
                {
                    tD = Convert.ToDateTime(toDate);
                }
                else
                {
                    tD = null;
                }

                var matList = receiverTransfer.GetSearchedMaterialsForListView(categoryID, userID, matCode, fD, tD);
                if (matList == null)
                {
                    return;
                }

                using (AdGiverRT adGiverRt = new AdGiverRT())
                {
                    string name = adGiverRt.GetAdGiverIDByEmail(Session["UserName"].ToString()).Name;
                    labelAdCount.Text = " Hi " + name + ", you currently have " + matList.Count + " adverts";
                }

                lvMaterial.DataSource = matList;
                lvMaterial.DataBind();
            }
        }
        protected void btn_CreateAccount_Click(object sender, EventArgs e)
        {
            try
            {
                using (AdGiverRT adGiverRt = new AdGiverRT())
                {
                    UserInformationRT aUserInformationRt = new UserInformationRT();
                    UserInfo          aUserInfo          = new UserInfo();
                    AdGiver           adGiver            = new AdGiver();
                    adGiver = CreateAdGiver();
                    if (adGiver != null)
                    {
                        // const int userInGroup = 7; //for addgiver
                        adGiverRt.AddAdGiver(adGiver);
                        aUserInfo = CreateUserInfo(adGiver.IID);
                        aUserInformationRt.AddUserInfo(aUserInfo);
                    }
                    else
                    {
                        if (txtPassword.Text == string.Empty || txtPassword.Text == "")
                        {
                            labelMessage.Text = "Please enter your password";
                        }
                        else if (txtConfirmPassword.Text == "" || txtConfirmPassword.Text == string.Empty)
                        {
                            labelMessage.Text = "Please comfirm your password";
                        }
                        else if (txtPassword.Text != txtConfirmPassword.Text)
                        {
                            labelMessage.Text = "password doesn't match";
                        }
                        else if (txtPassword.Text.Length < 6)
                        {
                            labelMessage.Text = "password too short, enter at least 6 character";
                        }
                        else
                        {
                            labelMessage.Text = string.Format("The email address {0} already registered ",
                                                              txtEmail.Text.Trim());
                        }
                        labelMessage.ForeColor = System.Drawing.Color.Red;
                        //ClearField();
                        return;
                    }

                    labelMessage.Text      = "you have registered successfully...and your user ID is " + adGiver.EmailID;
                    labelMessage.ForeColor = System.Drawing.Color.Green;
                    ClearField();
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Ejemplo n.º 10
0
        protected void lvMyfvrt_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteMyfvrt")
            {
                try
                {
                    lblMyfabourite.Text = string.Empty;

                    int MyfabouriteID = Convert.ToInt32(e.CommandArgument);
                    hdmyfvrt.Value = MyfabouriteID.ToString();
                    using (MyFavouriteRT receiverTransfer = new MyFavouriteRT())
                    {
                        receiverTransfer.DeleteMyfabourite(MyfabouriteID);
                        lblMyfabourite.Text      = "Data successfully deleted...";
                        lblMyfabourite.ForeColor = System.Drawing.Color.Green;
                    }
                }
                catch (Exception ex)
                {
                    lblMyfabourite.Text      = "Error : " + ex.Message;
                    lblMyfabourite.ForeColor = System.Drawing.Color.Red;
                }
            }

            else if (e.CommandName == "EditMyfvrt")
            {
                try
                {
                    using (AdGiverRT receiverTransfer = new AdGiverRT())
                    {
                        lblMyfabourite.Text = string.Empty;
                        string  userEmailId    = Convert.ToString(Session["UserName"]);
                        AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);

                        using (MyFavouriteRT receiverTransferMyfvrt = new MyFavouriteRT())
                        {
                            //int MaterialID = Convert.ToInt32(Request.QueryString["ID"]);
                            List <MyFavourite> EmailIDfrmMyfvrt = receiverTransferMyfvrt.GetEmailIDfrmMyfvrt(userEmailId);

                            if (adgiverEmailId.EmailID != null && EmailIDfrmMyfvrt != null && EmailIDfrmMyfvrt.Count > 0)
                            {
                                int         UrlID = Convert.ToInt32(e.CommandArgument);
                                MyFavourite url   = receiverTransferMyfvrt.GetUrlFrmMyfvrt(UrlID);
                                Response.Redirect("DetailPage?option=" + StringCipher.Encrypt(url.MaterialID.ToString()));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    lblMyfabourite.Text      = "Error : " + ex.Message;
                    lblMyfabourite.ForeColor = System.Drawing.Color.Red;
                }
            }
        }
Ejemplo n.º 11
0
        private void LoadAdGiver()
        {
            using (AdGiverRT adGRt = new AdGiverRT())
            {
                string Email   = Session["UserName"].ToString();
                var    adGiver = !txtUserID.Text.IsNullOrWhiteSpace() ? adGRt.GetAdGiverIDByEmail(Email) : null;

                TxtName.Text = adGiver.Name.Trim();

                //  lblAdGiverInfo.Text = "Please select at least one option to be contacted by.";
            }
        }
Ejemplo n.º 12
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;
            }
        }
Ejemplo n.º 13
0
        protected void btnFvrt_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["UserName"] == null)
                {
                    Response.Redirect("~/LoginPage");
                }
                else
                {
                    using (AdGiverRT receiverTransfer = new AdGiverRT())
                    {
                        string  userEmailId    = Convert.ToString(Session["UserName"]);
                        AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);

                        if (adgiverEmailId != null)
                        {
                            using (MyFavouriteRT receiverTransferMyfvrt = new MyFavouriteRT())
                            {
                                int         MaterialID         = Convert.ToInt32(Session["detailID"]);
                                MyFavourite EmailIDnMaterialID = receiverTransferMyfvrt.GetEmailIDnMaterialID(userEmailId, MaterialID);
                                MyFavourite myFvrt             = CreatemyFavrt();
                                if (EmailIDnMaterialID == null)
                                {
                                    receiverTransferMyfvrt.AddMYFvrt(myFvrt);

                                    lblFvrt.Text      = "You Add your Favourite Item Successfully...";
                                    lblFvrt.ForeColor = System.Drawing.Color.DarkSlateBlue;
                                }
                                else
                                {
                                    lblFvrt.Text      = "This Item is already added to your Favourite...";
                                    lblFvrt.ForeColor = System.Drawing.Color.Red;
                                }
                            }
                        }
                        else
                        {
                            lblFvrt.Text      = "Data not Added...";
                            lblFvrt.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblFvrt.Text      = "Error : " + ex.Message;
                lblFvrt.ForeColor = System.Drawing.Color.Red;
            }
        }
Ejemplo n.º 14
0
        private void LoadRegisteredUserListView(string email, string StartDate, string endDate)
        {
            try
            {
                using (AdGiverRT receiverTransfer = new AdGiverRT())
                {
                    string   userID;
                    DateTime?SD;
                    DateTime?ED;
                    if (email != string.Empty || email != "")
                    {
                        userID = email;
                    }
                    else
                    {
                        userID = null;
                    }

                    if (StartDate.ToString() != string.Empty || StartDate.ToString() != "")
                    {
                        //IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("pl-PL", true);
                        SD = Convert.ToDateTime(StartDate);
                        //SD = DateTime.ParseExact(StartDate, "yyyy-MM-dd", theCultureInfo);
                    }
                    else
                    {
                        SD = null;
                    }

                    if (endDate.ToString() != string.Empty || endDate.ToString() != "")
                    {
                        ED = Convert.ToDateTime(endDate);
                    }
                    else
                    {
                        ED = null;
                    }
                    lvRegisteredUser.DataSource = receiverTransfer.GetRegisteredUserListView(userID, SD, ED);
                    lvRegisteredUser.DataBind();
                }
            }
            catch (Exception ex)
            {
                labelMessageRegisteredUser.Text      = "Error : " + ex.Message;
                labelMessageRegisteredUser.ForeColor = System.Drawing.Color.Red;
            }
        }
Ejemplo n.º 15
0
 private void showUserNamePhn()
 {
     try
     {
         using (AdGiverRT receiverTransfer = new AdGiverRT())
         {
             string  userEmailId    = Convert.ToString(Session["UserName"]);
             AdGiver adgiverEmailId = receiverTransfer.GetAdGiverIDByEmail(userEmailId);
             var     info           = receiverTransfer.GetAdGiverNamePhnByEmail(userEmailId);
             if (adgiverEmailId != null)
             {
                 txtfName.Text = info[0].firstname;
                 txtlName.Text = info[0].lastname;
                 txtpNo.Text   = info[0].PhoneNo1;
             }
         }
     }
     catch (Exception ex)
     {
         lblAccountdetails.Text      = "Error : " + ex.Message;
         lblAccountdetails.ForeColor = System.Drawing.Color.Red;
     }
 }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
0
        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);
        }
        //private void LoadClientTypeDropDownInfo()
        //{
        //    try
        //    {
        //        DropDownListHelper.Bind(dropDownClientType, EnumHelper.EnumToList<EnumCollection.ClientType>());
        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception(ex.Message, ex);
        //    }
        //}

        public AdGiver CreateAdGiver()
        {
            AdGiver adgiver = new AdGiver();

            try
            {
                using (AdGiverRT adGiverRt = new AdGiverRT())
                {
                    bool IsThisEmailAlreadyExist = adGiverRt.GetAdGiverIDByEmail(txtEmail.Text) != null;
                    if (txtPassword.Text.Length < 6 || IsThisEmailAlreadyExist || (txtPassword.Text != txtConfirmPassword.Text) || txtPassword.Text == string.Empty || txtPassword.Text == "" || txtConfirmPassword.Text == "" || txtConfirmPassword.Text == string.Empty)
                    {
                        return(null);
                    }

                    adgiver.Name         = txtFirstName.Text + " " + txtLastname.Text;
                    adgiver.ClientTypeID = Convert.ToInt32(dropDownClientType.SelectedValue);

                    //if (txtNationalID.Text != "" && txtNationalID.Text != string.Empty)
                    //{
                    //    adgiver.NationalID = txtNationalID.Text;
                    //}

                    if (adgiver.ClientTypeID == Convert.ToInt32(EnumCollection.ClientType.OrganiztionOrCompany))
                    {
                        //adgiver.CompanyOrOrganizationName = txtCompanyName.Text;
                        //adgiver.ComOrOrgAddress = txtCompanyAddress.Text;
                        //adgiver.ComOrOrgPhone = txtCompanyPhoneNo.Text;
                    }

                    adgiver.EmailID  = txtEmail.Text;
                    adgiver.PhoneNo1 = txtContactNo.Text;

                    //if (txtNationalID.Text != "" && txtNationalID.Text != string.Empty)
                    //{
                    //    //adgiver.PhoneNo2 = txtPhNoOptional.Text;
                    //}


                    //if (txtLocationID.Text != "" || txtLocationID.Text != string.Empty)
                    //{
                    //    adgiver.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);
                    //            adgiver.LocationID = aLocation.IID;
                    //        }
                    //    }
                    //}
                    //catch (Exception exception)
                    //{
                    //    throw new Exception(exception.Message, exception);
                    //}

                    //}
                }
            }
            catch (Exception ex)
            {
                labelMessage.Text      = "Error : " + ex.Message;
                labelMessage.ForeColor = System.Drawing.Color.Red;
            }
            return(adgiver);
        }