private void SetFieldsForUpdate(string id)
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                Guid     postId  = new Guid(id);
                var      post    = from p in ctx.tbl_Post where p.PostID == postId select p;
                tbl_Post objPost = post.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();


                this.ddlCommonCountry.SelectedValue   = objPost.LU_tbl_City.LU_tbl_Country.CountryID;
                this.ddlCommonCity.SelectedValue      = objPost.CityID;
                this.ddlCommonCategory.SelectedValue  = objPost.CategoryID;
                this.txtCommonProviderFirstName.Text  = objPost.ProviderFirstName;
                this.txtCommonProviderLastName.Text   = objPost.ProviderLastName;
                this.txtCommonProviderAddress.Text    = objPost.ProviderAddress;
                this.txtCommonProviderEmil.Text       = objPost.ProviderEmail;
                this.txtCommonProviderPhone.Text      = objPost.ProviderPhoneNo;
                this.txtCommonPostingTitle.Text       = objPost.PostTitle;
                this.txtCommonPostingDescription.Text = objPost.PostDescription;
                PSImage.ImageUrl = objPost.ImageUrl + "?id=" + Guid.NewGuid();

                if (objPost.PSTID == "001")
                {
                    rdoCommonSales.Checked = true;
                }
                else
                {
                    rdoCommonService.Checked = true;
                }
                ddlRank.SelectedValue = Convert.ToString(objPost.Rank);
            }
        }
示例#2
0
        private void FillCategoryDropDownBox()
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                List <LU_tbl_Category> categoryListRoot = ctx.LU_tbl_Category.ToList <LU_tbl_Category>().Where(ct => ct.ParentCatID.Trim() == Convert.ToString("0000")).ToList <LU_tbl_Category>();


                foreach (LU_tbl_Category rootCategory in categoryListRoot)
                {
                    ddlCategory.Items.Add(rootCategory.CategoryName);
                    var listItem = ddlCategory.Items.FindByText(rootCategory.CategoryName);
                    listItem.Attributes["disabled"] = "true";

                    listItem.Attributes.Add("style", "font-weight: bold");


                    List <LU_tbl_Category> catListNodeWise = ctx.LU_tbl_Category.ToList <LU_tbl_Category>().Where(ct => ct.ParentCatID.Trim() == rootCategory.CategoryID.ToString()).ToList <LU_tbl_Category>();
                    foreach (LU_tbl_Category cat in catListNodeWise)
                    {
                        string indentSize     = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        string strDisplayName = HttpUtility.HtmlDecode(indentSize) + cat.CategoryName;
                        ddlCategory.Items.Add(new ListItem(strDisplayName, cat.CategoryID));
                    }
                }
            }

            ddlCategory.Items.Insert(0, new ListItem("Select One", "0"));
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (IsValidUpdate())
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    LU_tbl_City cityToBeUpdate = (LU_tbl_City)Session["LU_tbl_City_ToEdit"];

                    cityToBeUpdate.CityName = txtCityForEdit.Text;
                    if (((tbl_User)Session["User"]) != null)
                    {
                        cityToBeUpdate.EditUser = ((tbl_User)Session["User"]).UserID;  // User
                    }
                    cityToBeUpdate.EditDate = DateTime.Now;


                    ctx.LU_tbl_City.Attach(cityToBeUpdate);
                    ctx.Entry(cityToBeUpdate).State = System.Data.Entity.EntityState.Modified;
                    ctx.SaveChanges();

                    this.BindGrid();
                    TabContainer1.ActiveTabIndex = 1;
                    TabPanelEditCity.Visible     = false;
                }
            }
        }
        private bool IsValid()
        {
            if (txtPassword.Text.Trim() != txtConfirmPassword.Text.Trim())
            {
                lblErrorMessage.Text = "Password miss match.";
                MessagePanel.Visible = true;
                return(false);
            }


            if (txtEmail.Text != string.Empty)
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    var             user = from u in ctx.tbl_User where u.LoginName.Trim() == txtEmail.Text.Trim() select u;
                    List <tbl_User> list = user.ToList <tbl_User>();
                    if (list.Count > 0)
                    {
                        lblErrorMessage.Text   = "User already exist";
                        lblSuccessMessage.Text = string.Empty;
                        MessagePanel.Visible   = true;
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            } // End Block

            return(true);
        }
        private bool IsValidUpdate()
        {
            if (txtCityForEdit.Text != string.Empty)
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    var city = from c in ctx.LU_tbl_City where c.CityName.Trim() == txtCityForEdit.Text.Trim() select c;
                    List <LU_tbl_City> list = city.ToList <LU_tbl_City>();
                    if (list.Count > 0)
                    {
                        lblErrorMessage.Text   = "Duplicate city name";
                        lblSuccessMessage.Text = string.Empty;
                        MessagePanel.Visible   = true;
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            else
            {
                lblErrorMessage.Text = "City name can not be empty.";
                return(false);
            }

            return(true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    string   id            = Request.QueryString["ID"];
                    var      posting       = from post in ctx.tbl_Post where post.PostID == new Guid(id) select post;
                    tbl_Post postingDetail = posting.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();

                    lblTitle.Text       = postingDetail.PostTitle.Trim();
                    lblName.Text        = postingDetail.ProviderFirstName + " " + postingDetail.ProviderLastName;
                    lblAddress.Text     = postingDetail.ProviderAddress;
                    lblDescription.Text = postingDetail.PostDescription;
                    lblEmail.Text       = postingDetail.ProviderEmail;
                    lblPhone.Text       = postingDetail.ProviderPhoneNo;
                    if (File.Exists(Server.MapPath(postingDetail.ImageUrl)))
                    {
                        itemImage.ImageUrl = postingDetail.ImageUrl;
                    }
                    else
                    {
                        itemImage.ImageUrl = "/Styles/images/image_not_found.jpg";
                    }
                }
            }
        }
