Example #1
0
        public ActionResult ToCompleteInbound(string InboundPlanCode, string Result)
        {
            INinboundPlan plan = (from c in db.INinboundPlans where c.InboundPlanCode == InboundPlanCode select c).FirstOrDefault();

            plan.PrintStatus     = "Printed";
            plan.InboundStatus   = Result;
            db.Entry(plan).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult DeleteInboundPlan(string InboundPlanCode)
        {
            INinboundPlan inboundplan = new INinboundPlan();

            inboundplan = (from u in db.INinboundPlans.ToList()
                           where u.InboundPlanCode == InboundPlanCode
                           select u).FirstOrDefault();
            inboundplan.Is_Deleted      = true;
            inboundplan.Update_Date     = DateTime.Now;
            inboundplan.Update_User     = user.UserID;
            db.Entry(inboundplan).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public ActionResult EditInboundPlan(INinboundPlan InboundPlan)
        {
            try
            {
                INinboundPlan inbound = new INinboundPlan();
                inbound = (from u in db.INinboundPlans.ToList()
                           where u.ID == InboundPlan.ID
                           select u).FirstOrDefault();
                inbound.InboundPlanDate  = InboundPlan.InboundPlanDate;
                inbound.CodeSupplier     = InboundPlan.CodeSupplier;
                inbound.SlipNo           = InboundPlan.SlipNo;
                inbound.SlipClass        = InboundPlan.SlipClass;
                inbound.SlipDate         = InboundPlan.SlipDate;
                inbound.CodeClassInbound = InboundPlan.CodeClassInbound;
                inbound.Remarks          = InboundPlan.Remarks;
                inbound.CodeOwner        = InboundPlan.CodeOwner;

                inbound.Update_User = "******";
                inbound.Update_Date = DateTime.Now;

                INinboundPlan checker = (from c in db.INinboundPlans
                                         where c.InboundPlanCode == c.InboundPlanCode &&
                                         inbound.InboundPlanDate == c.InboundPlanDate &&
                                         inbound.CodeSupplier == c.CodeSupplier &&
                                         inbound.SlipNo == c.SlipNo &&
                                         inbound.SlipClass == c.SlipClass &&
                                         inbound.SlipDate == c.SlipDate &&
                                         inbound.CodeClassInbound == c.CodeClassInbound &&
                                         inbound.Remarks == c.Remarks &&
                                         inbound.CodeOwner == c.CodeOwner
                                         select c).FirstOrDefault();
                if (checker == null)
                {
                    db.Entry(inbound).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    return(Json(new { result = "failed" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception err) { }

            return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CreateStockInventory(INinboundPlan inboundplan)
        {
            STstockInventory StockInventory = new STstockInventory();

            StockInventory.OwnerCode = (from c in db.INinboundPlans where c.InboundPlanCode == inboundplan.InboundPlanCode select c.CodeOwner).FirstOrDefault();
            string DateID      = DateTime.Now.ToString("yyyyMMdd");
            string gencode     = string.Empty;
            string lastgencode = (from u in db.STstockInventories.ToList()
                                  orderby u.StockCode descending
                                  select u.StockCode).FirstOrDefault();

            if (lastgencode == null)
            {
                gencode = DateID + "STK0000001";
            }
            else
            {
                gencode = lastgencode.Substring(11);
                int upId = Convert.ToInt32(gencode.TrimStart(new char[] { '0' })) + 1;
                gencode = DateID + string.Format("STK{0}", upId.ToString().PadLeft(7, '0'));
            }
            StockInventory.InboundPlanCode = inboundplan.InboundPlanCode;
            StockInventory.SiteCode        = inboundplan.SiteCode;
            StockInventory.StockCode       = gencode;
            StockInventory.Is_Deleted      = false;
            StockInventory.Create_Date     = DateTime.Now;
            StockInventory.Create_User     = user.UserID;
            StockInventory.Update_Date     = DateTime.Now;
            StockInventory.Update_User     = user.UserID;
            try
            {
                db.STstockInventories.Add(StockInventory);
                db.SaveChanges();
            }
            catch (Exception err) { }



            return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public ActionResult CreateInboundPlan(INinboundPlan InboundPlan)
        {
            string DateID      = DateTime.Now.ToString("yyyyMMdd");
            string gencode     = string.Empty;
            string lastgencode = (from u in db.INinboundPlans.ToList()
                                  orderby u.InboundPlanCode descending
                                  select u.InboundPlanCode).FirstOrDefault();

            if (lastgencode == null)
            {
                gencode = DateID + "INB0000001";
            }
            else
            {
                gencode = lastgencode.Substring(11);
                int upId = Convert.ToInt32(gencode.TrimStart(new char[] { '0' })) + 1;
                gencode = DateID + string.Format("INB{0}", upId.ToString().PadLeft(7, '0'));
            }

            InboundPlan.PrintStatus     = "Not Printed";
            InboundPlan.InboundStatus   = "Not Received";
            InboundPlan.InboundPlanCode = gencode;
            InboundPlan.Is_Deleted      = false;
            InboundPlan.Create_Date     = DateTime.Now;
            InboundPlan.Create_User     = user.UserID;
            InboundPlan.Update_Date     = DateTime.Now;
            InboundPlan.Update_User     = user.UserID;
            try {
                db.INinboundPlans.Add(InboundPlan);
                db.SaveChanges();
            }
            catch (Exception err) { }



            return(Json(new { result = "success", InboundPlan = InboundPlan }, JsonRequestBehavior.AllowGet));
        }
Example #6
0
        public ActionResult SetInbound(INinboundSet InboundItem, STstockInventoryDetail stockdetails, ItemUnitModel itemunit)
        {
            InboundItem.Is_Deleted  = false;
            InboundItem.Create_Date = DateTime.Now;
            InboundItem.Create_User = user.UserID;
            InboundItem.Update_Date = DateTime.Now;
            InboundItem.Update_User = user.UserID;
            string DateID      = DateTime.Now.ToString("yyyyMMdd");
            string gencode     = string.Empty;
            string lastgencode = (from u in db.INinboundSets.ToList()
                                  orderby u.InboundNoResult descending
                                  select u.InboundNoResult).FirstOrDefault();

            if (lastgencode == null)
            {
                gencode = DateID + "INR0000001";
            }
            else
            {
                gencode = lastgencode.Substring(11);
                int upId = Convert.ToInt32(gencode.TrimStart(new char[] { '0' })) + 1;
                gencode = DateID + string.Format("INR{0}", upId.ToString().PadLeft(7, '0'));
            }
            InboundItem.InboundNoResult = gencode;
            try
            {
                db.INinboundSets.Add(InboundItem);
                db.SaveChanges();

                string gencodes     = string.Empty;
                string lastgencodes = (from u in db.STstockInventoryDetails.ToList()
                                       orderby u.StockDetailCode descending
                                       select u.StockDetailCode).FirstOrDefault();
                if (lastgencodes == null)
                {
                    gencodes = DateID + "STD0000001";
                }
                else
                {
                    gencodes = lastgencodes.Substring(11);
                    int upId = Convert.ToInt32(gencodes.TrimStart(new char[] { '0' })) + 1;
                    gencodes = DateID + string.Format("STD{0}", upId.ToString().PadLeft(7, '0'));
                }

                INinboundPlan inboundplan      = (from c in db.INinboundPlans where c.InboundPlanCode == InboundItem.InboundPlanCode select c).FirstOrDefault();
                mItem         itemcurrent_main = (from c in db.mItems where c.ItemCode == InboundItem.ItemCode select c).FirstOrDefault();
                INinboundItem inboundplanitem  = (from c in db.INinboundItems where c.InboundPlanCode == InboundItem.InboundPlanCode && c.ItemCode == itemcurrent_main.ItemCode select c).FirstOrDefault();

                stockdetails.StockCode        = (from c in db.STstockInventories where c.InboundPlanCode == InboundItem.InboundPlanCode select c.StockCode).FirstOrDefault();
                stockdetails.InboundPlanNo    = inboundplan.InboundPlanCode;
                stockdetails.InboundNoResult  = gencode;  //Inbound result Gen code
                stockdetails.StockDetailCode  = gencodes; //Stock Details Code
                stockdetails.ItemCode         = inboundplanitem.ItemCode;
                stockdetails.ExpiredDate      = inboundplanitem.ExpirationDate;
                stockdetails.InboundDate      = inboundplan.InboundPlanDate;
                stockdetails.ActualStockQty   = InboundItem.ActualReceived;
                stockdetails.AllocatedQty     = 0;
                stockdetails.PickedQty        = 0;
                stockdetails.LocationCode     = InboundItem.Location;
                stockdetails.LocationSubCode  = InboundItem.SubLocation;
                stockdetails.LotNo            = inboundplanitem.LotNo;
                stockdetails.PONo             = inboundplanitem.PoNo;
                stockdetails.SupplierCode     = itemcurrent_main.CusSupCode;
                stockdetails.SupplierCode     = itemcurrent_main.CusSupCode;
                stockdetails.OriginalItemCode = itemcurrent_main.ItemCode;
                stockdetails.CaseQty          = itemunit.pqc_q;
                stockdetails.QtyPerCase       = itemunit.QtyPerCase;
                stockdetails.InnerCaseQty     = itemunit.qpic_q;
                stockdetails.InnerQtyPerCase  = itemunit.QtyPerInnerCase;
                stockdetails.UnitQty          = itemunit.QtyPerUnit;
                //stockdetails.NW = (itemunit.QtyPerCase + itemunit.QtyPerInnerCase + itemunit.QtyPerUnit) * itemcurrent_unit.Where(c => c.Type == "") sa sunod na to
                stockdetails.LastInboundDate = DateTime.Now;
                //stockdetails.LastOutboundDate = DateTime.Now;
                stockdetails.SlipClass   = inboundplan.SlipClass;
                stockdetails.SlipDate    = inboundplan.SlipDate;
                stockdetails.SlipNo      = inboundplan.SlipNo;
                stockdetails.SlipRemarks = inboundplan.Remarks;
                stockdetails.Is_Deleted  = false;
                stockdetails.Create_Date = DateTime.Now;
                stockdetails.Create_User = user.UserID;
                stockdetails.Update_Date = DateTime.Now;
                stockdetails.Update_User = user.UserID;
                db.STstockInventoryDetails.Add(stockdetails);
                db.SaveChanges();
            }
            catch (Exception err) { }
            return(Json(new { result = "success", InboundItem = InboundItem }, JsonRequestBehavior.AllowGet));
        }