예제 #1
0
        public ActionResult Delete(int id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];
            //ViewBag.IsConfigMenu = 0;

            //start Logging
            int UserID = Convert.ToInt32(Session["UserId"]);
            //String Username = Session["Username"].ToString();
            //string CompleteModificationdetail = "Deleted MachineDetails";
            //Action = "Delete";
            //ActiveLogStorage Obj = new ActiveLogStorage();
            //Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail);
            //End
            tblmachinedetail tblmachine = db.tblmachinedetails.Find(id);

            tblmachine.IsDeleted       = 1;
            tblmachine.ModifiedBy      = UserID;
            tblmachine.DeletedDate     = DateTime.Now.ToString("yyyy-MM-dd");
            db.Entry(tblmachine).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Edit(tblmachinedetail tblmachine, int Shop = 0, int Plant = 0, int Cell = 0)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];
            int UserID = Convert.ToInt32(Session["UserID"]);

            tblmachine.ModifiedBy = UserID;
            tblmachine.ModifiedOn = System.DateTime.Now;
            {
                if (ModelState.IsValid)
                {
                    #region Active Log Code
                    //tblmachinedetail OldData = db.tblmachinedetails.Find(tblmachine.MachineID);
                    //String Username = Session["Username"].ToString();
                    //IEnumerable<string> FullData = ActiveLog.EnumeratePropertyDifferences<tblmachinedetail>(OldData, tblmachine);
                    //ICollection<tblmachinedetail> c = FullData as ICollection<tblmachinedetail>;
                    //int Count = c.Count;
                    //if (Count != 0)
                    //{
                    //    string CompleteModificationdetail = null;
                    //    for (int i = 0; i < Count; i++)
                    //    {
                    //        CompleteModificationdetail = CompleteModificationdetail + "-" + FullData.Take(i).ToArray();
                    //    }
                    //    Action = "Edit";
                    //    ActiveLogStorage Obj = new ActiveLogStorage();
                    //    Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail);
                    //}
                    #endregion //End Active Log

                    var shopname = db.tblshops.Where(m => m.IsDeleted == 0 && m.ShopID == tblmachine.ShopID).Select(m => m.ShopName).FirstOrDefault();
                    tblmachine.ShopNo = shopname.ToString();

                    //tblmachine.PlantID = Plant;
                    //tblmachine.ShopID = Shop;
                    //if (Cell != 0)
                    //{
                    //    tblmachine.CellID = Cell;
                    //}
                    db.Entry(tblmachine).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.Plant = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", tblmachine.PlantID);
            ViewBag.Shop  = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == tblmachine.PlantID), "ShopID", "ShopName", tblmachine.ShopID);
            ViewBag.Cell  = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0 && m.ShopID == tblmachine.ShopID), "CellID", "CellName", tblmachine.CellID);
            ViewBag.WC    = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.ShopID == tblmachine.ShopID && m.CellID == tblmachine.CellID), "MachineInvNo", "MachineInvNo", tblmachine.MachineInvNo);

            return(View(tblmachine));
        }
        public string FetchMachine(int CID)
        {
            string res           = "";
            var    sensormachine = db.configurationtblmachinesensors.Where(m => m.IsDeleted == 0).Select(m => m.MachineId).Distinct().ToList();

            foreach (var sensormachinedet in sensormachine)
            {
                tblmachinedetail obj = new tblmachinedetail();
                var machinedet       = (from m in db.tblmachinedetails where m.IsDeleted == 0 && m.CellID == CID && m.MachineID == sensormachinedet select new { Value = m.MachineID, Text = m.MachineDisplayName }).ToList();
                res = JsonConvert.SerializeObject(machinedet);
            }
            return(res);
        }
        public tblmachinedetail GettblmachineDet3(int MachineID)
        {
            tblmachinedetail ddldet             = new tblmachinedetail();
            Repository <tblmachinedetail> lista = new Repository <tblmachinedetail>();

            try
            {
                string query = "SELECT IsNormalWC from [i_facility_TSAL].[dbo].tblmachinedetails WHERE MachineID =" + MachineID + "";
                ddldet = lista.GetFirstOrDefault(query, _connectionFactory.GetConnection);
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.ToString());
            }
            return(ddldet);
        }
