예제 #1
0
        private void LoadGrid()
        {
            CustomerDal dal       = new CustomerDal();
            DataSet     customers = dal.Read();

            dtgCustomers.DataSource = customers.Tables[0];
        }
예제 #2
0
        /// <summary>
        ///     Adds a new customer
        /// </summary>
        /// <param name="customer"></param>
        public void AddCustomer(Customer customer)
        {
            // Exception handling
            if (customer == null)
            {
                throw new ArgumentNullException(nameof(customer), "Customer is null");
            }
            if (customer.Name == null)
            {
                throw new ArgumentNullException(nameof(customer.Name), "Customer Name is null");
            }
            if (customer.Contact == null)
            {
                throw new ArgumentNullException(nameof(customer.Contact), "Customer Contact is null");
            }
            if (customer.Nic == null)
            {
                throw new ArgumentNullException(nameof(customer.Nic), "Customer Nic is null");
            }

            using (var connection = Connector.GetConnection())
            {
                var customerDal = new CustomerDal(connection);
                customerDal.Insert(customer.Name, customer.Nic, customer.Contact);
                customer.Id = customerDal.GetLastInsertId();
            }
        }
예제 #3
0
        public ActionResult getCustomers() // JSON collection
        {
            CustomerDal     dal           = new CustomerDal();
            List <Customer> customerscoll = dal.Customers.ToList <Customer>();

            return(Json(customerscoll, JsonRequestBehavior.AllowGet));
        }
        // public ActionResult Submit([ModelBinder(typeof(CustomerBinder))]   Customer obj)
        public ActionResult Submit(Customer obj)
        {
            /*Customer ccc = new Customer();
             * ccc.CustName = CustName;
             * ccc.CustId = CustId;
             *
             * var name = CustName;
             * var no = CustId;*/

            var name = obj.CustName;
            var no   = obj.CustId;

            ViewData["C1"] = name;
            ViewData["C2"] = no;
            if (ModelState.IsValid)
            {
                //Insert Customer Objsct to data baseEF DAL

                CustomerDal Dal = new CustomerDal();
                Dal.Customers.Add(obj); //in memmory
                Dal.SaveChanges();      //Physical  Commit

                ViewData["SUC"] = "Successfull";
                return(View("Customers", obj));
            }
            else
            {
                return(View("Customers", obj));
            }


            //return View("Customers",obj);
        }
예제 #5
0
        // GET: Load
        public ActionResult Index()
        {
            BooksAuthorVM baVm = new BooksAuthorVM();

            Customer customer = new Customer()
            {
                CustId = 1, CustName = "Chirag", CustMobile = 449027677
            };

            Books book = new Books()
            {
                BookId = 1, Author = "Charles Darwin", BookName = "Evolution Of Species"
            };


            baVm.customer = customer;
            baVm.book     = book;


            CustomerDal dal1 = new CustomerDal();

            List <Customer> listCust = dal1.Customers.ToList <Customer>();



            baVm.MyListOfsustomers = listCust;

            return(View("LoadContent", baVm));
        }
