Esempio n. 1
0
 public ActionResult statusChangeOnMarkComplete(int?issueID)
 {
     if (ModelState.IsValid)
     {
         tblIssue updateIssue = pocoDb.Fetch <tblIssue>(" WHERE issueID = @0", issueID).FirstOrDefault();
         updateIssue.issueStatusID = 11;
         pocoDb.Update(updateIssue);
     }
     return(RedirectToAction("Details", "Issues", new { id = issueID }));
 }
Esempio n. 2
0
 public ActionResult statusChangeOnReturnLink(int?issueID)
 {
     if (ModelState.IsValid)
     {
         using (db db = new db())
         {
             tblIssue updateIssue = pocoDb.Fetch <tblIssue>(" WHERE issueID = @0", issueID).FirstOrDefault();
             updateIssue.issueStatusID = 15;
             pocoDb.Update(updateIssue);
         }
     }
     return(RedirectToAction("Details", "Issues", new { id = issueID }));
 }
        //add
        public ActionResult add(string retailID, string local, string lot, string localname, string pacA, string pacB, string small, string med, string large, string xLarge, string date, string isFromReturn)
        {
            //check if issued retail id already exist in the table issuedretailer
            tblIssue       lt = new tblIssue();
            issuedRetailer ir;

            try
            {
                int assignedID = 0;
                int retailId   = Convert.ToInt32(retailID);
                int loc        = Convert.ToInt32(local);
                int lotid      = Convert.ToInt32(lot);
                using (linqDBContext db = new linqDBContext())
                {
                    var checkRetail = (from a in db.issuedRetailers where a.localId == loc && a.retailId == retailId select a).FirstOrDefault();

                    if (checkRetail == null)
                    {
                        ir           = new issuedRetailer();
                        ir.retailId  = retailId;
                        ir.localId   = loc;
                        ir.localName = localname;
                        db.issuedRetailers.Add(ir);
                        db.SaveChanges();
                    }
                    else
                    {
                        ir = checkRetail;
                    }

                    lt.lotId     = lotid;
                    lt.networkID = retailId;
                    lt.packetA   = Convert.ToInt32(pacA);
                    lt.packetB   = Convert.ToInt32(pacB);
                    lt.small     = Convert.ToInt32(small);
                    lt.medium    = Convert.ToInt32(med);
                    lt.large     = Convert.ToInt32(large);
                    lt.xLarge    = Convert.ToInt32(xLarge);
                    lt.issueDate = Convert.ToDateTime(date).Date;
                    if (isFromReturn == "0")
                    {
                        lt.isFromReturn = false;
                    }
                    else
                    {
                        lt.isFromReturn = true;
                    }

                    var mainCatId = (from a in dc.tblLots
                                     where a.id == lotid
                                     select a.mainCatId).ToList().First().Value;
                    int chkCatId = Convert.ToInt32(mainCatId);

                    var mainInv = (from b in dc.tblMainInventries
                                   where b.mainCatId == chkCatId
                                   select b).FirstOrDefault();
                    if (mainInv == null)
                    {
                        throw new Exception("This Category doest not exisit in main inventory!");
                    }


                    int totalS = 0, totalM = 0, totalL = 0, totalXL = 0, tPacA = 0, tPacB = 0;

                    //Previous Qtys
                    try
                    {
                        var ts = (from a in db.tblIssues
                                  where a.lotId == lotid
                                  select a.small.Value).Sum();
                        if (ts > 0)
                        {
                            totalS = ts;
                        }
                    }
                    catch (Exception xz)
                    { }
                    try
                    {
                        var tm = (from a in db.tblIssues
                                  where a.lotId == lotid
                                  select a.medium.Value).Sum();
                        if (tm > 0)
                        {
                            totalM = tm;
                        }
                    }
                    catch (Exception xz)
                    { }
                    try
                    {
                        var tl = (from a in db.tblIssues
                                  where a.lotId == lotid
                                  select a.large.Value).Sum();
                        if (tl > 0)
                        {
                            totalL = tl;
                        }
                    }
                    catch (Exception xz)
                    { }

                    try
                    {
                        var tXL = (from a in db.tblIssues
                                   where a.lotId == lotid
                                   select a.xLarge.Value).Sum();
                        if (tXL > 0)
                        {
                            totalL = tXL;
                        }
                    }
                    catch (Exception xz)
                    { }
                    try
                    {
                        var tA = (from a in db.tblIssues
                                  where a.lotId == lotid
                                  select a.packetA.Value).Sum();
                        if (tA > 0)
                        {
                            tPacA = tA;
                        }
                    }
                    catch (Exception xz)
                    { }
                    try
                    {
                        var tB = (from a in db.tblIssues
                                  where a.lotId == lotid
                                  select a.packetB.Value).Sum();
                        if (tB > 0)
                        {
                            tPacB = tB;
                        }
                    }
                    catch (Exception xz)
                    { }


                    //Check lot
                    var lotQuery = (from us in db.tblLots
                                    where us.id == lotid
                                    select us).FirstOrDefault();
                    if (lotQuery != null)
                    {
                        if ((lt.packetA + tPacA) > lotQuery.packets_A)
                        {
                            throw new Exception("Cannot add more than" + (lotQuery.packets_A.Value - tPacA) + " A packets.");
                        }
                        if ((lt.packetB + tPacB) > lotQuery.packets_B)
                        {
                            throw new Exception("Cannot add more than" + (lotQuery.packets_B.Value - tPacB) + " B packets.");
                        }
                        if ((lt.small + totalS) > lotQuery.small)
                        {
                            throw new Exception("Cannot add more than" + (lotQuery.small.Value - totalS) + " small items.");
                        }
                        if ((lt.medium + totalM) > lotQuery.medium)
                        {
                            throw new Exception("Cannot add more than" + (lotQuery.medium.Value - totalM) + " medium items.");
                        }
                        if ((lt.large + totalL) > lotQuery.large)
                        {
                            throw new Exception("Cannot add more than" + (lotQuery.large.Value - totalL) + " large items.");
                        }
                        if ((lt.xLarge + totalXL) > lotQuery.xLarge)
                        {
                            throw new Exception("Cannot add more than" + (lotQuery.xLarge.Value - totalXL) + " XL items.");
                        }

                        //update main invenrty
                        var query = mainInv;
                        if (query.pacA >= lt.packetA)
                        {
                            query.pacA -= lt.packetA;
                        }
                        else
                        {
                            throw new Exception("Inventry have only " + query.pacA + "  Packet A item(s) left.");
                        }

                        if (query.pacB >= lt.packetB)
                        {
                            query.pacB -= lt.packetB;
                        }
                        else
                        {
                            throw new Exception("Inventry have only  " + query.pacB + " Packet B Item(s) left.");
                        }

                        if (query.small >= lt.small)
                        {
                            query.small -= lt.small;
                        }
                        else
                        {
                            throw new Exception("Inventry have only " + query.small + "  small item(s) left.");
                        }
                        if (query.medium >= lt.medium)
                        {
                            query.medium -= lt.medium;
                        }
                        else
                        {
                            throw new Exception("Inventry have only " + query.medium + "  Medium  item(s)");
                        }
                        if (query.large >= lt.large)
                        {
                            query.large -= lt.large;
                        }
                        else
                        {
                            throw new Exception("Inventry have only " + query.large + " Large item(s)");
                        }
                        if (query.xLarge >= lt.xLarge)
                        {
                            query.xLarge -= lt.xLarge;
                        }
                        else
                        {
                            throw new Exception("inventry have only" + query.xLarge + " xLarge item(s)");
                        }

                        dc.SaveChanges();


                        //saved all changes

                        lt.issuedRetailId = ir.Id;
                        db.tblIssues.Add(lt);
                        db.SaveChanges();
                        assignedID = lt.id;
                    }
                }
                return(Json(new JsonResult()
                {
                    Data = "Done"
                }, JsonRequestBehavior.AllowGet));
            }

            catch (Exception x)
            {
                return(Json(new { status = "error", Data = x.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 4
0
        public ActionResult Create(IssueCreateViewModel model, HttpPostedFileBase postedFile, string button)
        {
            //getting the userID
            string userid = "";

            if (Session["userId"] != null)
            {
                userid = Session["userId"].ToString();
            }
            int userID   = int.Parse(userid);
            int screenID = 0;
            //getting the screenshotID
            string screenShotId = "";

            if (Session["screenshotid"] != null)
            {
                screenShotId = Session["screenshotid"].ToString();
            }
            if (screenShotId != "")
            {
                screenID = int.Parse(screenShotId);
            }


            var person      = pocoDb.Fetch <tblUser>(" WHERE userID = @0", userID).FirstOrDefault();
            var createdbyId = person.userID;
            var personid    = person.PersonID.ToString();
            int personId    = Int32.Parse(personid);

            try
            {
                if (ModelState.IsValid)
                {
                    tblIssue issue = new tblIssue();
                    issue.issueTitle          = model.Issue.issueTitle;
                    issue.issueDescription    = model.Issue.issueDescription;
                    issue.solutionComponentID = model.Issue.solutionComponentID;
                    issue.issueTypeID         = model.Issue.issueTypeID;
                    issue.issueStatusID       = model.Issue.issueStatusID;
                    issue.IssueURL            = model.Issue.IssueURL;
                    issue.CreatedByID         = personId;

                    issue.IsCritical      = model.Issue.IsCritical;
                    issue.browserHeight   = model.Issue.browserHeight;
                    issue.browserWidth    = model.Issue.browserWidth;
                    issue.userAgent       = model.Issue.userAgent;
                    issue.CreatedDate     = DateTime.Now;
                    issue.issueCategoryID = 1;
                    issue.issuePriorityID = 1;
                    if (issue.issueDescription == null)
                    {
                        issue.issueDescription = "";
                    }
                    issue.solutionId = model.Issue.solutionId;
                    pocoDb.Insert(issue);
                    var issueList = pocoDb.Fetch <tblIssue>(" WHERE issueTitle=@0 and issueDescription=@1 and solutionId=@2", model.Issue.issueTitle, model.Issue.issueDescription, model.Issue.solutionId).FirstOrDefault();
                    var issueId   = issueList.issueID;
                    if (postedFile != null)
                    {
                        linkToTblattachment(issueId, postedFile);
                    }
                    if (screenShotId != "")
                    {
                        var screenattachments = pocoDb.Fetch <tblFileAttachment>(" WHERE fileID=@0", screenID).FirstOrDefault();
                        screenattachments.itemID = issueId;
                        pocoDb.Update(screenattachments);
                    }
                    if (button == "Save")
                    {
                        return(RedirectToAction("solutionIssues", "Issues", new { ID = model.Issue.solutionId }));
                    }
                    else if (button == "Save and Add another")
                    {
                        return(RedirectToAction("create", "Issues", new { h = model.Issue.browserHeight, w = model.Issue.browserWidth, b = model.Issue.userAgent, componentid = model.Issue.solutionComponentID, url = model.Issue.IssueURL, solutionid = model.Issue.solutionId }));
                    }
                    else if (button == "Save&Close")
                    {
                        return(RedirectToAction("Index", "Issues"));
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(RedirectToAction("Issues/solutionIssues/ new { id = issue.solutionId }"));
        }