public IHttpActionResult PosttblAddress(tblAddress tblAddress)
        {
            db.tblAddresses.Add(tblAddress);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tblAddress.AddressId }, tblAddress));
        }
        public IHttpActionResult PuttblAddress(int id, tblAddress tblAddress)
        {
            if (id != tblAddress.AddressId)
            {
                return(BadRequest());
            }

            db.Entry(tblAddress).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblAddressExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public void SaveProduct(ProductModel objProductModel) // save category
        {
            tblAddress objtblAddress = new tblAddress()
            {
                Id           = objProductModel.Address.Id,
                AddressLine1 = objProductModel.Address.AddressLine1,
                AddressLine2 = objProductModel.Address.AddressLine2,
                City         = objProductModel.Address.City,
                State        = objProductModel.Address.State,
                Country      = objProductModel.Address.Country
            };


            tblProduct objProduct = new tblProduct() // database class instance
            {
                ID             = objProductModel.Id,
                Name           = objProductModel.Name, // assign model property to daatabase class
                Brand          = objProductModel.Brand,
                ModelNo        = objProductModel.ModelNo,
                Category       = objProductModel.Category,
                Condition      = objProductModel.Condition,
                BuyNowPrice    = (int)objProductModel.BuyNowPrice,
                BidPrice       = (int)objProductModel.BidPrice,
                Quantity       = objProductModel.Quantity,
                AddressID      = objProductModel.AddressId,
                BidEndDateTime = Convert.ToDateTime(objProductModel.BidDateTime),
                ImagePath      = objProductModel.ImagePath,
                AddedByUserId  = (int)objProductModel.AddedByUserId,
                tblAddress     = objtblAddress
            };

            objWITSProjectEntities.tblProduct.Add(objProduct); // add record into database
            objWITSProjectEntities.SaveChanges();              // save the record into table
        }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["ClientID"] == null)
     {
         Session["FromOrder"] = true;
         Response.Redirect("ServiceLogin.aspx");
     }
     if (!IsPostBack)
     {
         InitPage();
         binddata();
         var       DC         = new DataClassesDataContext();
         tblClient ClientData = DC.tblClients.Single(ob => ob.ClientID == Convert.ToInt32(Session["ClientID"]));
         txtfnm.Text     = ClientData.FirstName;
         txtlnm.Text     = ClientData.LastName;
         txtcontact.Text = ClientData.ContactNo;
         txtemail.Text   = ClientData.Email;
         tblAddress AddressData = DC.tblAddresses.Single(ob => ob.AddressID == ClientData.AddressID);
         txtShippingAddress.Text         = AddressData.Address;
         txtShippingAddressLandmark.Text = AddressData.Landmark;
         txtBillingAddress.Text          = AddressData.Address;
         txtBillingAddressLandmark.Text  = AddressData.Landmark;
         //hdnAddress.Value = AddressData.Address + ", " + AddressData.Landmark;
         bindCheckOutData();
         ltrTotalAmount.Text    = TotalAmount.ToString();
         ltrTotalQty.Text       = TotalQuentity.ToString();
         ltrTotalAmountO.Text   = TotalAmount.ToString();
         ltrTotalQtyO.Text      = TotalQuentity.ToString();
         Session["TotalAmount"] = TotalAmount;
     }
 }
Пример #5
0
        ///// <summary>
        ///// Returns a list of PopulationTypes for a given job
        ///// </summary>
        ///// <param name="jobID"></param>
        ///// <returns></returns>
        //public List<tblJobPatientPopulationType> GetJobPatientPopulationTypes(int jobID)
        //{
        //    return dc.tblJobPatientPopulationTypes.Where(x => x.JobID == jobID).ToList();
        //}

        ///// <summary>
        ///// Returns a list of Job Exp types for a given job
        ///// </summary>
        ///// <param name="jobID"></param>
        ///// <returns></returns>
        //public List<tblJobJobExperienceType> GetJobJobExperienceTypes(int jobID)
        //{
        //    return dc.tblJobJobExperienceTypes.Where(x => x.JobID == jobID).ToList();
        //}

        #endregion *** General Fields ***

        #region *** Inserts ***

        /// <summary>
        /// Updates / Inserts new Address
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public int UpsertAddress(tblAddress address)
        {
            if (address.AddressID == 0) //new record
            {
                try
                {
                    dc.tblAddresses.InsertOnSubmit(address);
                    dc.SubmitChanges();
                    return(address.AddressID);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                try
                {
                    var record = dc.tblAddresses.FirstOrDefault(x => x.AddressID == address.AddressID);
                    record = address;
                    dc.SubmitChanges();
                    return(address.AddressID);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Пример #6
0
        public ActionResult DeleteAddressConfirmed(int id)
        {
            tblAddress addressModel = db.tblAddress.Find(id);

            db.tblAddress.Remove(addressModel);
            db.SaveChanges();
            return(RedirectToAction("Address"));
        }
Пример #7
0
        public ActionResult EditAdd(int id)
        {
            TempData["id"] = id;
            tblAddress add = dc.tblAddresses.SingleOrDefault(ob => ob.AddressId == id);

            ViewBag.City = (from ob in dc.CityMasters where ob.ID == add.CityId select ob).Take(1).SingleOrDefault().ID;

            return(View(add));
        }
Пример #8
0
 public ActionResult AddAddress(tblAddress addressModel)
 {
     using (DemirStoreDBEntities dbModel = new DemirStoreDBEntities())
     {
         addressModel.UserId = (int)Session["userID"];
         dbModel.tblAddress.Add(addressModel);
         dbModel.SaveChanges();
         return(RedirectToAction("Address"));
     }
 }
Пример #9
0
 public ActionResult EditAddress(tblAddress addressModel)
 {
     if (ModelState.IsValid)
     {
         addressModel.UserId          = (int)Session["userID"];
         db.Entry(addressModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Address"));
     }
     return(View(addressModel));
 }
        public IHttpActionResult GettblAddress(int id)
        {
            tblAddress tblAddress = db.tblAddresses.Find(id);

            if (tblAddress == null)
            {
                return(NotFound());
            }

            return(Ok(tblAddress));
        }
Пример #11
0
 public ActionResult EditAddress(int?id, tblAddress addressModel)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     addressModel = db.tblAddress.Find(id);
     if (addressModel == null)
     {
         return(HttpNotFound());
     }
     return(View(addressModel));
 }
Пример #12
0
        public AddressModel GetAddressByID(int id) //get address by id
        {
            tblAddress tblAddress = objWITSProjectEntities.tblAddress.Find(id);

            return(new AddressModel()
            {
                Id = tblAddress.Id,
                AddressLine1 = tblAddress.AddressLine1,
                AddressLine2 = tblAddress.AddressLine2,
                City = tblAddress.City,
                State = tblAddress.State,
                Country = tblAddress.Country
            });
        }
        public IHttpActionResult DeletetblAddress(int id)
        {
            tblAddress tblAddress = db.tblAddresses.Find(id);

            if (tblAddress == null)
            {
                return(NotFound());
            }

            db.tblAddresses.Remove(tblAddress);
            db.SaveChanges();

            return(Ok(tblAddress));
        }
Пример #14
0
        public ActionResult DeleteAddress(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblAddress address = db.tblAddress.Find(id);

            if (address == null)
            {
                return(HttpNotFound());
            }
            return(View(address));
        }
Пример #15
0
        public tblAddress ConvertAddress(Address objAddress)
        {
            tblAddress objTblAddress = new tblAddress();

            objTblAddress.AddressID  = objAddress.AddressID;
            objTblAddress.Address1   = objAddress.Address1;
            objTblAddress.Address2   = objAddress.Address2;
            objTblAddress.Address3   = objAddress.Address3;
            objTblAddress.StateID    = objAddress.State.StateID;
            objTblAddress.DistrictID = objAddress.District.DistrictID;
            objTblAddress.CityID     = objAddress.City.CityID;
            objTblAddress.Pincode    = objAddress.Pincode;

            return(objTblAddress);
        }
Пример #16
0
        public ActionResult Order(tblOrder orderModel)
        {
            if (ModelState.IsValid)
            {
                tblAddress userAddress  = db.tblAddress.Where(x => x.Id == orderModel.AdressId).FirstOrDefault();
                tblAddress orderAddress = new tblAddress {
                    Name    = userAddress.Name,
                    Address = userAddress.Address,
                    City    = userAddress.City,
                    Country = userAddress.Country,
                    Zip     = userAddress.Zip,
                };

                db.tblAddress.Add(orderAddress);

                orderModel.AdressId  = orderAddress.Id;
                orderModel.isShipped = false;
                orderModel.Date      = DateTime.Now;
                db.tblOrder.Add(orderModel);
            }

            int userId = (int)Session["userID"];
            List <tblShoppingCart> oldSCart = db.tblShoppingCart.Where(x => x.UserId == userId && x.OrderId == null).ToList();

            foreach (var item in oldSCart)
            {
                db.tblShoppingCart.Remove(item);
            }
            foreach (ShoppingCart item in (List <ShoppingCart>)Session["cart"])
            {
                tblShoppingCart sCart = new tblShoppingCart {
                    UserId     = (int)Session["userID"],
                    ProductId  = item.Product.Id,
                    Amount     = item.Quantity,
                    TotalPrice = (item.Product.Price * item.Quantity),
                    OrderId    = orderModel.Id,
                };
                tblProduct product = db.tblProduct.Where(x => x.Id == sCart.ProductId).FirstOrDefault();
                product.Stock          -= sCart.Amount;
                db.Entry(product).State = EntityState.Modified;

                db.tblShoppingCart.Add(sCart);
            }
            db.SaveChanges();
            Session.Remove("cart");

            return(View("Index"));
        }
Пример #17
0
        public ActionResult ComAdd(FormCollection form)
        {
            tblAddress address = new tblAddress();

            address.AddressType = form["addtype"];
            address.HouseNo     = form["txtHouseNo"];
            address.Landmark    = form["txtLandmark"];
            address.Area        = form["txtArea"];
            address.CompanyId   = Convert.ToInt32(Session["CompanyId"]);
            address.Address     = form["txtAddress"];
            address.CityId      = Convert.ToInt32(form["ddCity"]);
            address.Zipcode     = form["txtZip"];
            dc.tblAddresses.Add(address);
            dc.SaveChanges();
            return(RedirectToAction("CompanyProfile", "ClientCompany", new { id = address.CompanyId }));
        }
Пример #18
0
        public int SaveAddress(AddressModel addressModel) // save new address
        {
            tblAddress address = new tblAddress()
            {
                Id           = addressModel.Id,
                AddressLine1 = addressModel.AddressLine1,
                AddressLine2 = addressModel.AddressLine2,
                City         = addressModel.City,
                State        = addressModel.State,
                Country      = addressModel.Country
            };

            objWITSProjectEntities.tblAddress.Add(address);
            objWITSProjectEntities.SaveChanges();
            return(address.Id);
        }
Пример #19
0
        public ActionResult EditAdd(FormCollection form)
        {
            int        id  = Convert.ToInt32(TempData["id"]);
            tblAddress add = dc.tblAddresses.SingleOrDefault(ob => ob.AddressId == id);

            add.AddressType = form["txtAddressType"];
            add.HouseNo     = form["txtHouseNo"];
            //user.ProfilePic = form["txtprofile"];
            add.Landmark = form["txtLandMark"];
            add.Area     = form["txtArea"];
            add.Address  = form["txtAddress"];
            add.CityId   = Convert.ToInt32(form["txtCityId"]);
            add.Zipcode  = form["txtZipcode"];

            dc.SaveChanges();
            return(RedirectToAction("ViewCon", "ClientConsignment", new { id = add.AddressId }));
        }
Пример #20
0
 public ActionResult DeleteAddress(int id)
 {
     if (ClsCheckRole.CheckQuyen(4, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblAddress tbladdress = db.tblAddresses.Find(id);
         var        result     = string.Empty;
         db.tblAddresses.Remove(tbladdress);
         db.SaveChanges();
         result = "Bạn đã xóa thành công.";
         return(Json(new { result = result }));
     }
     else
     {
         var result = string.Empty;
         result = "Bạn không có quyền thay đổi tính năng này";
         return(Json(new { result = result }));
     }
 }
Пример #21
0
        public void UpdateEmployee(tblEmployeeDetail objTblEmp, Employee objEmployee)
        {
            objTblEmp.FirstName = objEmployee.FirstName;
            objTblEmp.LastName  = objEmployee.LastName;
            objTblEmp.Email     = objEmployee.Email;
            objTblEmp.Mobile    = objEmployee.Mobile;
            objTblEmp.Phone     = objEmployee.Phone;

            tblAddress objAddress    = ConvertAddress(objEmployee.CommunicationAddress);
            tblAddress objTblAddress = entities.tblAddresses.Find(objAddress.AddressID);

            objTblAddress.Address1 = objAddress.Address1;
            objTblAddress.Address2 = objAddress.Address2;
            objTblAddress.Address3 = objAddress.Address3;

            objTblAddress.StateID    = objAddress.StateID;
            objTblAddress.DistrictID = objAddress.DistrictID;
            objTblAddress.CityID     = objAddress.CityID;
            objTblAddress.Pincode    = objAddress.Pincode;


            objTblEmp.CommunicationAddressID = objAddress.AddressID;


            tblAddress objAddress1    = ConvertAddress(objEmployee.PermanentAddress);
            tblAddress objTblAddress1 = entities.tblAddresses.Find(objAddress1.AddressID);

            objTblAddress1.Address1 = objAddress1.Address1;
            objTblAddress1.Address2 = objAddress1.Address2;
            objTblAddress1.Address3 = objAddress1.Address3;

            objTblAddress1.StateID    = objAddress1.StateID;
            objTblAddress1.DistrictID = objAddress1.DistrictID;
            objTblAddress1.CityID     = objAddress1.CityID;
            objTblAddress1.Pincode    = objAddress1.Pincode;

            objTblEmp.PermanentAddressID = objTblAddress1.AddressID;

            //objTblEmp.tblAddress1 = ConvertAddress(objEmployee.PermanentAddress);

            entities.SaveChanges();
        }
Пример #22
0
 public ActionResult Edit(int id = 0)
 {
     if ((Request.Cookies["Username"] == null))
     {
         return(RedirectToAction("LoginIndex", "Login"));
     }
     if (ClsCheckRole.CheckQuyen(4, 2, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         tblAddress tbladdress = db.tblAddresses.Find(id);
         if (tbladdress == null)
         {
             return(HttpNotFound());
         }
         return(View(tbladdress));
     }
     else
     {
         return(Redirect("/Users/Erro"));
     }
 }
Пример #23
0
        public ActionResult Create(tblAddress tbladdress, FormCollection collection)
        {
            db.tblAddresses.Add(tbladdress);
            db.SaveChanges();
            #region [Updatehistory]
            Updatehistoty.UpdateHistory("Add tbladdress", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString());
            #endregion
            if (collection["btnSave"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info alert1\">Bạn đã thêm thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";

                return(Redirect("/address/Index"));
            }
            if (collection["btnSaveCreate"] != null)
            {
                Session["Thongbao"] = "<div  class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm danh mục  mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";
                return(Redirect("/address/Create"));
            }
            return(Redirect("Index"));
        }
Пример #24
0
        public int Register(RegistrationViewModel Data)
        {
            using (UserDataContext db = new UserDataContext())
            {
                if (db.tblUserData.Any(o => o.UserName.Equals(Data.UserName)))
                {
                    return(1);
                }
                var UserData = Data.TotblUserData();


                var        User   = db.tblUserData.Add(UserData);
                tblAddress Adress = new tblAddress();
                // User AdressID = Address.Id

                db.tblAddress.Add(Adress);
                User.AddressID = Adress.ID;// Increment Address.ID
                db.SaveChanges();
                return(0);
            }
        }
Пример #25
0
        public static int Add(Models.DomainModel.Student student)
        {
            using (TestEntities context = new TestEntities())
            {
                tblAddress objAddress = new tblAddress()
                    {
                        HouseNo = student.AddressDetails.HouseNo,
                        Locality = student.AddressDetails.Locality,
                        City = student.AddressDetails.City,
                        District = student.AddressDetails.District,
                        State = student.AddressDetails.State,
                        CreatedDate = DateTime.Now,
                        CreatedBy = "admin"
                    };

                tblPerson objPerson = new tblPerson()
                    {
                        Name = student.Name,
                        FatherName = student.FatherName,
                        MotherName = student.MotherName,
                        Age = student.Age,
                        Gender = 1,
                        CreatedDate = DateTime.Now,
                        CreatedBy = "admin"
                    };

                context.tblAddresses.AddObject(objAddress);
                context.tblPersons.AddObject(objPerson);
                tblStudent objStudent = new tblStudent()
                {
                    PersonID = objPerson.ID,
                    AddressID = objAddress.ID,
                    CreatedDate = DateTime.Now,
                    CreatedBy = "admin"
                };
                context.tblStudents.AddObject(objStudent);
                context.SaveChanges();
                return objStudent.ID;
            }
        }
Пример #26
0
        public ActionResult Insert3(FormCollection form)
        {
            tblAddress fromplace = new tblAddress();

            fromplace.AddressType = form["addtype"];
            fromplace.HouseNo     = form["txtHouseNo"];
            fromplace.Landmark    = form["txtLandmark"];
            fromplace.Area        = form["txtArea"];
            fromplace.UserId      = Convert.ToInt32(Session["LogID"]);
            fromplace.Address     = form["txtAddress"];
            fromplace.CityId      = Convert.ToInt32(form["ddCity"]);
            fromplace.Zipcode     = form["txtZip"];

            dc.tblAddresses.Add(fromplace);
            dc.SaveChanges();
            int LastFromAddressID = (from ob in dc.tblAddresses orderby ob.AddressId descending select ob).Take(1).SingleOrDefault().AddressId;

            tblAddress toplace = new tblAddress();

            toplace.AddressType = form["addtype"];
            toplace.HouseNo     = form["txttoHouseNo"];
            toplace.Landmark    = form["txttoLandmark"];
            toplace.Area        = form["txttoArea"];
            toplace.UserId      = Convert.ToInt32(Session["LogID"]);
            toplace.Address     = form["txttoAddress"];
            toplace.CityId      = Convert.ToInt32(form["ddtoCity"]);
            toplace.Zipcode     = form["txttoZip"];
            dc.tblAddresses.Add(toplace);
            dc.SaveChanges();
            int LastToAddressID = (from ob in dc.tblAddresses orderby ob.AddressId descending select ob).Take(1).SingleOrDefault().AddressId;

            int            LastID = Convert.ToInt32(Session["LastID"]);
            tblConsignment con    = dc.tblConsignments.SingleOrDefault(ob => ob.ConsignmentId == LastID);

            con.SourceId      = LastFromAddressID;
            con.DestinationId = LastToAddressID;
            dc.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Пример #27
0
        public ActionResult Edit(tblAddress tbladdress, int id, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tbladdress).State = EntityState.Modified;

                db.SaveChanges();
                #region [Updatehistory]
                Updatehistoty.UpdateHistory("Edit tbladdress", Request.Cookies["Username"].Values["FullName"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString());
                #endregion
                if (collection["btnSave"] != null)
                {
                    Session["Thongbao"] = "<div  class=\"alert alert-info alert1\">Bạn đã sửa  thành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";

                    return(Redirect("/address/Index"));
                }
                if (collection["btnSaveCreate"] != null)
                {
                    Session["Thongbao"] = "<div  class=\"alert alert-info\">Bạn đã thêm thành công, mời bạn thêm mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>";
                    return(Redirect("/address/Create"));
                }
            }
            return(View(tbladdress));
        }
Пример #28
0
        public Address ConvertTblAddress(tblAddress objTblAddress)
        {
            Address  objAddress = new Address();
            State    state      = new State();
            District district   = new District();
            City     city       = new City();

            objAddress.AddressID = objTblAddress.AddressID;
            objAddress.Address1  = objTblAddress.Address1;
            objAddress.Address2  = objTblAddress.Address2;
            objAddress.Address3  = objTblAddress.Address3;


            state.StateID = objTblAddress.StateID;
            state.States  = objTblAddress.tblMasState.StateName;

            district.DistrictID = objTblAddress.DistrictID;
            district.Districts  = objTblAddress.tblMasDistrict.DistrictName;

            city.CityID = objTblAddress.CityID;
            city.Cities = objTblAddress.tblMasCity.CityName;

            foreach (var s in FetchStates())
            {
                objAddress.States.Add(s);
            }
            objAddress.Districts.Add(district);
            objAddress.Cities.Add(city);

            objAddress.State    = state;
            objAddress.District = district;
            objAddress.City     = city;
            objAddress.Pincode  = objTblAddress.Pincode;

            return(objAddress);
        }
Пример #29
0
        public ActionResult Index(int?page, string id, FormCollection collection)
        {
            if ((Request.Cookies["Username"] == null))
            {
                return(RedirectToAction("LoginIndex", "Login"));
            }
            if (ClsCheckRole.CheckQuyen(4, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
            {
                var listAddress = db.tblAddresses.ToList();

                const int pageSize   = 20;
                var       pageNumber = (page ?? 1);
                // Thiết lập phân trang
                var ship = new PagedListRenderOptions
                {
                    DisplayLinkToFirstPage                      = PagedListDisplayMode.Always,
                    DisplayLinkToLastPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToPreviousPage                   = PagedListDisplayMode.Always,
                    DisplayLinkToNextPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToIndividualPages                = true,
                    DisplayPageCountAndCurrentLocation          = false,
                    MaximumPageNumbersToDisplay                 = 5,
                    DisplayEllipsesWhenNotShowingAllPageNumbers = true,
                    EllipsesFormat                     = "&#8230;",
                    LinkToFirstPageFormat              = "Trang đầu",
                    LinkToPreviousPageFormat           = "«",
                    LinkToIndividualPageFormat         = "{0}",
                    LinkToNextPageFormat               = "»",
                    LinkToLastPageFormat               = "Trang cuối",
                    PageCountAndCurrentLocationFormat  = "Page {0} of {1}.",
                    ItemSliceAndTotalFormat            = "Showing items {0} through {1} of {2}.",
                    FunctionToDisplayEachPageNumber    = null,
                    ClassToApplyToFirstListItemInPager = null,
                    ClassToApplyToLastListItemInPager  = null,
                    ContainerDivClasses                = new[] { "pagination-container" },
                    UlElementClasses                   = new[] { "pagination" },
                    LiElementClasses                   = Enumerable.Empty <string>()
                };
                ViewBag.ship = ship;
                if (Session["Thongbao"] != null && Session["Thongbao"] != "")
                {
                    ViewBag.thongbao    = Session["Thongbao"].ToString();
                    Session["Thongbao"] = "";
                }
                if (collection["btnDelete"] != null)
                {
                    foreach (string key in Request.Form.Keys)
                    {
                        var checkbox = "";
                        if (key.StartsWith("chk_"))
                        {
                            checkbox = Request.Form["" + key];
                            if (checkbox != "false")
                            {
                                if (ClsCheckRole.CheckQuyen(4, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
                                {
                                    int        ids        = Convert.ToInt32(key.Remove(0, 4));
                                    tblAddress tbladdress = db.tblAddresses.Find(ids);
                                    db.tblAddresses.Remove(tbladdress);
                                    db.SaveChanges();
                                    return(RedirectToAction("Index"));
                                }
                                else
                                {
                                    return(Redirect("/Users/Erro"));
                                }
                            }
                        }
                    }
                }
                return(View(listAddress.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                return(Redirect("/Users/Erro"));
            }
        }
Пример #30
0
    protected void rptservice_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            var DC = new DataClassesDataContext();

            int ID = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "Active")
            {
                tblAddress result = (from u in DC.tblAddresses
                                     where u.AddressID == ID
                                     select u).Single();

                if (result.IsActive == true)
                {
                    result.IsActive = false;
                }
                else
                {
                    result.IsActive = true;
                }
                DC.SubmitChanges();
            }
            else if (e.CommandName == "View")
            {
                var str = (from obj in DC.tblAddresses
                           where obj.AddressID == Convert.ToInt32(e.CommandArgument)
                           select new
                {
                    data = (from ob in DC.tblServiceProviders
                            where ob.AddressID == obj.AddressID
                            select new
                    {
                        Da = ob.FirstName + " " + ob.LastName
                    }).Take(1).SingleOrDefault().Da,
                    city = (from obj1 in DC.CityMasters
                            where obj1.ID == obj.CityID
                            select new
                    {
                        Da1 = obj1.Name,
                    }).Take(1).SingleOrDefault().Da1,
                    obj.AddressID,
                    obj.Address,
                    obj.Area,
                    obj.CityID,
                    obj.IsActive,
                    obj.Landmark,
                    obj.PincodeNo,
                });
                rptViewDetail.DataSource = str;
                rptViewDetail.DataBind();
                foreach (RepeaterItem item in rptViewDetail.Items)
                {
                    HiddenField hdn      = (HiddenField)item.FindControl("HiddenField1");
                    Label       lblState = (Label)item.FindControl("Label6");
                    HiddenField hdnState = (HiddenField)item.FindControl("HiddenField3");
                    if (hdn.Value != "")
                    {
                        var State = (from obj in DC.StateMasters
                                     where obj.ID == Convert.ToInt32(hdn.Value)
                                     select obj).Single();
                        lblState.Text  = State.Name;
                        hdnState.Value = State.ID.ToString();
                    }
                }

                foreach (RepeaterItem item in rptViewDetail.Items)
                {
                    HiddenField hdn      = (HiddenField)item.FindControl("HiddenField3");
                    Label       lblState = (Label)item.FindControl("Label7");
                    if (hdn.Value != "")
                    {
                        var Country = (from obj in DC.CountryMasters
                                       where obj.ID == Convert.ToInt32(hdn.Value)
                                       select obj).Single();
                        lblState.Text = Country.Name;
                    }
                }
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal({backdrop:'static', keyboard: false});", true);
                //    upModal.Update();
            }
            bindata1();
        }
        catch (Exception ex)
        {
            int    session    = Convert.ToInt32(Session["AdminID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "Admin", 0, session, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }
Пример #31
0
    protected void btnsub_Click(object sender, EventArgs e)
    {
        try {
            panel1.Visible = true;
            var dc = new DataClassesDataContext();
            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                tblAddress add = new tblAddress()
                {
                    Address   = txtadd.Text,
                    Area      = txtarea.Text,
                    Landmark  = txtlm.Text,
                    PincodeNo = txtpinno.Text,
                    CityID    = ddlcity.SelectedIndex
                };

                data.tblAddresses.InsertOnSubmit(add);
                data.SubmitChanges();

                string chk;
                if (radveg.Checked)
                {
                    chk = "veg";
                }
                else if (radnonveg.Checked)
                {
                    chk = "Non-Veg";
                }
                else
                {
                    chk = "Both";
                }


                var img = (from im in dc.tblImages
                           orderby im.ImagesID descending
                           select im).FirstOrDefault();

                tblServiceProvider user = new tblServiceProvider()
                {
                    AddressID   = add.AddressID,
                    Password    = Session["pass"].ToString(),
                    FirstName   = txtfnm.Text,
                    LastName    = txtlnm.Text,
                    Email       = txtmail.Text,
                    ImageID     = Convert.ToInt32(img.ImagesID),
                    Veg_NonVeg  = chk,
                    VerifyBy    = 1,
                    CreatedOn   = DateTime.Now,
                    ContactNo   = txtphno.Text,
                    CompanyName = txtcompnm.Text
                };
                data.tblServiceProviders.InsertOnSubmit(user);
                data.SubmitChanges();

                using (DataClassesDataContext des = new DataClassesDataContext())
                {
                    tblNotification str = new tblNotification();
                    str.Title       = "ServiceProvider Registered";
                    str.Description = "You have new ServiceProvider registered";
                    str.CreatedOn   = DateTime.Now;
                    str.CreatedBy   = Convert.ToInt32(Session["ServiceProviderID"]);
                    des.tblNotifications.InsertOnSubmit(str);
                    des.SubmitChanges();

                    tblNotificationDetail strr = new tblNotificationDetail();
                    strr.NotificationID = str.NotificationID;
                    strr.IsRead         = false;
                    strr.IsNotify       = false;
                    des.tblNotificationDetails.InsertOnSubmit(strr);
                    des.SubmitChanges();
                }
                Response.Redirect("Profile_SP.aspx");
            }
        }
        catch (Exception ex)
        {
            //int session = Convert.ToInt32(Session["UserID"].ToString());
            string PageName   = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
            string MACAddress = GetMacAddress();
            AddErrorLog(ref ex, PageName, "User", 0, 0, MACAddress);
            ClientScript.RegisterStartupScript(GetType(), "abc", "alert('Something went wrong! Try again');", true);
        }
    }