예제 #5
0
        public ActionResult EditMachine(int Id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }

            tblmachinedetail machine = db.tblmachinedetails.Find(Id);

            if (machine == null)
            {
                return(HttpNotFound());
            }
            int plantid = Convert.ToInt32(machine.PlantID);

            ViewBag.Plant = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", machine.PlantID);
            ViewBag.dept  = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0), "ShopId", "ShopName", machine.ShopID);
            ViewBag.cell  = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0), "CellID", "CellName", machine.CellID);
            return(View(machine));
        }
예제 #6
0
        public ActionResult MachineList()
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }

            ViewBag.plant = new SelectList(db.tblplants.Where(p => p.IsDeleted == 0), "PlantID", "PlantDisplayName");
            ViewBag.dept  = new SelectList(db.tblshops.Where(d => d.IsDeleted == -1), "ShopId", "ShopDisplayName");
            ViewBag.cell  = new SelectList(db.tblcells.Where(m => m.IsDeleted == -1), "CellId", "CellDisplayName");
            MachineModel     ma = new MachineModel();
            tblmachinedetail me = new tblmachinedetail();

            ma.Machine     = me;
            ma.MachineList = db.tblmachinedetails.Where(x => x.IsDeleted == 0).ToList();
            return(View(ma));

            //var machine = db.mastermachine_tbl.Where(x => x.IsDeleted == 0);
            //return View(machine.ToList());
        }
예제 #7
0
        public ActionResult Create(tblmachinedetail tblmachine, int Shop = 0, int Plant = 0, int Cell = 0)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];

            string machineinv     = tblmachine.MachineInvNo;
            var    duplicateEntry = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.PlantID == Plant && m.ShopID == Shop && m.CellID == Cell && m.MachineInvNo == machineinv).ToList();

            if (duplicateEntry.Count == 0)
            {
                tblmachine.InsertedBy   = Convert.ToInt32(Session["UserId"]);
                tblmachine.InsertedOn   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                tblmachine.IsDeleted    = 0;
                tblmachine.IsParameters = 1;
                tblmachine.MachineType  = "2";
                tblmachine.PlantID      = Plant;
                tblmachine.ShopID       = Shop;
                var shopname = db.tblshops.Where(m => m.IsDeleted == 0 && m.ShopID == Shop).Select(m => m.ShopName).FirstOrDefault();
                tblmachine.ShopNo = shopname.ToString();

                if (Cell != 0)
                {
                    tblmachine.CellID = Cell;
                }
                //ActiveLog Code
                int    UserID   = Convert.ToInt32(Session["UserId"]);
                String Username = Session["Username"].ToString();
                string CompleteModificationdetail = "New Creation";
                Action = "Create";
                //ActiveLogStorage Obj = new ActiveLogStorage();
                //Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail);
                //End
                db.tblmachinedetails.Add(tblmachine);
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
예제 #8
0
        //Delete Machine
        public ActionResult DeleteMachine(int id)
        {
            //ViewBag.Logout = Session["Username"].ToString().ToUpper();
            //ViewBag.roleid = Session["RoleID"];
            //String Username = Session["Username"].ToString();
            //int UserID1 = id;
            //ViewBag.IsConfigMenu = 0;

            //start Logging
            // int UserID = Convert.ToInt32(Session["UserId"]);
            // string CompleteModificationdetail = "Deleted Role";
            // Action = "Delete";
            // ActiveLogStorage Obj = new ActiveLogStorage();
            //Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail);
            //End
            tblmachinedetail tblmc = db.tblmachinedetails.Find(id);
            int mcahineid          = tblmc.MachineID;

            tblmc.IsDeleted         = 1;
            tblmc.ModifiedBy        = 1;
            tblmc.ServerTabFlagSync = 1;
            tblmc.ServerTabCheck    = 2;
            tblmc.ModifiedOn        = DateTime.Now;
            db.Entry(tblmc).State   = EntityState.Modified;
            db.SaveChanges();

            //delete corresponding machines
            var machinedata = db.tblcells.Where(m => m.IsDeleted == 0 && m.CellID == mcahineid).ToList();

            foreach (var machinerow in machinedata)
            {
                machinerow.IsDeleted       = 1;
                db.Entry(machinerow).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("MachineList"));
        }
예제 #9
0
        public ActionResult Edit(int id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];
            tblmachinedetail tblmachine = db.tblmachinedetails.Find(id);

            if (tblmachine == null)
            {
                return(HttpNotFound());
            }

            ViewData["ispcb"] = tblmachine.IsPCB;
            ViewBag.Plant     = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", tblmachine.PlantID);
            ViewBag.Shop      = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == tblmachine.PlantID), "ShopID", "ShopName", tblmachine.ShopID);
            ViewBag.Cell      = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0 && m.ShopID == tblmachine.ShopID), "CellID", "CellName", tblmachine.CellID);
            ViewBag.WC        = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.ShopID == tblmachine.ShopID && m.CellID == tblmachine.CellID), "MachineInvNo", "MachineInvNo", tblmachine.MachineInvNo);

            return(View(tblmachine));
        }