示例#7
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                var user = from u in ctx.tbl_User
                           join p in ctx.tbl_UserPassword on u.UserID equals p.UserID
                           where u.LoginName == txtUserName.Text.Trim() && p.Password == txtPassword.Text.Trim()
                           select u;

                List <tbl_User> userList = user.ToList <tbl_User>();

                if (userList.Count > 0)
                {
                    tbl_User singleUser = userList.FirstOrDefault <tbl_User>();
                    if (singleUser.RoleID.Trim() == "001") // Admin User
                    {
                        Session.Add("User", singleUser);
                        Response.Redirect("AdminPanel.aspx");
                    }
                    else
                    {
                        Session.Add("User", singleUser);
                        Response.Redirect("UserLoggedinHome.aspx");
                    }
                }
                else
                {
                    lblMessage.Text      = "Incorrect UserName/Password.";
                    MessagePanel.Visible = true;
                }
            }
        }
示例#8
0
        private void PopulateTree()
        {
            MSIPortalContext ctx = new MSIPortalContext();

            List <LU_tbl_Category> categoryListRoot = ctx.LU_tbl_Category.ToList <LU_tbl_Category>().Where(ct => ct.ParentCatID.Trim() == Convert.ToString("0000")).ToList <LU_tbl_Category>();

            TreeNode rootNode = new TreeNode("Root");

            rootNode.Value = "0000";
            TreeView1.Nodes.Clear();
            TreeView1.Nodes.Add(rootNode);

            foreach (LU_tbl_Category cat in categoryListRoot)
            {
                TreeNode tn = new TreeNode(cat.CategoryName.ToString());
                List <LU_tbl_Category> catListNodeWise = ctx.LU_tbl_Category.ToList <LU_tbl_Category>().Where(ct => ct.ParentCatID.Trim() == cat.CategoryID.ToString()).ToList <LU_tbl_Category>();

                foreach (LU_tbl_Category catNode in catListNodeWise)
                {
                    TreeNode childNode = new TreeNode(catNode.CategoryName);
                    childNode.Value = catNode.CategoryID;
                    tn.ChildNodes.Add(childNode);
                }
                tn.Value = cat.CategoryID;
                rootNode.ChildNodes.Add(tn);
            }

            rootNode.CollapseAll();
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    try
                    {
                        LU_tbl_City city        = new LU_tbl_City();
                        var         maxId       = ctx.LU_tbl_City.Select(c => c.CityID).Max(); // Select Max Id
                        int         newId       = Convert.ToInt32(maxId) + 1;
                        string      newStringId = newId.ToString("D3");

                        city.CityID   = newStringId;
                        city.CityName = txtCity.Text.Trim();
                        city.EditUser = ((tbl_User)Session["User"]).UserID;
                        city.EditDate = DateTime.Now;

                        ctx.LU_tbl_City.Add(city);
                        ctx.SaveChanges();
                        cpSuccessMessage.Text = "City added successfully";
                        this.BindGrid();
                        cpErrorMessage.Text = string.Empty;
                        txtCity.Text        = string.Empty;
                        txtCity.Focus();
                        MessagePanel.Visible = true;
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
示例#10
0
 public static string ReturnData(string categoryId)
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         LU_tbl_Category category = ctx.LU_tbl_Category.Where(c => c.CategoryID == categoryId).FirstOrDefault();
         return(category.PSTID);
     }
 }
        private void UpdateRank()
        {
            //============Initialize Post Table
            using (MSIPortalContext ctx = new MSIPortalContext())
            {
                //try
                //{
                string   id      = hiddenPostId.Value;
                var      posting = from post in ctx.tbl_Post where post.PostID == new Guid(id) select post;
                tbl_Post objPost = posting.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();

                objPost.Rank = Convert.ToInt32(ddlRank.SelectedValue); // Only Rank WIll Update
                ctx.tbl_Post.Attach(objPost);
                ctx.Entry(objPost).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
                ////---------------After Successful Update Do the following operation
                MessagePanel.Visible = true;
                //lblSuccessMessage.Visible = true;
                //lblSuccessMessage.Text = "Rank updated suffessfully.";
                TabContainer1.ActiveTabIndex = 1;
                TabPanelEditRank.Visible     = false;


                // GEt Parameter for Bind DataGrid
                string cat  = ddlSearchCategory.SelectedValue;
                string city = ddlCity.SelectedValue;
                string type = string.Empty;

                if (rdoProduct.Checked)
                {
                    type = "001";
                }
                else
                {
                    type = "002";
                }

                BinGridData(cat, city, type);
                TabContainer1.ActiveTabIndex = 0;

                //}
                //catch (DbEntityValidationException dbEx)
                //{
                //    foreach (var validationErrors in dbEx.EntityValidationErrors)
                //    {
                //        foreach (var validationError in validationErrors.ValidationErrors)
                //        {
                //            Trace.Write("Property: {0} Error: {1}" + validationError.PropertyName, validationError.ErrorMessage);
                //        }
                //    }
                //}
                //catch (Exception Ex)
                //{


                //}// End of Catch
            }
        }
 private List <tbl_User> FindUserByEmailOnly()
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         var user = from u in ctx.tbl_User
                    where u.LoginName == txtUserEmail.Text.Trim() select u;
         return(user.ToList <tbl_User>());
     }
 }
 private List <tbl_Post> Search(string cat, string city, string type) // Search By Type, City, Category
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         var post = from p in ctx.tbl_Post where p.CategoryID == cat && p.CityID == city && p.PSTID == type && p.Approved == true
                    orderby p.Rank ascending, p.EditDate descending select p;
         return(post.ToList <tbl_Post>());
     }
 }
 private List <tbl_UserPassword> FindPasswordByUserId(Guid userId)
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         var pass = from
                    p in ctx.tbl_UserPassword where  p.UserID == userId select p;
         return(pass.ToList <tbl_UserPassword>());
     }
 }
