Exemple #1
0
        /// <summary>
        /// creates customer and adds to db + logging
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void createCustomerButton_Click(object sender, EventArgs e)
        {
            CUSTOMERS customer = new CUSTOMERS();

            int newId = _controller.GetNextCustomerId();

            customer.CS_STAMP       = newId;
            customer.CS_CUSTNO      = newId;
            customer.CS_CPRNO       = cprBox.Text;
            customer.CS_FIRSTNAME   = firstNameBox.Text;
            customer.CS_LASTNAME    = LastNameBox.Text;
            customer.CS_ADRESS1     = adressBox.Text;
            customer.CS_EMAIL       = emailBox.Text;
            customer.CS_PHONEMOBILE = phoneBox.Text;

            if (createCustomerButtonOK.Text == "Gem")
            {
                _controller.PutCustomer(customer);
                Trace.WriteLine($"\n Ny kunde med navn: {firstNameBox.Text} {LastNameBox.Text} er blevet oprettet d. {DateTime.Now}");
                this.Close();
            }
            if (createCustomerButtonOK.Text == "Opret")
            {
                _controller.PostCustomer(customer);
                Trace.WriteLine($"\n Ny kunde med navn: {firstNameBox.Text} {LastNameBox.Text} er blevet rettet i d. {DateTime.Now}");
                this.Close();
            }
            this.Close();
        }
Exemple #2
0
 public ActionResult Login(CUSTOMERS user, string returnUrl)
 {
     {
         if (ModelState.IsValid)
         {
             CUSTOMERS cus = context.CUSTOMERS.SingleOrDefault(kh => kh.USERNAME == user.USERNAME);
             if (cus != null && cus.ROLE == 1)
             {
                 if (BCrypt.Net.BCrypt.Verify(user.PASSWORD, cus.PASSWORD))
                 {
                     Session.Add("ADMIN_SESSION", cus);
                     return(RedirectToAction("TatCaSach", "AdminQuanLySach"));
                 }
                 else
                 {
                     ModelState.AddModelError("", "Mật khẩu sai");
                 }
             }
             else
             {
                 ModelState.AddModelError("", "Tài khoản không tồn tại");
             }
         }
         return(View("Index"));
     }
 }
        /// <summary>
        /// Gets the last 2 appointments from specified customer
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public List <APTDETAILS> GetPastAppointments(CUSTOMERS customer)
        {
            var allAppointments = GetAppointments();
            List <APTDETAILS> pastAppointments    = new List <APTDETAILS>();
            List <APTDETAILS> twoLastAppointments = new List <APTDETAILS>();
            var now = DateTime.Now;

            foreach (APTDETAILS a in allAppointments)
            {
                if (a.APD_CUSTOMER == customer.CS_STAMP && a.APD_DATE < now)
                {
                    pastAppointments.Add(a);
                }
            }

            for (int i = 0; i < 2; i++)
            {
                try
                {
                    twoLastAppointments.Add(pastAppointments[i]);
                }
                catch (ArgumentOutOfRangeException) { }
            }

            var sorted = (from a in twoLastAppointments orderby a.APD_DATE select a).ToList();

            return(sorted);
        }
Exemple #4
0
        public static bool UpdateCustomer(CUSTOMERS customer)
        {
            bool status = false;

            try
            {
                using (OracleConnection connection = new OracleConnection(conlink))
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    string        query = "UPDATE CUSTOMERS SET EMAIL= :email ,FIRSTNAME= :fname,LASTNAME=:lname,PHONE=:phone where CUSTID = :custid";
                    OracleCommand cmd   = new OracleCommand(query, connection);

                    cmd.Parameters.Add(new OracleParameter(":custid", customer.CUSTID));
                    cmd.Parameters.Add(new OracleParameter(":email", customer.EMAIL));
                    cmd.Parameters.Add(new OracleParameter(":fname", customer.FIRSTNAME));
                    cmd.Parameters.Add(new OracleParameter(":lname", customer.LASTNAME));
                    cmd.Parameters.Add(new OracleParameter(":phone", customer.PHONE));

                    cmd.ExecuteNonQuery();
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }
                    status = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(status);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            CUSTOMERS cUSTOMERS = db.CUSTOMERS.Find(id);

            db.CUSTOMERS.Remove(cUSTOMERS);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #6
0
        public ActionResult KullaniciSil(int id)
        {
            CUSTOMERS tempID = db.CUSTOMERS.Where(k => k.ID == id).FirstOrDefault();

            db.CUSTOMERS.Remove(tempID);
            db.SaveChanges();
            return(RedirectToAction("Kullanici", "Home"));
        }
 public bool InsertCustomer(CUSTOMERS newCustomer)
 {
     using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
     {
         dbContext.CUSTOMERS.Add(newCustomer);
         dbContext.SaveChanges();
     }
     return(true);
 }
Exemple #8
0
        /// <summary>
        /// Create a new CUSTOMERS object.
        /// </summary>
        /// <param name="id">Initial value of ID.</param>
        /// <param name="cNAME">Initial value of CNAME.</param>
        /// <param name="cONTACT">Initial value of CONTACT.</param>
        public static CUSTOMERS CreateCUSTOMERS(int id, string cNAME, string cONTACT)
        {
            CUSTOMERS cUSTOMERS = new CUSTOMERS();

            cUSTOMERS.ID      = id;
            cUSTOMERS.CNAME   = cNAME;
            cUSTOMERS.CONTACT = cONTACT;
            return(cUSTOMERS);
        }
Exemple #9
0
        public ActionResult Edit(int id, CUSTOMERS customer)
        {
            RetaDbEntities db  = new RetaDbEntities();
            var            mus = db.CUSTOMERS.Find(id);

            mus.SURNAME = customer.SURNAME;
            db.SaveChanges();
            return(RedirectToAction("index"));
        }
 public ActionResult Edit([Bind(Include = "CUSTOMER_ID,CUSTOMER_NAME,CITY")] CUSTOMERS cUSTOMERS)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cUSTOMERS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cUSTOMERS));
 }
Exemple #11
0
        public void UpdateCustomer(int degisken, CUSTOMERS customer)
        {
            CUSTOMERS customer_old = db.CUSTOMERS.Where(m => m.ID == degisken).FirstOrDefault();

            customer_old.MAIL    = customer.MAIL;
            customer_old.NAME    = customer.NAME;
            customer_old.PHONE   = customer.PHONE;
            customer_old.SURNAME = customer.SURNAME;
            db.SaveChanges();
        }
        public CUSTOMERS GetCustomerById(int id)
        {
            var customer = new CUSTOMERS();

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                customer = dbContext.CUSTOMERS.FirstOrDefault(x => x.client_id == id);
            }
            return(customer);
        }
        public ActionResult Create([Bind(Include = "CUSTOMER_ID,CUSTOMER_NAME,CITY")] CUSTOMERS cUSTOMERS)
        {
            if (ModelState.IsValid)
            {
                db.CUSTOMERS.Add(cUSTOMERS);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cUSTOMERS));
        }
Exemple #14
0
        public ActionResult KullaniciDuzenle(CUSTOMERS getUser)
        {
            CUSTOMERS tempID = db.CUSTOMERS.Where(k => k.ID == getUser.ID).SingleOrDefault();

            tempID.CUSTOMERNAME = getUser.CUSTOMERNAME;
            tempID.AGE          = getUser.AGE;
            tempID.GENDER       = getUser.GENDER;
            tempID.EMAIL        = getUser.EMAIL;
            tempID.PASSWORD     = getUser.PASSWORD;
            db.SaveChanges();
            return(RedirectToAction("Kullanici"));
        }
        // GET: CUSTOMERS/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CUSTOMERS cUSTOMERS = db.CUSTOMERS.Find(id);

            if (cUSTOMERS == null)
            {
                return(HttpNotFound());
            }
            return(View(cUSTOMERS));
        }
Exemple #16
0
        private void ListViewBox_DoubleClick(object sender, EventArgs e)
        {
            CUSTOMERS selectedCustomer = (CUSTOMERS)ListViewBox.SelectedItems[0].Tag;

            if (FromAppointmentCreation)
            {
                CreateAppointment.SelectedCustomer = selectedCustomer;
                FromAppointmentCreation            = false;
                this.Close();
            }
            else if (ListViewBox.SelectedItems.Count == 1)
            {
                editCustomerButton_Click(sender, e);
            }
        }
Exemple #17
0
        /// <summary>
        /// Deletes selected customer from view and db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteCustomerButton_Click(object sender, EventArgs e)
        {
            CUSTOMERS customer = (CUSTOMERS)ListViewBox.SelectedItems[0].Tag;

            for (int i = 0; i < ListViewBox.Items.Count; i++)
            {
                if (ListViewBox.Items[i].Selected)
                {
                    ListViewBox.Items[i].Remove();
                    i--;
                }
            }

            _controller.DeleteCustomer(customer);
        }
