Ejemplo n.º 1
0
        public JsonResult DeleteBike(int id)
        {
            if (ContextManager.Current.UserKey == null)
                return Json(new { Success = true, LoggedIn = false });
            else
            {
                var context = new DAL.DataClassesDataContext();
                var item = context.items.Where(i => i.id == id && i.user_key == ContextManager.Current.UserKey).SingleOrDefault();

                context.items.DeleteOnSubmit(item);
                context.SubmitChanges();

                HttpContext.Application["totalNumberOfBikesRegistered"] = Convert.ToInt32(HttpContext.Application["totalNumberOfBikesRegistered"]) - 1;

                return Json(new { Success = true, LoggedIn = true });
            }
        }
Ejemplo n.º 2
0
        public JsonResult StoreBike(item item)
        {
            if (ContextManager.Current.UserKey == null)
                return Json(new { Success = true, LoggedIn = false });
            else
            {
                var context = new DAL.DataClassesDataContext();
                //var item = new DAL.DataClassesDataContext().items.Where(i => i.serial_no == serialNo).SingleOrDefault();
                item.user_key = ContextManager.Current.UserKey;
                context.items.InsertOnSubmit(item);
                context.SubmitChanges();

                HttpContext.Application["totalNumberOfBikesRegistered"] = Convert.ToInt32(HttpContext.Application["totalNumberOfBikesRegistered"]) + 1;

                return Json(new { Success = true, LoggedIn = true });
            }
        }
Ejemplo n.º 3
0
        public List <ServiceForUpdateBO> getServiceReportBW(string from, string to)
        {
            string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\BCS DATA\Samester 6\C Sharp\Assingment 1\DAL\styloDatabase.mdf;Integrated Security=True";

            using (DataClassesDataContext data = new DataClassesDataContext(constr))
            {
                var check = from p in data.Items
                            join c in data.Services
                            on p.PID equals c.PID
                            select new
                {
                    p.PID,
                    p.Price,
                    p.Category,
                    p.Size,
                    p.Color,
                    p.Brand,
                    p.Date,
                    c.Customer_Name,
                    c.Address,
                    c.Phone,
                    c.Charges,
                    c.Service_Date,
                    c.Return_Date
                };
                if (check.Any())
                {
                    List <ServiceForUpdateBO> ls = new List <ServiceForUpdateBO>();
                    foreach (var i in check)
                    {
                        if (DateTime.Parse(i.Service_Date) >= DateTime.Parse(from) && DateTime.Parse(i.Service_Date) <= DateTime.Parse(to))
                        {
                            ServiceForUpdateBO itBO = new ServiceForUpdateBO();
                            itBO.Pid      = i.PID;
                            itBO.Price    = (int)i.Price;
                            itBO.Category = i.Category;
                            itBO.Size     = (int)i.Size;
                            itBO.Color    = i.Color;
                            itBO.Brand    = i.Brand;

                            itBO.CustomerName = i.Customer_Name;
                            itBO.Address      = i.Address;
                            itBO.Phone        = i.Phone;
                            itBO.Charges      = (int)i.Charges;
                            itBO.ServiceDate  = i.Service_Date;
                            itBO.ReturnDate   = i.Return_Date;
                            itBO.ReturnDate   = i.Return_Date;
                            itBO.Date         = i.Date;

                            //itBO.Quantity = (int)i.Quantity;
                            ls.Add(itBO);
                        }
                    }
                    return(ls);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 4
0
        public JsonResult SearchBike(String serialNo)
        {
            var item = new DAL.DataClassesDataContext().items.Where(i => i.serial_no == serialNo).SingleOrDefault();

            return Json(new { Found = item != null });
        }
Ejemplo n.º 5
0
        public ServiceForUpdateBO searchToUpdateIteam(ServiceForUpdateBO item)
        {
            string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\BCS DATA\Samester 6\C Sharp\Assingment 1\DAL\styloDatabase.mdf;Integrated Security=True";

            using (DataClassesDataContext data = new DataClassesDataContext(constr))
            {
                var check = from p in data.Items
                            join c in data.Services
                            on p.PID equals c.PID
                            select new {
                    c.PID,
                    p.Price,
                    p.Category,
                    p.Size,
                    p.Color,
                    p.Brand,
                    p.Date,
                    c.Customer_Name,
                    c.Address,
                    c.Phone,
                    c.Charges,
                    c.Service_Date,
                    c.Return_Date
                };
                int flag = 0;
                if (check.Any())
                {
                    ServiceForUpdateBO itBO = new ServiceForUpdateBO();
                    foreach (var i in check)
                    {
                        if (i.PID == item.Pid)
                        {
                            itBO.Pid          = i.PID;
                            itBO.Price        = (int)i.Price;
                            itBO.Category     = i.Category;
                            itBO.Size         = (int)i.Size;
                            itBO.Color        = i.Color;
                            itBO.Brand        = i.Brand;
                            itBO.Date         = i.Date;
                            itBO.CustomerName = i.Customer_Name;
                            itBO.Address      = i.Address;
                            itBO.Phone        = i.Phone;
                            itBO.Charges      = (int)i.Charges;
                            itBO.ServiceDate  = i.Service_Date;
                            itBO.ReturnDate   = i.Return_Date;
                            flag = 1;
                            break;
                        }
                        if (flag == 1)
                        {
                            break;
                        }
                    }
                    if (itBO.Quantity == 0 && flag == 1)
                    {
                        return(itBO);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }