Esempio n. 1
0
 protected void lbxProdType_TextChanged(object sender, EventArgs e)
 {
     int.TryParse(lbxProdType.SelectedValue, out typeId);
     if (typeId == 0)
     {
         loadManufacturers();
         //lbxManufacturer.SelectedValue = "0";
     }
     else
     {
         using (var context = new cathlabEntities())
         {
             List <Manufacturer> temp = (from prod in context.Products
                                         where prod.PartNumber1.ProductTypeID == typeId
                                         select prod.PartNumber1.Manufacturer).Distinct().ToList();
             Manufacturer a = new Manufacturer();
             a.ID = 0; a.Name = "All";
             temp.Insert(0, a);
             lbxManufacturer.DataTextField  = "Name";
             lbxManufacturer.DataValueField = "ID";
             lbxManufacturer.DataSource     = temp;
             lbxManufacturer.DataBind();
         }
     }
     rgInventory.Rebind();
     lbxLocation.DataSource = null;
     lbxLocation.DataBind();
     //lbxManufacturer.SelectedValue = "0";
     //lbxLocation.SelectedValue = "0";
 }
Esempio n. 2
0
 protected void rgManufacturers_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
 {
     using (var context = new cathlabEntities())
     {
         int         pnum = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString());
         ProductType pt   = context.ProductTypes.Find(ID);
     }
 }
Esempio n. 3
0
 protected void rgProdType_UpdateCommand(object sender, GridCommandEventArgs e)
 {
     using (var context = new cathlabEntities())
     {
         int         ID = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString());
         ProductType pt = context.ProductTypes.Find(ID);
         pt.Type = (e.Item.FindControl("tbType") as RadTextBox).Text;
         context.SaveChanges();
     }
 }
Esempio n. 4
0
 protected void loadLocs()
 {
     using (var context = new cathlabEntities())
     {
         List <Location> temp = (from loc in context.Locations select loc).ToList();
         lbxLoc.DataValueField = "ID";
         lbxLoc.DataTextField  = "LocationName";
         lbxLoc.DataSource     = temp;
         lbxLoc.DataBind();
     }
 }
Esempio n. 5
0
        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DateTime upper = DateTime.Today.AddDays(days).AddHours(23).AddMinutes(59);

            using (var context = new cathlabEntities())
            {
                var temp = (from prod in context.Products
                            where prod.ExpirationDate >= DateTime.Today && prod.ExpirationDate <= upper
                            select new { prod.ExpirationDate, prod.Location.LocationName, prod.PartNumber1.NameSize }).AsEnumerable()
                           .Select(a => new { ExpirationDate = a.ExpirationDate.Value.ToLongDateString(), a.NameSize, a.LocationName });
                RadGrid1.DataSource = temp.ToList();
            }
        }
Esempio n. 6
0
 protected void btnInsertProduct_Click(object sender, EventArgs e)
 {
     using (var context = new cathlabEntities())
     {
         Product prod = new Product();
         prod.PartNumber     = txtPartNum.Text;
         prod.LotNumber      = (txtLotNumber.Text != null) ? int.Parse(txtLotNumber.Text) : -1;
         prod.ExpirationDate = rdpExpiration.SelectedDate;
         prod.LocationID     = int.Parse(lbxLoc.SelectedValue);
         context.Products.Add(prod);
         context.SaveChanges();
     }
 }
Esempio n. 7
0
 protected void tbPNSearch_TextChanged(object sender, EventArgs e)
 {
     if (tbPNSearch.Text != string.Empty)
     {
         using (var context = new cathlabEntities())
             rgPartNumbers.DataSource = (from pnum in context.PartNumbers select new { pnum.PartNum, pnum.NameSize, pnum.ProductType.Type, pnum.Cost, pnum.Manufacturer.Name, pnum.Par })
                                        .Where(a => a.PartNum.Contains(tbPNSearch.Text)).ToList();
     }
     else
     {
         rgPartNumbers.Rebind();
     }
 }
Esempio n. 8
0
 protected void loadProductTypes()
 {
     using (var context = new cathlabEntities())
     {
         List <ProductType> temp = (from prodtype in context.ProductTypes select prodtype).ToList();
         ProductType        a    = new ProductType();
         a.ID = 0; a.Type = "ALL";
         temp.Insert(0, a);
         lbxProdType.DataValueField = "ID";
         lbxProdType.DataTextField  = "Type";
         lbxProdType.DataSource     = temp;
         lbxProdType.DataBind();
     }
 }