Exemple #18
0
        private void btn_adoLambda_Click(object sender, EventArgs e)
        {
            if (!checkInfo())
            {
                MessageBox.Show("لطفا نام مشتری را وارد کنید.", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                CUSTOMERS customer = ReturnCustInfo();

                conection.insert <CUSTOMERS>(customer);

                ResultMessage();
            }
        }
Exemple #19
0
        public static List <CUSTOMERS> GetAll()
        {
            CUSTOMERS        customer  = null;
            List <CUSTOMERS> customers = new List <CUSTOMERS>();

            try
            {
                using (OracleConnection con = new OracleConnection(conlink))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    string           query  = "SELECT * FROM CUSTOMERS";
                    OracleCommand    cmd    = new OracleCommand(query, con);
                    OracleDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                customer = new CUSTOMERS()
                                {
                                    CUSTID    = int.Parse(reader["CUSTID"].ToString()),
                                    EMAIL     = reader["EMAIL"].ToString(),
                                    FIRSTNAME = reader["FIRSTNAME"].ToString(),
                                    LASTNAME  = reader["LASTNAME"].ToString(),
                                    PHONE     = long.Parse(reader["PHONE"].ToString()),
                                };
                                customers.Add(customer);
                            }
                            reader.Close();
                        }
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(customers);
        }
        public ActionResult Index(string EMAIL, string PASSWORD)
        {
            CUSTOMERS tempUser = db.CUSTOMERS.Where(k => k.EMAIL == EMAIL && k.PASSWORD.Trim() == PASSWORD.Trim()).SingleOrDefault();

            if (tempUser == null)
            {
                ViewBag.Sonuc = "Kullanıcı bulunamadı.";
                return(View());
            }
            else
            {
                Session["CUSTOMERS"] = tempUser.CUSTOMERNAME;
                Session["Security"]  = true;
                return(RedirectToAction("Index", "Home"));
            }
        }
        public bool UpdateCustomer(CUSTOMERS editCustomer)
        {
            bool result = false;

            using (OrderGraberDBEntities dbContext = new OrderGraberDBEntities())
            {
                var recordToEdit = dbContext.CUSTOMERS.FirstOrDefault(x => x.client_id == editCustomer.client_id);
                recordToEdit.document_type = editCustomer.document_type;
                recordToEdit.document_nro  = editCustomer.document_nro;
                recordToEdit.customer_name = editCustomer.customer_name;
                recordToEdit.address       = editCustomer.address;
                recordToEdit.email         = editCustomer.email;
                recordToEdit.state         = editCustomer.state;
            }
            return(result);
        }
Exemple #22
0
        private void btn_entitySP_Click(object sender, EventArgs e)
        {
            if (!checkInfo())
            {
                MessageBox.Show("لطفا نام مشتری را وارد کنید.", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                CUSTOMERS customer = ReturnCustInfo();
                conection.insertEntitySP(customer.code, customer.special, customer.MONAME, customer.group_rdf,
                                         customer.vis_rdf, customer.addre, customer.tell1, customer.cred, customer.check_eteb,
                                         customer.just_naghdi, customer.MaxManFactor, customer.sharh);

                ResultMessage();
            }
        }
Exemple #23
0
        public static CUSTOMERS Get(string customerEmail)
        {
            CUSTOMERS customer = null;

            try
            {
                using (OracleConnection con = new OracleConnection(conlink))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    string        query = "SELECT * FROM CUSTOMERS WHERE EMAIL =:customerEmail";
                    OracleCommand cmd   = new OracleCommand(query, con);
                    cmd.Parameters.Add(new OracleParameter(":customerEmail", customerEmail));
                    OracleDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                customer = new CUSTOMERS()
                                {
                                    CUSTID    = int.Parse(reader["CUSTID"].ToString()),
                                    EMAIL     = reader["EMAIL"].ToString(),
                                    FIRSTNAME = reader["FIRSTNAME"].ToString(),
                                    LASTNAME  = reader["LASTNAME"].ToString(),
                                    PHONE     = long.Parse(reader["PHONE"].ToString()),
                                };
                            }
                            reader.Close();
                        }
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
            return(customer);
        }