예제 #10
0
        public ActionResult EditMachine(tblmachinedetail tblmachine, int dept = 0, int plant = 0, int cell = 0, string Machine = "")
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"].ToString().ToUpper();
            ViewBag.roleid = Session["RoleID"];
            int UserID = Convert.ToInt32(Session["UserID"]);

            tblmachine.PlantID = plant;
            tblmachine.CellID  = cell;
            tblmachine.ShopID  = dept;
            // tblmachine.MachineCategoryID = machinecategory;
            tblmachine.ModifiedBy = UserID;
            tblmachine.ModifiedOn = System.DateTime.Now;
            using (i_facility_unimechEntities db = new i_facility_unimechEntities())
            {
                var duplicateEntry = db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.PlantID == plant && m.ShopID == dept && m.CellID == tblmachine.CellID && m.MachineName == tblmachine.MachineName && m.MachineID != tblmachine.MachineID).ToList();
                if (duplicateEntry.Count == 0)
                {
                    var MachineDet = db.tblmachinedetails.Find(tblmachine.MachineID);

                    MachineDet.CellID             = tblmachine.CellID;
                    MachineDet.ControllerType     = tblmachine.ControllerType;
                    MachineDet.CurrentControlAxis = tblmachine.CurrentControlAxis;
                    MachineDet.IPAddress          = tblmachine.IPAddress;
                    MachineDet.MachineDescription = tblmachine.MachineDescription;
                    MachineDet.MachineDisplayName = tblmachine.MachineDisplayName;
                    MachineDet.MachineMake        = tblmachine.MachineMake;
                    MachineDet.MachineModel       = tblmachine.MachineModel;
                    MachineDet.MachineName        = tblmachine.MachineName;
                    MachineDet.MachineType        = tblmachine.MachineType;
                    MachineDet.ModelType          = tblmachine.ModelType;
                    MachineDet.NoOfAxis           = tblmachine.NoOfAxis;
                    MachineDet.PlantID            = tblmachine.PlantID;
                    MachineDet.ShopID             = tblmachine.ShopID;
                    MachineDet.ServerTabFlagSync  = 1;
                    MachineDet.ServerTabCheck     = 2;
                    MachineDet.IsParameters       = tblmachine.IsParameters;
                    MachineDet.IsPCB           = tblmachine.IsPCB;
                    MachineDet.IsNormalWC      = tblmachine.IsNormalWC;
                    MachineDet.MacConnName     = tblmachine.MacConnName;
                    MachineDet.SpindleAxis     = tblmachine.SpindleAxis;
                    MachineDet.TabIPAddress    = tblmachine.TabIPAddress;
                    MachineDet.EnableLockLogic = tblmachine.EnableLockLogic;
                    MachineDet.ModifiedBy      = tblmachine.ModifiedBy;
                    MachineDet.ModifiedOn      = tblmachine.ModifiedOn;

                    db.Entry(MachineDet).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("MachineList", "Machines"));
                }
                else
                {
                    ViewBag.Plant             = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName", tblmachine.PlantID);
                    ViewBag.dept              = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0), "ShopID", "ShopName", tblmachine.ShopID);
                    ViewBag.MachineCategoryID = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0), "CellID", "CellName", tblmachine.CellID);
                    return(View(tblmachine));
                }
            }
        }