示例#15
0
        private List<LU_tbl_Country> GetAllCountry()
        {

            using (MSIPortalContext ctx = new MSIPortalContext())
            {

                var list = from country in ctx.LU_tbl_Country select country;
                return list.ToList<LU_tbl_Country>();
            }
        }
示例#16
0
 public List<tbl_Post> PerformGlobalSearchBasicLikeOperation(string searchText) 
 {
     using (MSIPortalContext ctx = new MSIPortalContext()) 
     {
         var result = from post in ctx.tbl_Post where post.PostTitle.Contains(searchText) select post;
         return result.ToList<tbl_Post>();
     
     }
 
 }
示例#17
0
        private List<LU_tbl_City> GetAllCity()
        {

            using (MSIPortalContext ctx = new MSIPortalContext())
            {

                var list = from c in ctx.LU_tbl_City select c;
                return list.ToList<LU_tbl_City>();
            }
        }
示例#18
0
        private List<tbl_Post> GetPostByCountry(string countryName)
        {

            using (MSIPortalContext ctx = new MSIPortalContext())
            {

                var list = from p in ctx.tbl_Post where p.LU_tbl_City.LU_tbl_Country.CountryName == countryName select p;
                return list.ToList<tbl_Post>();
            }
        }
示例#19
0
        private List<tbl_Post> GetPostByCity(string cityName)
        {

            using (MSIPortalContext ctx = new MSIPortalContext())
            {

                var list = from c in ctx.tbl_Post where c.LU_tbl_City.CityName == cityName select c;
                return list.ToList<tbl_Post>();
            }
        }
        protected void LoadCity()
        {
            MSIPortalContext ctx = new MSIPortalContext();

            ddlCity.DataSource     = ctx.LU_tbl_City.ToList <LU_tbl_City>();
            ddlCity.DataTextField  = "CityName";
            ddlCity.DataValueField = "CityID";
            ddlCity.DataBind();
            ddlCity.Items.Insert(0, new ListItem("Select One", "0"));
        }
