コード例 #1
0
        public ActionResult Create([Bind(Include = "clientId,dateCreation,name,identifAbrev,reup,street,city,province,telephone,email,agent,agentPosition,organismId,country,isSubject,fatherId,legalPerson")] Client client, int clientFather, string jsonData)
        {
            if (ModelState.IsValid)
            {
                ICollection <AccountBank> accountBanks = SetJson(jsonData);
                if (accountBanks.Count > 0)
                {
                    client.AccountBank = accountBanks;
                    foreach (AccountBank accountBank in accountBanks)
                    {
                        db.AccountBank.Add(accountBank);
                    }
                }
                if (!client.isSubject)
                {
                    client.fatherId = null;
                }
                else
                {
                    client.fatherId = clientFather;
                }

                db.Client.Add(client);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.organismId = new SelectList(db.Organism, "organismId", "name", client.organismId);
            return(View(client));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "contractId,number,signedProvider,nom1,nom2,description,clientId,expirationDate,signedClient,comitteNumber,comitteDate")] Contract contract, int stateC, System.DateTime dateState, string descriptionState, int idClient)
        {
            if (ModelState.IsValid)
            {
                StateContract _stateContract = new StateContract
                {
                    stateCId    = stateC,
                    Contract    = contract,
                    date        = dateState,
                    description = descriptionState,
                    state       = true
                };
                db.StateContract.Add(_stateContract);
                contract.nom1     = "tempvalue";
                contract.nom2     = "tmpvalue";
                contract.clientId = idClient;
                db.Contract.Add(contract);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = contract.clientId }));
            }

            ViewBag.clientId = contract.clientId;
            ViewBag.stateC   = db.StateC.Where(s => s.type == "Contrato");
            //ViewBag.clientId = new SelectList(db.Client, "clientId", "name", contract.clientId);
            return(View(contract));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "globalServiceId,name")] GlobalService globalService)
        {
            if (ModelState.IsValid)
            {
                db.GlobalService.Add(globalService);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(globalService));
        }
