Exemplo n.º 1
0
        public void AddBonderAnnualEntitlementCoE(int?BonderSlno, int id, int[] ProductCoE, string[] ProductWeightCoE, string[] ProductDescriptionCoE, string[] ProductSizeCoE,
                                                  string[] ProductMeasurementCoE, string[] ProductRawmaterialsCoE, int[] ProductMachineCoE, int[] hscodesCoE, int[] RawmaterialProductID,
                                                  int[] measuementoCoE, int[] grossCoEs, int[] wastageCoEs, int[] shrinkageCoEs, int[] netCoEs)
        {
            if (ProductCoE != null)
            {
                int lenth = ProductCoE.Length;

                for (int i = 0; i < lenth; i++)
                {
                    BONDERANNUALENTITLEMENTCOM bonderannualentitlementcom = new BONDERANNUALENTITLEMENTCOM();

                    bonderannualentitlementcom.AESLNO      = (Int16)id;
                    bonderannualentitlementcom.BONDERSLNO  = (Int16)BonderSlno;
                    bonderannualentitlementcom.MSLNO       = (Int16)ProductCoE[i];
                    bonderannualentitlementcom.WEIGHT      = ProductWeightCoE[i];
                    bonderannualentitlementcom.MSIZE       = ProductSizeCoE[i];
                    bonderannualentitlementcom.MEASUREMENT = ProductMeasurementCoE[i];
                    //bonderannualentitlementcom.MDESC = ProductDescriptionCoE[i];
                    bonderannualentitlementcom.MACHINESLNO = (Int16)ProductMachineCoE[i];

                    for (int j = 0; j < hscodesCoE.Length; j++)
                    {
                        BONDERANNUALENTITLEMENTCOEDET bonderannualentitlementcoedet = new BONDERANNUALENTITLEMENTCOEDET();

                        OracleEntitiesConnStr db2 = new OracleEntitiesConnStr();

                        if (ProductCoE[i] == RawmaterialProductID[j])
                        {
                            bonderannualentitlementcoedet.AESLNO      = (Int16)id;
                            bonderannualentitlementcoedet.BONDERSLNO  = (Int16)BonderSlno;
                            bonderannualentitlementcoedet.MSLNO       = (Int16)ProductCoE[i];
                            bonderannualentitlementcoedet.RMSLNO      = (Int16)hscodesCoE[j];
                            bonderannualentitlementcoedet.GROSSQT     = (Int16)grossCoEs[j];
                            bonderannualentitlementcoedet.WASTAGEQT   = (Int16)wastageCoEs[j];
                            bonderannualentitlementcoedet.SHRINKAGEQT = (Int16)shrinkageCoEs[j];
                            bonderannualentitlementcoedet.NETQT       = (Int16)netCoEs[j];

                            db2.BONDERANNUALENTITLEMENTCOEDETs.Add(bonderannualentitlementcoedet);
                        }

                        db2.SaveChanges();
                    }


                    db.BONDERANNUALENTITLEMENTCOMs.Add(bonderannualentitlementcom);
                }

                db.SaveChanges();


                //db.SaveChanges();
            }
        }
        public ActionResult EditCoefficientMas(CoefficientMasterDetailViewModel coefficientmasterdetailviewmodeledt, int?MachineList)
        {
            BONDERANNUALENTITLEMENTCOM bonderannualentitlementcom = new BONDERANNUALENTITLEMENTCOM();

            //CoefficientMasterDetailViewModel coefficientmasterdetailviewmodel = new CoefficientMasterDetailViewModel();

            if (ModelState.IsValid)
            {
                try
                {
                    bonderannualentitlementcom.AESLNO     = coefficientmasterdetailviewmodeledt.Bonderannualentitlementcoms.AESLNO;
                    bonderannualentitlementcom.BONDERSLNO = coefficientmasterdetailviewmodeledt.Bonderannualentitlementcoms.BONDERSLNO;
                    bonderannualentitlementcom.MSLNO      = coefficientmasterdetailviewmodeledt.Bonderannualentitlementcoms.MSLNO;


                    bonderannualentitlementcom.WEIGHT      = coefficientmasterdetailviewmodeledt.Bonderannualentitlementcoms.WEIGHT;
                    bonderannualentitlementcom.MSIZE       = coefficientmasterdetailviewmodeledt.Bonderannualentitlementcoms.MSIZE;
                    bonderannualentitlementcom.MEASUREMENT = coefficientmasterdetailviewmodeledt.Bonderannualentitlementcoms.MEASUREMENT;
                    bonderannualentitlementcom.MACHINESLNO = (Int16)MachineList;


                    db.Entry(bonderannualentitlementcom).State = EntityState.Modified;
                    db.SaveChanges();

                    ViewBag.Products     = new SelectList(db.MATERIALS.Where(r => r.MTYPE == "F"), "MSLNO", "MATERIALNAME", bonderannualentitlementcom.MSLNO);
                    ViewBag.Rawmaterilas = new SelectList(db.MATERIALS.Where(r => r.MTYPE == "r"), "MSLNO", "MATERIALNAME");
                    return(RedirectToAction("EntitlementDetails", new { id = bonderannualentitlementcom.AESLNO }));
                }
                catch (Exception e)
                {
                }
            }


            ViewBag.MachineList = new SelectList(db.MACHINEINFORMATIONs, "MACHINESLNO", "MODELNM", coefficientmasterdetailviewmodeledt.Bonderannualentitlementcoms.MACHINESLNO);
            return(View(bonderannualentitlementcom));
        }
        public ActionResult AddEntitlementCoefficient(int?aeslno, int?bonderslno, int[] ProductCoE, string[] ProductWeightCoE, string[] ProductDescriptionCoE,
                                                      string[] ProductSizeCoE, string[] ProductMeasurementCoE, string[] ProductRawmaterialsCoE, int[] ProductMachineCoE, int[] hscodesCoE
                                                      , int[] measuementoCoE, int[] grossCoEs, int[] wastageCoEs, int[] shrinkageCoEs, int[] netCoEs, int[] RawmaterialProductID)
        {
            try
            {
                if (ProductCoE != null)
                {
                    int lenth = ProductCoE.Length;

                    for (int i = 0; i < lenth; i++)
                    {
                        BONDERANNUALENTITLEMENTCOM bonderannualentitlementcom = new BONDERANNUALENTITLEMENTCOM();

                        bonderannualentitlementcom.AESLNO      = (Int16)aeslno;
                        bonderannualentitlementcom.BONDERSLNO  = (Int16)bonderslno;
                        bonderannualentitlementcom.MSLNO       = (Int16)ProductCoE[i];
                        bonderannualentitlementcom.WEIGHT      = ProductWeightCoE[i];
                        bonderannualentitlementcom.MSIZE       = ProductSizeCoE[i];
                        bonderannualentitlementcom.MEASUREMENT = ProductMeasurementCoE[i];
                        //bonderannualentitlementcom.MDESC = ProductDescriptionCoE[i];
                        bonderannualentitlementcom.MACHINESLNO = (Int16)ProductMachineCoE[i];

                        for (int j = 0; j < hscodesCoE.Length; j++)
                        {
                            BONDERANNUALENTITLEMENTCOEDET bonderannualentitlementcoedet = new BONDERANNUALENTITLEMENTCOEDET();

                            OracleEntitiesConnStr db2 = new OracleEntitiesConnStr();

                            if (ProductCoE[i] == RawmaterialProductID[j])
                            {
                                bonderannualentitlementcoedet.AESLNO      = (Int16)aeslno;
                                bonderannualentitlementcoedet.BONDERSLNO  = (Int16)bonderslno;
                                bonderannualentitlementcoedet.MSLNO       = (Int16)ProductCoE[i];
                                bonderannualentitlementcoedet.RMSLNO      = (Int16)hscodesCoE[j];
                                bonderannualentitlementcoedet.GROSSQT     = (Int16)grossCoEs[j];
                                bonderannualentitlementcoedet.WASTAGEQT   = (Int16)wastageCoEs[j];
                                bonderannualentitlementcoedet.SHRINKAGEQT = (Int16)shrinkageCoEs[j];
                                bonderannualentitlementcoedet.NETQT       = (Int16)netCoEs[j];

                                db2.BONDERANNUALENTITLEMENTCOEDETs.Add(bonderannualentitlementcoedet);
                            }

                            db2.SaveChanges();
                        }


                        db.BONDERANNUALENTITLEMENTCOMs.Add(bonderannualentitlementcom);
                    }

                    db.SaveChanges();
                }


                return(RedirectToAction("EntitlementDetails", new { ID = aeslno }));
            }


            catch
            {
                ViewBag.MachineList  = new SelectList(db.MACHINEINFORMATIONs, "MACHINESLNO", "MODELNM");
                ViewBag.Products     = new SelectList(db.MATERIALS.Where(p => p.MTYPE == "F"), "MSLNO", "MHSCODE");
                ViewBag.Rawmaterilas = new SelectList(db.MATERIALS.Where(r => r.MTYPE == "r"), "MSLNO", "MHSCODE");
                ViewBag.AeSlno       = aeslno;
                ViewBag.BonderSlno   = bonderslno;

                return(View());
            }
        }