Esempio n. 9
0
        protected void rgInventory_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;

            using (var context = new cathlabEntities())
            {
                string PartNum    = dataItem.GetDataKeyValue("PartNumber").ToString();
                int    LocationID = (int)dataItem.GetDataKeyValue("LocationID");
                var    temp       = (from prod in context.Products
                                     where prod.PartNumber == PartNum && prod.LocationID == LocationID
                                     select new { prod.Location.LocationName, prod.LotNumber, prod.SerialNumber, prod.ExpirationDate });
                e.DetailTableView.DataSource = temp.ToList();
            }
        }
Esempio n. 10
0
 protected void loadLocations()
 {
     using (var context = new cathlabEntities())
     {
         List <Location> temp = (from loc in context.Locations select loc).ToList();
         Location        a    = new Location();
         a.ID = 0; a.LocationName = "All";
         temp.Insert(0, a);
         lbxLocation.DataValueField = "ID";
         lbxLocation.DataTextField  = "LocationName";
         lbxLocation.DataSource     = temp;
         lbxLocation.DataBind();
     }
 }
Esempio n. 11
0
 protected void loadManufacturers()
 {
     using (var context = new cathlabEntities())
     {
         List <Manufacturer> temp = (from man in context.Manufacturers select man).ToList();
         Manufacturer        a    = new Manufacturer();
         a.ID = 0; a.Name = "All";
         temp.Insert(0, a);
         lbxManufacturer.DataValueField = "ID";
         lbxManufacturer.DataTextField  = "Name";
         lbxManufacturer.DataSource     = temp;
         lbxManufacturer.DataBind();
     }
 }
Esempio n. 12
0
        protected void GetExpiredRange()
        {
            DateTime upper = DateTime.Today.AddDays(days).AddHours(23).AddMinutes(59);

            using (var context = new cathlabEntities())
            {
                var temp = (from prod in context.Products
                            where prod.ExpirationDate >= DateTime.Today && prod.ExpirationDate <= upper
                            select new { prod.ExpirationDate.Value, prod.ExpirationDate.Value.Month, prod.ExpirationDate.Value.Day, prod.PartNumber1.NameSize, prod.Location.LocationName })
                           .OrderBy(a => a.Month).ThenBy(a => a.Day);
                RadGrid1.MasterTableView.DataSource = temp.ToList();
                RadGrid1.MasterTableView.DataBind();
            }
        }
Esempio n. 13
0
 protected void rgPartNumbers_UpdateCommand(object sender, GridCommandEventArgs e)
 {
     if (e.CommandName == "Update")
     {
         using (var context = new cathlabEntities())
         {
             int        PNum = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PartNum"].ToString());
             PartNumber pn   = context.PartNumbers.Find(PNum);
             pn.NameSize = (e.Item.FindControl("tbNameSize") as RadTextBox).Text;
             pn.Cost     = int.Parse((e.Item.FindControl("tbCost") as RadTextBox).Text);
             pn.Par      = int.Parse((e.Item.FindControl("tbPar") as RadTextBox).Text);
             context.SaveChanges();
         }
     }
 }
Esempio n. 14
0
 protected void rgInventory_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     using (var context = new cathlabEntities())
     {
         var temp = context.GetProductCounts().AsEnumerable();
         //(from prod in context.Products
         //        select new
         //        {
         //            prod.ID,
         //            prod.PartNumber,
         //            prod.PartNumber1,
         //            prod.PartNumber1.NameSize,
         //            prod.PartNumber1.ProductType.Type,
         //            prod.Location.LocationName,
         //            prod.PartNumber1.Manufacturer.Name,
         //            prod.LocationID,
         //            //prod.SerialNumber,
         //            //prod.ExpirationDate,
         //            //prod.PartNumber1.NameSize
         //        }).Distinct();
         //            //.Select(prod => new
         //            //{
         //            //    prod.ID,
         //            //    prod.PartNumber,
         //            //    Manufacturer = prod.Name,
         //            //    prod.PartNumber1.NameSize,
         //            //    //Count = (from p in context.Products where p.PartNumber == prod.PartNumber select p).Count(),
         //            //    Count = 8,
         //            //    prod.PartNumber1.ProductType.Type,
         //            //    prod.PartNumber1,
         //            //    prod.LocationID,
         //            //});
         if (typeId != 0)
         {
             temp = temp.Where(a => a.ProductTypeID == typeId);
         }
         if (manId != 0)
         {
             temp = temp.Where(a => a.ManufacturerID == manId);
         }
         if (locId != 0)
         {
             temp = temp.Where(a => a.LocationID == locId);
         }
         rgInventory.MasterTableView.DataSource = temp.ToList();
     }
 }
Esempio n. 15
0
        protected void autopopulate()
        {
            string part = txtPartNum.Text;

            using (var context = new cathlabEntities())
            {
                var temp = (from pnum in context.PartNumbers
                            where pnum.PartNum == part
                            select new { pnum.Manufacturer.Name, pnum.NameSize, pnum.ProductType.Type }).SingleOrDefault();
                if (temp != null)
                {
                    txtManufacturer.Text = temp.Name;
                    txtNameSize.Text     = temp.NameSize;
                    txtProdType.Text     = temp.Type;
                }
            }
        }
