public ActionResult ExporttoExcel()
        {
            var customerdata = ManageCustomerService.CustomerDetails(0, "");
            List <ExportManageUserModel> ExportManageUserModel = new List <Models.ExportManageUserModel>();

            foreach (var item in customerdata)
            {
                var model = new ExportManageUserModel();
                model.CustomerNo         = item.CustomerId;
                model.CustomerName       = item.FirstName + item.LastName;
                model.Email              = item.Email;
                model.DateofRegistration = item.Date_of_Registration;
                model.AvailableCredits   = item.Availablecredits;
                model.NoOfEvents         = item.No_of_events;
                ExportManageUserModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ExportManageUserModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ManageUser.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int CustomerId = 0)
        {
            if (Session["CustomerId"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            Customer customer = ManageCustomerService.GetCustomerById(CustomerId);

            if (customer == null)
            {
                return(HttpNotFound());
            }

            CustomerModel model = new CustomerModel();

            model.CustomerId           = customer.CustomerId;
            model.FirstName            = customer.FirstName;
            model.LastName             = customer.LastName;
            model.Email                = customer.Email;
            model.Contactno            = customer.Contactno;
            model.Username             = customer.Username;
            model.Password             = customer.Password;
            model.CompanyName          = customer.CompanyName;
            model.Date_of_Registration = customer.Date_of_Registration;

            model.IsActive      = customer.IsActive;
            model.AccountStatus = customer.IsActive;


            ViewBag.CustomerId = model.CustomerId;
            return(View(model));
        }
        public ActionResult Edit(CustomerModel model)
        {
            if (Session["CustomerId"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            Customer customer = ManageCustomerService.GetCustomerById(model.CustomerId);

            customer.FirstName            = model.FirstName;
            customer.LastName             = model.LastName;
            customer.Email                = model.Email;
            customer.Contactno            = model.Contactno;
            customer.Username             = model.Username;
            customer.Password             = model.Password;
            customer.CompanyName          = model.CompanyName;
            customer.Date_of_Registration = model.Date_of_Registration;

            customer.CustomerId = model.CustomerId;
            customer.IsActive   = model.AccountStatus;
            //customer.createddate = DateTime.Now;
            //customer.updateddate = DateTime.Now;
            ManageCustomerService.UpdateCustomer(customer);

            ViewBag.StatusMessage = "SuccessUpdate";
            return(View(model));
        }
        private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha)
        {
            SearchTitle = SearchTitle.Trim().ToLower();
            Alpha       = Alpha.Trim().ToLower();
            List <CustomerModel> Customerlist = new List <CustomerModel>();
            var customerdata = ManageCustomerService.CustomerDetails(0, Alpha);

            foreach (var data in customerdata)
            {
                CustomerModel model = new CustomerModel();
                model.CustomerId           = data.CustomerId;
                model.FirstName            = data.FirstName;
                model.LastName             = data.LastName;
                model.Email                = data.Email;
                model.Contactno            = data.Contactno;
                model.Username             = data.Username;
                model.Password             = data.Password;
                model.CompanyName          = data.CompanyName;
                model.Date_of_Registration = data.Date_of_Registration;
                model.NoOfEvents           = data.No_of_events.Value;
                model.AvailableCredits     = data.Availablecredits.Value;
                Customerlist.Add(model);
            }

            return(Customerlist);
        }
        public ActionResult ExporttoExcel()
        {
            var customerdata = ManageCustomerService.ManageEvents(0, Convert.ToString(TempData["SearchTitle"]));
            List <ManageEventModel> ManageEventModel = new List <Models.ManageEventModel>();

            foreach (var item in customerdata)
            {
                var model = new ManageEventModel();
                model.CustomerName   = item.Name;
                model.EventName      = item.EventName;
                model.EventStartDate = item.EventStartDate;
                model.EventEndDate   = item.EventEndDate;
                model.RegisteredUser = item.TotalCount;
                model.ReferredUser   = item.ReferredUsers;
                ManageEventModel.Add(model);
            }

            GridView gv = new GridView();

            gv.DataSource = ManageEventModel;
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ManageEvent.xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset     = "";
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return(RedirectToAction("Index"));
        }
 public ActionResult Delete(int CustomerId)
 {
     if (Session["CustomerId"] == null)
     {
         return(RedirectToAction("Login", "Home"));
     }
     ManageCustomerService.DeleteCustomer(CustomerId);
     return(RedirectToAction("Grid"));
 }
Exemplo n.º 7
0
        //Control Customer Panel-------------------------------------------------------------------------------------------

        private void btn_search_customer_Click(object sender, EventArgs e)
        {
            Customer customer = new ManageCustomerService().FindByPhone(search_customer.Text);

            if (customer != null)
            {
                select_customer.Text = customer.CustomerId + " - " + customer.CustomerFullname;
                customerPresent      = customer;
                LoadDeliveryAddress(customer.CustomerId);
            }
            else
            {
                MessageBox.Show("Not Found!");
                select_customer.Text = null;
                customerPresent      = null;
                LoadDeliveryAddress(-1);
            }
        }
        public ActionResult ChangePassword(int CustomerId, string Password)
        {
            var rsult = "";

            try
            {
                Customer customer = ManageCustomerService.GetCustomerById(CustomerId);

                customer.Password = Password;
                ManageCustomerService.UpdateCustomer(customer);
                rsult = "Password Saved Successfully";
            }
            catch
            {
                rsult = "Try again";
            }


            return(Json(rsult));
        }
        private IEnumerable GetData(int SearchRecords, string SearchTitle, string Alpha)
        {
            SearchTitle = SearchTitle.Trim().ToLower();
            Alpha       = Alpha.Trim().ToLower();
            List <ManageEventModel> Customerlist = new List <ManageEventModel>();
            var customerdata = ManageCustomerService.ManageEvents(0, SearchTitle);

            foreach (var data in customerdata)
            {
                ManageEventModel model = new ManageEventModel();
                model.CustomerName   = data.Name;
                model.EventName      = data.EventName;
                model.EventStartDate = data.EventStartDate;
                model.EventEndDate   = data.EventEndDate;
                model.RegisteredUser = data.TotalCount;
                model.ReferredUser   = data.ReferredUsers;
                Customerlist.Add(model);
            }

            return(Customerlist);
        }
        public ActionResult Create(CustomerModel model)
        {
            if (Session["CustomerId"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (ModelState.IsValid)
            {
                var matchuser = db.Customers.Where(a => a.Username.Equals(model.Username)).FirstOrDefault();
                if (matchuser == null)
                {
                    Customer customer = new Customer();
                    customer.CustomerId           = model.CustomerId;
                    customer.FirstName            = model.FirstName;
                    customer.LastName             = model.LastName;
                    customer.Email                = model.Email;
                    customer.Contactno            = model.Contactno;
                    customer.Username             = model.Username;
                    customer.Password             = model.Password;
                    customer.CompanyName          = model.CompanyName;
                    customer.Date_of_Registration = DateTime.Now;
                    customer.IsActive             = true;
                    customer.createddate          = DateTime.Now;
                    customer.updateddate          = DateTime.Now;

                    ViewBag.CustomerId    = customer.CustomerId;
                    ViewBag.StatusMessage = "SuccessAdd";


                    var          role         = RoleService.GetRoleByName("User");
                    CustomerRole customerrole = new CustomerRole();
                    if (role != null)
                    {
                        customerrole.RoleId     = role.RoleId;
                        customerrole.CustomerId = customer.CustomerId;
                    }
                    customer.CustomerRoles.Add(customerrole);
                    ManageCustomerService.InsertCustomer(customer);


                    //Transaction
                    Transaction transaction = new Transaction();
                    transaction.CustomerId      = customer.CustomerId;
                    transaction.Amount          = 100;
                    transaction.TransactionDate = DateTime.Now;
                    transaction.Status          = "completed";
                    transaction.TransactionType = "credit";
                    transaction.CreatedDate     = DateTime.Now;
                    transaction.UpdatedDate     = DateTime.Now;
                    transaction.PaymentMethod   = "offline";
                    TransactionService.InsertTransaction(transaction);
                }
                else
                {
                    ViewBag.Message = "  This user is already exists";
                    return(View());
                }
            }
            return(View(model));
        }