예제 #6
0
        public ActionResult Submit()
        {
            Customer obj = new Customer();

            obj.CustomerCode = Request.Form["Customer.CustomerCode"];
            obj.CustomerName = Request.Form["Customer.CustomerName"];
            CustomerViewModel objCustomerVM = new CustomerViewModel();

            objCustomerVM.customer = obj;
            if (ModelState.IsValid)
            {
                CustomerDal Dal = new CustomerDal();
                Dal.Customers.Add(objCustomerVM.customer);
                Dal.SaveChanges();
            }
            else
            {
                objCustomerVM.customer = obj;
            }
            CustomerDal     dal           = new CustomerDal();
            List <Customer> customersColl = dal.Customers.ToList <Customer>();

            //return View("EnterCustomer", objCustomerVM);
            return(Json(customersColl, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // Delete customer record
            // Create the record object to be deleted
            CustomerDal dal     = new CustomerDal();
            DataSet     records = dal.Read();
            // Load selected row (unique key)
            int recordDel = Convert.ToInt16(txtCustomerId.Text);// Fetches unique key object id and assigns it to rowSelected

            string record = recordDel.ToString();
            string mode   = "delete";

            // Ask user if to proceed with deletion of this record

            if (doubleCheck(record, mode))
            {
                // Deletes selected record from the server

                dal.Delete(Convert.ToInt16(record));
            }


            LoadGrid();

            ClearUI();
        }
예제 #8
0
        //public async Task<IActionResult> OnGetAsync()
        //{
        //
        //}

        public void OnPost()
        {
            if (ModelState.IsValid)
            {
                // TODO Validate the username and the password with your own logic
                CustomerDTO objCustomer = CustomerDal.GetItem("test1", "test1");
                var         isValid     = objCustomer != null;

                if (!isValid)
                {
                    // return null if user not found
                    ModelState.AddModelError("", "username or password is invalid");
                }

                CookieOptions option = new CookieOptions()
                {
                    Expires     = DateTime.Now.AddDays(1),
                    Secure      = false,
                    Path        = "/",
                    HttpOnly    = false,
                    IsEssential = true
                };

                Response.Cookies.Append(Consts.CookieKey_Back_CurrentUser_UserName, objCustomer.UserName, option);

                //Response.Redirect("/Admin/AdminDefault");

                RedirectToPage("/Admin/AdminDefault");
            }
        }
 protected void btnAddCustomer_Click(object sender, EventArgs e)
 {
     divError.Visible   = false;
     divSuccess.Visible = false;
     if (Page.IsValid)
     {
         if (!string.IsNullOrEmpty(txtCustomerName.Text) && !string.IsNullOrEmpty(txtCustomerEmail.Text) && !string.IsNullOrEmpty(ddlEnergyPlans.SelectedValue))
         {
             CustomerDal dal      = new CustomerDal();
             Customer    customer = new Customer();
             customer.CreateDate    = DateTime.Now;
             customer.CustomerName  = txtCustomerName.Text;
             customer.EnergyPlanId  = int.Parse(ddlEnergyPlans.SelectedValue);
             customer.CustomerEmail = txtCustomerEmail.Text;
             var savedCustomer = dal.SaveCustomer(customer);
             if (savedCustomer != null && savedCustomer.CustomerId > 0)
             {
                 divSuccess.Visible = true;
             }
             gvCustomers.DataSource = dal.GetAllCustomers();
             gvCustomers.DataBind();
             ClearForm();
         }
         else
         {
             divError.Visible = true;
         }
     }
     else
     {
         divError.Visible = true;
     }
 }
예제 #10
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                // Loading values from the UI
                Customer updatedCustomer = new Customer();
                updatedCustomer.CustomerName = txtCustomerName.Text;
                updatedCustomer.PhoneNumber  = txtPhoneNumber.Text;
                updatedCustomer.BillAmount   = Convert.ToDecimal(txtBillAmount.Text);
                updatedCustomer.ProductId    = Convert.ToInt16(((DataRowView)cmbProduct.SelectedValue)["ProductId"]);

                // Creating DaL object
                CustomerDal dal = new CustomerDal();
                // Updating database per customer record
                dal.Update(updatedCustomer, Convert.ToInt16(txtCustomerId.Text));

                // Calling Load grid refreshes the grid display
                LoadGrid();

                // Clears the UI inputs
                ClearUI();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #11
0
        public void Add(Customer customer, DatabaseTypes databaseTypes)
        {
            Utility.Validate(new CustomerValidator(), customer);
            CustomerDal customerDal = new CustomerDal(databaseTypes);

            customerDal.Add(customer);
        }
예제 #12
0
 public ActionResult getData()
 {
     using (CustomerDal _oCustomerDal = new CustomerDal())
     {
         return(Json(_oCustomerDal.customers.ToList()));
     }
 }
예제 #13
0
        public JsonResult GetCustomer()
        {
            CustomerDal     _oCustomerDal  = new CustomerDal();
            List <Customer> ListOfCostumer = _oCustomerDal.customers.ToList();

            return(Json(ListOfCostumer, JsonRequestBehavior.AllowGet));
        }
예제 #14
0
        public ActionResult Authenticate(CustomerViewModel cvm)
        {
            CustomerDal dal = new CustomerDal();

            if (ModelState.IsValid)
            {
                List <Customer> userValidated = (from u in dal.Customers
                                                 where (u.Email == cvm.user.Email) && (u.Password == cvm.user.Password)
                                                 select u).ToList <Customer>();


                if (userValidated.Count != 0)
                {
                    cvm.customer = userValidated[0];
                    FormsAuthentication.SetAuthCookie("cookie", true);
                    Session["cvm"] = cvm;
                    return(RedirectToAction("Index2", "Home", cvm));
                }
                else
                {
                    cvm.ErrorMessage = "Check your enter please";
                    return(View("Login", cvm));
                }
            }
            return(View("Login", cvm));
        }
예제 #15
0
        static void Main(string[] args)
        {
            CustomerDal customerDal = new CustomerDal();

            using project0Context context = new project0Context();
            {
                var products = context.Inventory
                               .ToList();

                foreach (var product in products)
                {
                    Console.WriteLine($"{product.Name} productId {product.ProductId}\n");
                }

                DefaultStoreDal def = new DefaultStoreDal();
                def.getAllCustomerOfStore(context, 1);

                /*Customers customer = customerDal.addACustomer();
                 * context.Customers.Add(customer);
                 * context.SaveChanges();
                 * Console.WriteLine("Hello World!");*/
            }
            Customers disl = customerDal.GetCustomerById(context, 1);

            Console.WriteLine($"{disl.FirstName} {disl.LastName}");
        }
예제 #16
0
        private void FillProducts()
        {
            CustomerDal dal = new CustomerDal();

            cmbProduct.DisplayMember = "ProductName";
            cmbProduct.ValueMember   = "PoductId";
            cmbProduct.DataSource    = dal.ReadProducts().Tables[0];
        }
 public OrdersForm(Manager manager)
 {
     _manager     = manager;
     _orderDal    = new OrderDal();
     _customerDal = new CustomerDal();
     _bookDal     = new BookDal();
     InitializeComponent();
 }
예제 #18
0
        public ActionResult getCustomers()//gives  JSON collection
        {
            CustomerDal  dal           = new CustomerDal();
            List <Custi> customerscoll = dal.Customers.ToList <Custi>();

            Thread.Sleep(1000);
            return(Json(customerscoll, JsonRequestBehavior.AllowGet));// Req behaviour allows to get called by http func
        }
예제 #19
0
        public ActionResult getCustomersByJson()
        {
            //Json- return json with customers list
            CustomerDal     cDal        = new CustomerDal();
            List <Customer> objProducts = cDal.Customers.ToList();

            return(Json(objProducts, JsonRequestBehavior.AllowGet));
        }
예제 #20
0
        private void btnCustomerDepositCash_Click(object sender, EventArgs e)
        {
            customerLoggedIn.Cash += Convert.ToDecimal(tbxCustomerDepositCash.Text);

            CustomerDal.Update(customerLoggedIn);

            lblCustomerAccountCashDisplay.Text = customerLoggedIn.Cash.ToString();
        }
예제 #21
0
        public ActionResult GetCustomers()
        {
            CustomerDal     dal           = new CustomerDal();
            List <Customer> customersColl = dal.Customers.ToList <Customer>();

            Thread.Sleep(10000);
            return(Json(customersColl, JsonRequestBehavior.AllowGet));
        }
예제 #22
0
        private void btnUpdateCustomer_Click(object sender, EventArgs e)
        {
            customerLoggedIn.FirstName  = tbxUpdateCustomerFirstName.Text;
            customerLoggedIn.LastName   = tbxUpdateCustomerLastName.Text;
            customerLoggedIn.CustomerId = tbxUpdateCustomerId.Text;
            customerLoggedIn.Password   = tbxUpdateCustomerPassword.Text;

            CustomerDal.Update(customerLoggedIn);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         CustomerDal dal = new CustomerDal();
         gvCustomers.DataSource = dal.GetAllCustomers();
         gvCustomers.DataBind();
     }
 }
예제 #24
0
        public static void AddCustomer(string name, string phone, string notifactionToken)
        {
            customer customer = new customer()
            {
                custName = name, phoneNumber = phone, firebaseToken = notifactionToken
            };

            CustomerDal.AddCustomer(customer);
        }
        public void DisplayMenu()
        {
            Console.WriteLine("Welcome to World Electronics Where Technology Meets Creativity");
            Console.WriteLine("How May I Help Today. Enter 'B' for Shoping; 'C' to get Customer's Information");
            Console.WriteLine("Or 'S' for Store Locationss and 'V' to view Orders History:");

            string str = Console.ReadLine();

            //check if the user input the right variable
            while (str.Length > 1)
            {
                Console.WriteLine("Welcome to World Electronics Where Technology Meets Creativity");
                Console.WriteLine("How May I Help Today. Enter 'B' for Shoping; 'C' to get Customer's Information");
                Console.WriteLine("Or 'S' for Store Locationss and 'V' to view Orders History:");

                str = Console.ReadLine();
            }
            char choice;
            //this allows the usee to enter input in lower case
            string ch = str.ToUpper();

            choice = ch[0];
            using project0Context context = new project0Context();
            Cart cart = new Cart();

            switch (choice)
            {
            case 'B':
                cart.Buying(context);
                BackToMenu();
                break;

            case 'C':
                CustomerDal customer = new CustomerDal();
                customer.CustomersHome(context);
                BackToMenu();
                break;

            case 'V':
                OrderDal order = new OrderDal();
                order.DisplayCustomerHist(context, 1);
                BackToMenu();
                break;

            case 'S':
                StoreDal store = new StoreDal();
                Console.WriteLine("showing store 1:");
                store.ShowStoreAddress(context, 1);
                BackToMenu();
                break;

            default:
                BackToMenu();
                break;
            }
        }
예제 #26
0
        // GET: Admin
        public ActionResult AdminIndex(User usr)
        {
            CustomerDal     Cdal      = new CustomerDal();
            List <Customer> customers = (from u in Cdal.Customers where (u.Email == usr.Email) && (u.Password == usr.Password)
                                         select u).ToList <Customer>();
            AdminViewModel model = new AdminViewModel();

            model.cvm.customer = customers[0];
            return(View(model));
        }
예제 #27
0
        static void Main(string[] args)
        {
            Customer customer = new Customer {
                firstName = "Mustafa", lastName = "Demirel", Age = 21
            };
            CustomerDal customerDal = new CustomerDal();

            customerDal.Add(customer);
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            CustomerDal customerDal = new CustomerDal();

            using project0Context context = new project0Context();
            {
                Menu menu = new Menu();
                menu.DisplayMenu();
            }
        }
예제 #29
0
        public static IAddSendAppMessageServiceBll CreateSendAppMessageObj()
        {
            ISendAppMessageDal    sendAppMessageDal    = new SendAppMessageDal();
            ICustomerDal          customerDal          = new CustomerDal();
            ICorporationDal       corporationDal       = new CorporationDal();
            IAddSendAppMessageBll addSendAppMessageBll = new AddSendAppMessageBll(sendAppMessageDal, customerDal,
                                                                                  corporationDal);

            return(new AddSendAppMessageServiceBll(addSendAppMessageBll));
        }
예제 #30
0
        static void Main(string[] args)
        {
            Customer customer = new Customer {
                Id = 1, LastName = "Kaya", Age = 32
            };
            CustomerDal customerDal = new CustomerDal();

            customerDal.Add(customer);

            Console.ReadLine();
        }
예제 #31
0
 public TicketingOffice.CrmService.Contracts.Customer[] FindCustomers(CustomerCriteria criteria)
 {
     CustomerDal dal = new CustomerDal();
     return dal.GetCustomersByCriteria(criteria);
 }
예제 #32
0
 public TicketingOffice.CrmService.Contracts.Customer FindCustomer(Guid customerID)
 {
     CustomerDal dal = new CustomerDal();
     return dal.GetEntity(customerID);
 }
예제 #33
0
 public Guid CreateCustomer(TicketingOffice.CrmService.Contracts.Customer newCustomer)
 {
     CustomerDal dal = new CustomerDal();
     return dal.CreateEntity(newCustomer);
 }
예제 #34
0
 public void DeleteCustomer(Guid customerID)
 {
     CustomerDal dal = new CustomerDal();
     dal.DeleteEntity(customerID);
 }
예제 #35
0
 public void UpdateCustomer(TicketingOffice.CrmService.Contracts.Customer newCustomer)
 {
     CustomerDal dal = new CustomerDal();
     dal.UpdateEntity(newCustomer);
 }