コード例 #4
0
ファイル: OrganismController.cs プロジェクト: zeldax54/GProy
        public ActionResult Create([Bind(Include = "organismId,name")] Organism organism)
        {
            if (ModelState.IsValid)
            {
                db.Organism.Add(organism);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(organism));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "currencyTypeId,type")] CurrencyType currencyType)
        {
            if (ModelState.IsValid)
            {
                db.CurrencyType.Add(currencyType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(currencyType));
        }
コード例 #6
0
ファイル: ProductsController.cs プロジェクト: zeldax54/GProy
        public ActionResult Create([Bind(Include = "productId,name,description,version")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Product.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
コード例 #7
0
ファイル: RatesController.cs プロジェクト: zeldax54/GProy
        public ActionResult Create([Bind(Include = "rateId,rate1")] Rate rate)
        {
            if (ModelState.IsValid)
            {
                db.Rate.Add(rate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rate));
        }
コード例 #8
0
ファイル: BanksController.cs プロジェクト: zeldax54/GProy
        public ActionResult Create([Bind(Include = "bankId,name,branch,street,city,province,country")] Bank bank)
        {
            if (ModelState.IsValid)
            {
                db.Bank.Add(bank);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bank));
        }
コード例 #9
0
        public ActionResult Create([Bind(Include = "areaId,name,boss,areaEntityId")] Area area)
        {
            if (ModelState.IsValid)
            {
                db.Area.Add(area);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.areaEntityId = new SelectList(db.Entity, "entityId", "name", area.areaEntityId);
            return(View(area));
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "entityId,name,reupCode,identifAbrev,organismId")] Entity entity)
        {
            if (ModelState.IsValid)
            {
                db.Entity.Add(entity);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.organismId = new SelectList(db.Organism, "organismId", "name", entity.organismId);
            return(View(entity));
        }
コード例 #11
0
ファイル: StagesController.cs プロジェクト: zeldax54/GProy
        public ActionResult Create([Bind(Include = "stageId,name,serviceId,orden")] Stage stage)
        {
            if (ModelState.IsValid)
            {
                db.Stage.Add(stage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.serviceId = new SelectList(db.Service, "serviceId", "name", stage.serviceId);
            return(View(stage));
        }
コード例 #12
0
        public ActionResult Create([Bind(Include = "specialistId,name,areaId,ci")] Specialist specialist)
        {
            if (ModelState.IsValid)
            {
                db.Specialist.Add(specialist);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.areaId = new SelectList(db.Area, "areaId", "name", specialist.areaId);
            return(View(specialist));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "serviceId,name,globalServiceId,rateId")] Service service)
        {
            if (ModelState.IsValid)
            {
                db.Service.Add(service);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.globalServiceId = new SelectList(db.GlobalService, "globalServiceId", "name", service.globalServiceId);
            ViewBag.rateId          = new SelectList(db.Rate, "rateId", "rateId", service.rateId);
            return(View(service));
        }
コード例 #14
0
        public ActionResult Create([Bind(Include = "invoiceId,amount,invoiceProjectDetailsId,projDetailsSpecialistId")] InvoiceProjectDetails invoiceProjectDetails)
        {
            if (ModelState.IsValid)
            {
                db.InvoiceProjectDetails.Add(invoiceProjectDetails);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.invoiceId = new SelectList(db.Invoice, "invoiceId", "invoiceNum", invoiceProjectDetails.invoiceId);
            ViewBag.projDetailsSpecialistId = new SelectList(db.ProjectDetailsSpecialist, "projDetailsSpecialistId", "projDetailsSpecialistId", invoiceProjectDetails.projDetailsSpecialistId);
            return(View(invoiceProjectDetails));
        }
コード例 #15
0
        public ActionResult Create([Bind(Include = "clientId,bankId,currencyTypeId,accountNumber,titular")] AccountBank accountBank)
        {
            if (ModelState.IsValid)
            {
                db.AccountBank.Add(accountBank);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.bankId         = new SelectList(db.Bank, "bankId", "name", accountBank.bankId);
            ViewBag.clientId       = new SelectList(db.Client, "clientId", "name", accountBank.clientId);
            ViewBag.currencyTypeId = new SelectList(db.CurrencyType, "currencyTypeId", "type", accountBank.currencyTypeId);
            return(View(accountBank));
        }
コード例 #16
0
ファイル: InvoicesController.cs プロジェクト: zeldax54/GProy
        public void Crear_Factura(int iddetalle, int idcliente, int idproducto, int idestado, string fecha,
                                  string numero, string projDetailsSpecialistId, string montos)
        {
            List <int>    ids     = Convert(projDetailsSpecialistId);
            List <double> montosv = ConvertMontos(montos);


            DateTime f      = DateTime.Parse(fecha);
            double   montof = montosv.Sum();
            Invoice  i      = new Invoice();

            i.Client     = db.Client.Find(idcliente);
            i.Product    = db.Product.Find(idproducto);
            i.invoiceNum = numero;
            i.amount     = montof;
            i.date       = f;
            db.Invoice.Add(i);


            InvoiceStateSet issSet = new InvoiceStateSet
            {
                Invoice     = i,
                State1      = db.State.Find(idestado),
                date        = fecha,
                description = db.State.Find(idestado).name
            };

            db.InvoiceStateSet.Add(issSet);


            for (int j = 0; j < ids.Count; j++)
            {
                InvoiceProjectDetails ipd = new InvoiceProjectDetails();
                ipd.projDetailsSpecialistId = ids[j];
                ipd.amount  = montosv[j];
                ipd.Invoice = i;
                db.InvoiceProjectDetails.Add(ipd);
            }
            //Restando del Detalle
            ProjectDetails pd = db.ProjectDetails.Find(iddetalle);

            pd.totalInvoiced = pd.totalInvoiced + montof;
            pd.toInvoice     = pd.totalContracted - pd.totalInvoiced;
            //Atualizando proyecto
            pd.ProjSup.Project.totalnvoiced = decimal.Parse((pd.totalInvoiced + montof).ToString());
            pd.ProjSup.Project.toInvoiced   = decimal.Parse((pd.totalContracted - pd.totalInvoiced).ToString());
            db.SaveChanges();
        }
コード例 #17
0
ファイル: ProjectsController.cs プロジェクト: zeldax54/GProy
        public string SCron(Int32 id, Int32 idf, string d, string m)
        {
            List <ProjectDetails> pdtDetails = db.ProjectDetails.Where(p => p.projSupId == id).ToList();

            if (pdtDetails.Count > 0)
            {
                foreach (var x in pdtDetails)
                {
                    List <ProjectDetailsSpecialist> pds =
                        db.ProjectDetailsSpecialist.Where(p => p.projectDetailsId == x.projectDetailsId).ToList();
                    if (pds.Count > 0)
                    {
                        return("-1");
                    }
                }
            }



            List <Schedule> sch = db.Schedule.Where(p => p.projSupId == id && p.stageId == idf).ToList();

            if (sch.Count > 0)
            {
                foreach (var c in sch)
                {
                    db.Schedule.Remove(c);
                }
            }
            Schedule s = new Schedule();

            s.projSupId = id;
            s.stageId   = idf;
            s.nDays     = float.Parse(d);
            s.amount    = float.Parse(m);
            db.Schedule.Add(s);

            /*ASignando detalle al proyecto*/
            foreach (var projectdetail in db.ProjectDetails.Where(p => p.projSupId == id && p.stageId == idf))
            {
                db.ProjectDetails.Remove(projectdetail);
            }

            ProjectDetails pd = new ProjectDetails();

            pd.projSupId       = id;
            pd.stageId         = idf;
            pd.totalContracted = float.Parse(m);
            pd.totalInvoiced   = 0;
            pd.toInvoice       = float.Parse(m);
            pd.state           = false;
            db.ProjectDetails.Add(pd);
            db.SaveChanges();

            return("1");
        }
コード例 #18
0
        public ActionResult Create([Bind(Include = "supplementId,number,name,contractId,amount,nom1,nom2,signedClient,productId,serviceId,signedProvider,comitteNumber,comitteDate,expirationDate")] Supplement supplement, int stateC, System.DateTime dateState, string descriptionState, string jsonClient, int contractId, bool idclient)
        {
            if (ModelState.IsValid)
            {
                supplement.nom1 = "tmpvalue";
                supplement.nom2 = "tmpvalue";
                StateCSupplement _stateCSupplement = new StateCSupplement
                {
                    stateCId    = stateC,
                    Supplement  = supplement,
                    date        = dateState,
                    description = descriptionState,
                    state       = true
                };
                db.StateCSupplement.Add(_stateCSupplement);

                List <string> stringData  = SetJson(jsonClient);
                decimal       amountValue = 0;
                if (stringData.Any())
                {
                    for (int i = 0; i < stringData.Count(); i += 3)
                    {
                        int id = int.Parse(stringData.ElementAt(i));

                        string   newAmount = stringData.ElementAt(i + 1);
                        string[] newValue  = newAmount.Split('.');
                        decimal  endValue  = 0;
                        if (newValue.Count() == 2)
                        {
                            decimal decens  = decimal.Parse(newValue[0]);
                            decimal centens = decimal.Parse(newValue[1]);
                            endValue = decens + (centens / 100);
                        }
                        else
                        {
                            endValue = decimal.Parse(newAmount);
                        }
                        string idproy = stringData.ElementAt(i + 2);



                        ClientSupplement clientSupplement = new ClientSupplement
                        {
                            clientId   = id,
                            Supplement = supplement,
                            amount     = endValue
                        };
                        amountValue += endValue;
                        if (clientSupplement != null)
                        {
                            db.ClientSupplement.Add(clientSupplement);
                        }
                        //creando los proyectos
                        Client client = db.Client.First(c => c.clientId == id);
                        if (client != null)
                        {
                            if (idproy != "*")
                            {
                                Project p       = db.Project.Find(int.Parse(idproy));
                                ProjSup projSup = new ProjSup
                                {
                                    Project    = p,
                                    Supplement = supplement,
                                    amount     = endValue
                                };
                                p.totalContracted += endValue;
                                p.toInvoiced      += endValue;
                                db.ProjSup.Add(projSup);
                            }
                            else
                            {
                                State   c       = db.State.Find(3);
                                Project project = new Project
                                {
                                    name            = supplement.number + " - " + client.name,
                                    clientId        = id,
                                    productId       = supplement.productId,
                                    advancePercent  = 0,
                                    totalContracted = endValue,
                                    toInvoiced      = endValue
                                };

                                db.Project.Add(project);
                                ProjectState ps = new ProjectState
                                {
                                    State1      = c,
                                    date        = DateTime.Now,
                                    description = "Proyecto creado automaticamente al crear Sumpelento",
                                    state       = true,
                                    Project     = project
                                };

                                db.ProjectState.Add(ps);
                                ProjSup projSup = new ProjSup
                                {
                                    Project    = project,
                                    Supplement = supplement,
                                    amount     = endValue
                                };
                                db.ProjSup.Add(projSup);
                            }
                        }
                    }
                }

                supplement.amount     = amountValue;
                supplement.contractId = contractId;

                db.Supplement.Add(supplement);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = supplement.contractId, idclient = idclient }));
            }

            ViewBag.contractId = contractId;
            ViewBag.productId  = new SelectList(db.Product, "productId", "name", supplement.productId);
            ViewBag.serviceId  = new SelectList(db.Service, "serviceId", "name", supplement.serviceId);
            ViewBag.stateC     = db.StateC.Where(s => s.type == "Suplemento");
            Contract contract = db.Contract.First(c => c.contractId == contractId);

            ViewBag.clientFather  = db.Client.First(fa => fa.clientId == contract.clientId);
            ViewBag.clients       = db.Client.Where(cl => cl.fatherId == contract.clientId).ToList();
            ViewBag.idclientValue = idclient;
            return(View(supplement));
        }