Exemple #24
0
        /// <summary>
        /// Deletes specified custoemr from db
        /// </summary>
        /// <param name="customer"></param>
        public void DeleteCustomer(CUSTOMERS customer)
        {
            using (db = new OptikItDbContext())
            {
                var removeQuery = from a in db.CUSTOMERS where a.CS_STAMP == customer.CS_STAMP select a;
                foreach (var a in removeQuery)
                {
                    db.CUSTOMERS.Remove(a);
                }

                try
                {
                    db.SaveChanges();
                }
                catch (Exception)
                {
                }
            }
        }
 public ActionResult KayitOl(string CUSTOMERNAME, string EMAIL, string PASSWORD, string pswrepeat, int AGE, string GENDER)
 {
     if (PASSWORD == pswrepeat)
     {
         var x = new CUSTOMERS();
         x.CUSTOMERNAME = CUSTOMERNAME;
         x.AGE          = AGE;
         x.GENDER       = GENDER;
         x.EMAIL        = EMAIL;
         x.PASSWORD     = PASSWORD;
         db.CUSTOMERS.Add(x);
         db.SaveChanges();
         ViewBag.Basarili = "Üyeliğiniz tamamlanmıştır.";
         return(RedirectToAction("Index", "Admin"));
     }
     else
     {
         ViewBag.Basarili = "Üyeliğiniz tamamlanamamıştır.";
         return(View());
     }
 }
        //special operations
        public static CUSTOMERS CustomerAllData(int id)
        {
            CUSTOMERS customer = null;

            try
            {
                customer         = CUSTOMERSDAL.Get(id);
                customer.ADDRESS = CUSTOMERADDRESSDAL.GetAddress(id);
                customer.ORDERS  = ORDERSDAL.GetOrders(id);
            }
            catch (NullReferenceException nex)
            {
                customer.ADDRESS = new List <CUSTOMERADDRESS>();
                customer.ORDERS  = new List <ORDERS>();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(customer);
        }
Exemple #27
0
        public static bool InsertCustomer(CUSTOMERS customer)
        {
            bool status = false;

            try
            {
                using (OracleConnection connection = new OracleConnection(conlink))
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }

                    string query = "INSERT INTO CUSTOMERS (EMAIL,PASSWORD,FIRSTNAME,LASTNAME,PHONE) " +
                                   "VALUES (:email,:password,:fname,:lname,:phone)";


#pragma warning disable CS0618 // Type or member is obsolete
                    OracleCommand cmd = new OracleCommand(query, connection);
#pragma warning restore CS0618 // Type or member is obsolete
                    cmd.Parameters.Add(new OracleParameter(":email", customer.EMAIL));
                    cmd.Parameters.Add(new OracleParameter(":password", customer.PASSWORD));
                    cmd.Parameters.Add(new OracleParameter(":fname", customer.FIRSTNAME));
                    cmd.Parameters.Add(new OracleParameter(":lname", customer.LASTNAME));
                    cmd.Parameters.Add(new OracleParameter(":phone", customer.PHONE));

                    cmd.ExecuteNonQuery();
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }
                    status = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(status);
        }
Exemple #28
0
 /// <summary>
 /// creates new specified customer in db
 /// </summary>
 /// <param name="customer"></param>
 public void PostCustomer(CUSTOMERS customer)
 {
     using (db = new OptikItDbContext())
     {
         try
         {
             db.CUSTOMERS.Add(customer);
             db.SaveChanges();
         }
         catch (DbEntityValidationException dbEx)
         {
             foreach (var validationErrors in dbEx.EntityValidationErrors)
             {
                 foreach (var validationError in validationErrors.ValidationErrors)
                 {
                     Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName,
                                            validationError.ErrorMessage);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Gets all future appointments of specified customer
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public List <APTDETAILS> GetFutureAppointments(CUSTOMERS customer)

        {
            List <APTDETAILS> futureCustomerAppoinments = new List <APTDETAILS>();

            var allAppointments = GetAppointments();
            var now             = DateTime.Now;

            foreach (APTDETAILS a in allAppointments)
            {
                if (a.APD_CUSTOMER == customer.CS_STAMP && a.APD_DATE > now)
                {
                    futureCustomerAppoinments.Add(a);
                }
            }



            var sorted = (from a in futureCustomerAppoinments orderby a.APD_DATE select a).ToList();

            return(sorted);
        }
Exemple #30
0
 /// <summary>
 /// edits specified customer in db
 /// </summary>
 /// <param name="customer"></param>
 public void PutCustomer(CUSTOMERS customer)
 {
     using (db = new OptikItDbContext())
     {
         var appointmentToEditQuery = from a in db.CUSTOMERS where a.CS_CPRNO == customer.CS_CPRNO select a;
         foreach (var a in appointmentToEditQuery)
         {
             a.CS_CPRNO       = customer.CS_CPRNO;
             a.CS_FIRSTNAME   = customer.CS_FIRSTNAME;
             a.CS_LASTNAME    = customer.CS_LASTNAME;
             a.CS_ADRESS1     = customer.CS_ADRESS1;
             a.CS_PHONEMOBILE = customer.CS_PHONEMOBILE;
             a.CS_EMAIL       = customer.CS_EMAIL;
         }
         try
         {
             db.SaveChanges();
         }
         catch (Exception)
         {
         }
     }
 }