// view 1st prescription
        public ActionResult ViewPrescription1(int id)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "SELECT * from CustomerTable where ID=@id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", id);
            cmd.ExecuteNonQuery();
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);
            customerModel ob = new customerModel();

            if (dt.Rows.Count == 1)
            {
                ob.id = Convert.ToInt32(dt.Rows[0][0].ToString());

                ob.imgpath = dt.Rows[0][7].ToString();
            }

            ViewData["img"] = ob.imgpath;
            return(View(ob));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("customerId,Name,eMail")] customerModel customerModel)
        {
            if (id != customerModel.customerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!customerModelExists(customerModel.customerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customerModel));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("customerId,Name,eMail")] customerModel customerModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customerModel));
        }
        public JsonResult Filter_Read(string text)
        {
            text = text.ToLower();
            var products = new customerModel().Read();

            if (!string.IsNullOrEmpty(text))
            {
                products = products.Where(i => i.name != null && i.name.ToLower().Contains(text));
                products = products.Where(i => i.isActive);
            }
            return(Json(products, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
 public bool addCustomer(customerModel coustomer)
 {
     try{
         coustomer.createon = System.DateTime.Now;
         coustomer.createby = 1;
         context.Add(coustomer);
         context.SaveChanges();
         return(true);
     }
     catch {
         return(false);
     }
 }
Beispiel #6
0
 public IActionResult Edit(int id, [Bind] customerModel customer)
 {
     if (ModelState.IsValid)
     {
         if (obj_customer.getAllCustomer().Any(x => x.id != id && x.custid.ToUpper() == customer.custid.ToUpper()))
         {
             ModelState.AddModelError("productcode", "Customer code already exists");
         }
         else
         {
             obj_customer.updateCustomer(id, customer);
             return(RedirectToAction("Index"));
         }
     }
     return(View(customer));
 }
Beispiel #7
0
        public IHttpActionResult createCustomer([FromUri] string customer_name, [FromUri] string customer_phone, [FromUri] string customer_address)
        {
            customer ncus = new customer();

            ncus.name     = customer_name;
            ncus.address  = customer_address;
            ncus.phone    = customer_phone;
            ncus.isActive = true;
            ncus.tag      = true;
            ncus.bid      = 1;
            ncus.balance  = 0;
            int id = new customerModel().Create(ncus);

            if (id <= 0)
            {
                return(BadRequest("Error adding the Customer"));
            }
            return(Ok(id));
        }
Beispiel #8
0
        public bool updateCustomer(int id, customerModel s)
        {
            try{
                var customer = context.customerModel.Where(x => x.id == id && x.status == 'A').FirstOrDefault();
                if (customer != null)
                {
                    customer.custid   = s.custid;
                    customer.name     = s.name;
                    customer.phone    = s.phone;
                    customer.gender   = s.gender;
                    customer.address  = s.address;
                    customer.createon = System.DateTime.Now;

                    context.customerModel.Update(customer);
                    context.SaveChanges();
                    return(true);
                }
                return(false);
            }catch (Exception ex) {
                Console.Write(ex.Message);
                return(false);
            }
        }
Beispiel #9
0
        public ActionResult Order(customerModel obj, HttpPostedFileBase file1, HttpPostedFileBase file2, HttpPostedFileBase file3, double amount)
        {
            String        query    = "SELECT * from Cart where UserId = " + UserController.id;
            SqlConnection con      = new SqlConnection(constring);
            String        query2   = "SELECT COUNT(*) from Cart where UserId = " + UserController.id;
            SqlCommand    command1 = new SqlCommand(query2, con);

            con.Open();

            int cnt = Convert.ToInt32(command1.ExecuteScalar());
            var ob  = new orderModel[cnt];
            var ob1 = new orderModel();
            int i;

            for (i = 0; i < cnt; i++)
            {
                ob[i] = new orderModel();
            }

            con.Close();
            SqlCommand command2 = new SqlCommand(query, con);

            con.Open();

            i = 0;
            SqlDataReader read = command2.ExecuteReader();

            while (read.Read())
            {
                ob[i].userid      = read["UserId"].ToString();
                ob[i].productname = read["Product_Name"].ToString();
                ob[i].category    = read["Category"].ToString();
                ob[i].price       = Convert.ToDouble(read["Price"]);
                ob[i].quantity    = Convert.ToInt32(read["quantity"]);
                i++;
            }
            con.Close();

            String q = "INSERT into OrderItem(OrderId,CustomerId,ProductName,Category,Price,Quantity) "
                       + "values(@orderid,@userid,@productname,@category,@price,@quantity)";

            System.Guid orderid = System.Guid.NewGuid();

            for (int j = 0; j < i; j++)
            {
                SqlCommand cmd = new SqlCommand(q, con);
                con.Open();

                cmd.Parameters.AddWithValue("@orderid", orderid.ToString());
                cmd.Parameters.AddWithValue("@productname", ob[j].productname);
                cmd.Parameters.AddWithValue("@userid", ob[j].userid);

                cmd.Parameters.AddWithValue("@category", ob[j].category);
                cmd.Parameters.AddWithValue("@price", ob[j].price);
                cmd.Parameters.AddWithValue("@quantity", ob[j].quantity);
                cmd.ExecuteNonQuery();
                con.Close();
            }



            String query3 = "INSERT into CustomerTable(CustomerId,Name,Address,Email,Phone,OrderId,Prescription1,Prescription2,Prescription3) " +
                            "values(@customerid,@name,@address,@email,@phone,@orderid,@prescription1,@prescription2,@prescription3)";

            SqlCommand command3 = new SqlCommand(query3, con);

            con.Open();
            command3.Parameters.AddWithValue("@customerid", obj.id);

            command3.Parameters.AddWithValue("@name", obj.name);

            command3.Parameters.AddWithValue("@address", obj.address);

            command3.Parameters.AddWithValue("@email", obj.email);

            command3.Parameters.AddWithValue("@phone", obj.phone);
            command3.Parameters.AddWithValue("@orderid", orderid.ToString());



            if (file1 != null && file1.ContentLength > 0)
            {
                string filename = Path.GetFileName(file1.FileName);
                string imgpath  = Path.Combine(Server.MapPath("/orderimages/"), filename);
                file1.SaveAs(imgpath);
                command3.Parameters.AddWithValue("@prescription1", "/orderimages/" + file1.FileName);
            }

            else
            {
                command3.Parameters.AddWithValue("@prescription1", DBNull.Value);
            }



            if (file2 != null && file2.ContentLength > 0)
            {
                string filename = Path.GetFileName(file2.FileName);

                string imgpath = Path.Combine(Server.MapPath("/orderimages/"), filename);
                file2.SaveAs(imgpath);
                command3.Parameters.AddWithValue("@prescription2", "/orderimages/" + file2.FileName);
            }

            else
            {
                command3.Parameters.AddWithValue("@prescription2", DBNull.Value);
            }


            if (file3 != null && file3.ContentLength > 0)
            {
                string filename = Path.GetFileName(file3.FileName);

                string imgpath = Path.Combine(Server.MapPath("/orderimages/"), filename);
                file3.SaveAs(imgpath);
                command3.Parameters.AddWithValue("@prescription3", "/orderimages/" + file3.FileName);
            }

            else
            {
                command3.Parameters.AddWithValue("@prescription3", DBNull.Value);
            }

            command3.ExecuteNonQuery();
            con.Close();


            double deliverycharge = 60.0;

            String query5 = "INSERT into Payment(CustomerId,OrderId,Amount,DeliveryCharge) " +
                            "values(@customerid,@orderid,@amount,@deliverycharge)";

            SqlCommand command5 = new SqlCommand(query5, con);

            con.Open();
            command5.Parameters.AddWithValue("@customerid", obj.id);

            command5.Parameters.AddWithValue("@orderid", orderid.ToString());
            command5.Parameters.AddWithValue("@amount", amount);
            command5.Parameters.AddWithValue("@deliverycharge", deliverycharge);


            command5.ExecuteNonQuery();
            con.Close();

            String query4 = "Delete from Cart where UserId = " + UserController.id;

            con.Open();
            SqlCommand command4 = new SqlCommand(query4, con);


            command4.ExecuteNonQuery();

            con.Close();

            return(RedirectToAction("Index", "Customer"));
        }
Beispiel #10
0
        public ActionResult Order()
        {
            customerModel obj = new customerModel();

            return(View(obj));
        }