Esempio n. 16
0
 protected void aspLogin_LoggingIn(object sender, LoginCancelEventArgs e)
 {
     using (var context = new cathlabEntities())
     {
         Login login = (from log in context.Logins where log.UserName == loginControl.UserName && log.Password == loginControl.Password select log).FirstOrDefault();
         if (login != null)
         {
             Session["LoggedIn"] = login.Id;
             Response.Redirect("~/Inventory/Inventory.aspx");
         }
         else
         {
             e.Cancel = true;
             lblLoginStatus.Visible   = true;
             loginControl.FailureText = "Invalid Login";
         }
     }
 }
Esempio n. 17
0
        protected void rgManufacturers_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            GridDataItem item = (GridDataItem)e.Item;
            int          ID   = (int)item.GetDataKeyValue("ID");

            using (var context = new cathlabEntities())
            {
                Manufacturer m = context.Manufacturers.Find(ID);
                try
                {
                    context.Manufacturers.Remove(m);
                    context.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    rnLabel.Text = "ERROR! Can't delete manufacturer. Products in database rely on this entry.";
                    RadNotification.Show();
                }
            }
        }
Esempio n. 18
0
        protected void rgPartNumbers_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            GridDataItem item    = (GridDataItem)e.Item;
            string       PartNum = item.GetDataKeyValue("PartNum").ToString();

            using (var context = new cathlabEntities())
            {
                PartNumber pn = context.PartNumbers.Find(PartNum);
                try
                {
                    context.PartNumbers.Remove(pn);
                    context.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    rnLabel.Text = "ERROR! Cannot delete, there are products<br/> in the database of that part number.";
                    RadNotification.Show();
                }
            }
        }
Esempio n. 19
0
        protected void rgProdType_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            GridDataItem item = (GridDataItem)e.Item;
            int          ID   = (int)item.GetDataKeyValue("ID");

            using (var context = new cathlabEntities())
            {
                ProductType pt   = context.ProductTypes.Find(ID);
                var         temp = (from prod in context.Products
                                    where prod.PartNumber1.ProductTypeID == pt.ID
                                    select prod).FirstOrDefault();

                if (temp == null)
                {
                    context.ProductTypes.Remove(pt);
                    context.SaveChanges();
                    rgProdType.Rebind();
                }
                else
                {
                    rnLabel.Text = "ERROR! Can't delete product type. Products in database rely on this entry.";
                    RadNotification.Show();
                }

                //try
                //{
                //    context.ProductTypes.Remove(pt);
                //    context.SaveChanges();
                //}
                //catch (Exception)
                //{
                //    rnLabel.Text = "ERROR! Can't delete product type. Products in database rely on this entry.";
                //    RadNotification.Show();
                //}
            }
        }
Esempio n. 20
0
 protected void lbxManufacturer_TextChanged(object sender, EventArgs e)
 {
     int.TryParse(lbxManufacturer.SelectedValue, out manId);
     if (manId == 0)
     {
         loadLocations();
         //lbxLocation.SelectedValue = "0";
     }
     else
     {
         using (var context = new cathlabEntities())
         {
             var temp = (from prod in context.Products
                         where prod.PartNumber1.ManufacturerID == manId && prod.PartNumber1.ProductTypeID == typeId
                         select new { ID = prod.LocationID, Name = prod.Location.LocationName }).Distinct().ToList();
             lbxLocation.DataTextField  = "Name";
             lbxLocation.DataValueField = "ID";
             lbxLocation.DataSource     = temp;
             lbxLocation.DataBind();
         }
     }
     rgInventory.Rebind();
     //lbxLocation.SelectedValue = "0";
 }
Esempio n. 21
0
 protected void rgManufacturers_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     using (var context = new cathlabEntities())
         rgManufacturers.DataSource = (from man in context.Manufacturers select new { man.ID, man.Name, man.PhoneNumber, man.Email }).ToList();
 }
Esempio n. 22
0
 protected void rgProdType_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     using (var context = new cathlabEntities())
         rgProdType.DataSource = (from types in context.ProductTypes select new { types.ID, types.Type }).ToList();
 }
Esempio n. 23
0
 protected void rgPartNumbers_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     using (var context = new cathlabEntities())
         rgPartNumbers.DataSource = (from pnum in context.PartNumbers select new { pnum.PartNum, pnum.NameSize, pnum.ProductType.Type, pnum.Cost, pnum.Manufacturer.Name, pnum.Par }).ToList();
 }