示例#21
0
        private List<tbl_Post> GetAllPost()
        {

            using (MSIPortalContext ctx = new MSIPortalContext())
            {

                var list = from p in ctx.tbl_Post select p;
                return list.ToList<tbl_Post>();
            }
        }
示例#22
0
 private tbl_Post GetPost()
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         string   id            = Request.QueryString["ID"];
         var      posting       = from post in ctx.tbl_Post where post.PostID == new Guid(id) select post;
         tbl_Post postingDetail = posting.ToList <tbl_Post>().FirstOrDefault <tbl_Post>();
         return(postingDetail);
     }
 }
示例#23
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.ClearMessagePanel();

            if (IsValid())
            {
                using (MSIPortalContext ctx = new MSIPortalContext())
                {
                    try
                    {
                        // Setup User
                        tbl_User user = new tbl_User();
                        user.UserID    = Guid.NewGuid();
                        user.LoginName = txtEmail.Text.Trim();
                        user.FirstName = txtFirstName.Text.Trim();
                        user.LastName  = txtLastName.Text.Trim();
                        user.RoleID    = ddlUserType.SelectedValue;
                        user.CityID    = ddlCity.SelectedValue;
                        user.IsActive  = true;
                        user.EditUser  = ((tbl_User)Session["User"]).UserID;
                        user.EditDate  = DateTime.Now;

                        //Setup Password
                        tbl_UserPassword pass = new tbl_UserPassword();
                        pass.UserID   = user.UserID;
                        pass.Password = txtPassword.Text.Trim();
                        pass.EditUser = ((tbl_User)Session["User"]).UserID;
                        pass.EditDate = DateTime.Now;

                        ctx.tbl_User.Add(user);
                        ctx.tbl_UserPassword.Add(pass);
                        ctx.SaveChanges();
                        this.ClearForm();
                        lblSuccessMessage.Text = "User created successfully.";
                        lblErrorMessage.Text   = string.Empty;
                        MessagePanel.Visible   = true;
                        txtEmail.Focus();
                        this.BindGrid();
                    }
                    catch (DbEntityValidationException dbEx)
                    {
                        foreach (var validationErrors in dbEx.EntityValidationErrors)
                        {
                            foreach (var validationError in validationErrors.ValidationErrors)
                            {
                                Trace.Write("Property: {0} Error: {1}" + validationError.PropertyName, validationError.ErrorMessage);
                            }
                        }
                    }
                    catch (Exception Ex)
                    {
                    }// End of Catch
                }
            }
        }
        private void FillUserLocation()
        {
            MSIPortalContext   ctx         = new MSIPortalContext();
            List <LU_tbl_City> lstLocation = ctx.LU_tbl_City.ToList <LU_tbl_City>();

            ddlUserLocation.DataSource     = lstLocation;
            ddlUserLocation.DataValueField = "CityID";
            ddlUserLocation.DataTextField  = "CityName";
            ddlUserLocation.DataBind();
            ddlUserLocation.Items.Insert(0, new ListItem("Select", "0"));
        }
 private List <tbl_Post> SearchWithoutCity(string type, string county, string cat) // Search By Type, Country, Category // No City Supplied
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         var post = from p in ctx.tbl_Post
                    where p.LU_tbl_City.CountryID == county && p.CategoryID == cat && p.PSTID == type && p.Approved == true
                    orderby p.EditDate descending
                    select p;
         return(post.ToList <tbl_Post>());
     }
 }
 private List <tbl_User> FindUserByEmailAndPassword()
 {
     using (MSIPortalContext ctx = new MSIPortalContext())
     {
         var user = from u in ctx.tbl_User
                    join p in ctx.tbl_UserPassword on u.UserID equals p.UserID
                    where u.LoginName == txtUserEmail.Text.Trim() && p.Password == txtPassword.Text.Trim()
                    select u;
         return(user.ToList <tbl_User>());
     }
 }
        private void FillCommonCity(string CountryId)
        {
            MSIPortalContext   ctx     = new MSIPortalContext();
            List <LU_tbl_City> lstCity = ctx.LU_tbl_City.Where(c => c.CountryID == CountryId).ToList <LU_tbl_City>();

            ddlCommonCity.DataSource     = lstCity;
            ddlCommonCity.DataValueField = "CityID";
            ddlCommonCity.DataTextField  = "CityName";
            ddlCommonCity.DataBind();
            ddlCommonCity.Items.Insert(0, new ListItem("Select One", "0"));
        }
        private void FillAllCity()
        {
            MSIPortalContext   ctx     = new MSIPortalContext();
            List <LU_tbl_City> lstCity = ctx.LU_tbl_City.ToList <LU_tbl_City>();

            ddlCommonCity.DataSource     = lstCity;
            ddlCommonCity.DataValueField = "CityID";
            ddlCommonCity.DataTextField  = "CityName";
            ddlCommonCity.DataBind();
            ddlCommonCity.Items.Insert(0, new ListItem("Select", "0"));
        }
示例#29
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            MSIPortalContext ctx = new MSIPortalContext();
            tbl_Post         ads = new tbl_Post();

            ads.PostTitle       = this.txtTitle.Text;
            ads.PostDescription = this.txtDescription.Text;
            //ads.AdImage = FileUpload1.FileBytes;
            ads.CategoryID = "1";
            ctx.tbl_Post.Add(ads);
            ctx.SaveChanges();
        }
示例#30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                MSIPortalContext ctx = new MSIPortalContext();

                ddlCountry.DataSource     = ctx.LU_tbl_Country.ToList <LU_tbl_Country>();
                ddlCountry.DataTextField  = "CountryName";
                ddlCountry.DataValueField = "CountryID";
                ddlCountry.DataBind();
                ddlCountry.Items.Insert(0, new ListItem("Select One", "0"));
            }
        }