//===============================================
        public JsonResult add_partner(string name, string address, string phone, string mobile, double?money)
        {
            try
            {
                partner pt = new partner();
                pt.name    = name;
                pt.address = address;
                pt.phone   = phone;
                pt.mobile  = mobile;

                if (money == null)
                {
                    pt.money = 0;
                }
                else
                {
                    pt.money = money;
                }

                DB.partner.Add(pt);
                DB.SaveChanges();

                return(Json(new { msg = "تم اضافه الشريك بنجاح" }));
            }
            catch
            {
                return(Json(new { msg = "لم تتم الاضافه .. حاول مره اخري" }));
            }
        }
Пример #2
0
        public async Task <ActionResult> AddNew(Partner model)
        {
            if (!ModelState.IsValid)
            {
                TempData["Errored"] = "Vui lòng kiểm tra lại các trường.";
                return(View(model));
            }

            try
            {
                int     id = 0;
                partner pn = new partner();
                pn.address   = model.address;
                pn.email     = model.email;
                pn.full_name = model.full_name;
                pn.lat       = model.lat;
                pn.lon       = model.lon;
                pn.pass      = model.pass;
                pn.phone     = model.phone;
                db.partners.Add(pn);

                await db.SaveChangesAsync();

                return(RedirectToAction("Admin"));
            }

            catch (Exception ex)
            {
                ModelState.AddModelError("", "Có lỗi xảy ra khi thêm mới");
                //configs.SaveTolog(ex.ToString());
                return(View(model));
            }
        }
Пример #3
0
 public IActionResult InsertPartner(partner partner)
 {
     try
     {
         int?maxPartnerBroj = null;
         int?broj           = null;
         if (_dbContext.partner != null && _dbContext.partner.Count() > 0)
         {
             maxPartnerBroj = _dbContext.partner.Max(p => p.sifra);
             broj           = maxPartnerBroj + 1;
         }
         else
         {
             broj = 1;
         }
         partner.sifra = broj;
         _dbContext.partner.Add(partner);
         _dbContext.SaveChanges();
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
//===============================================
        public JsonResult update_partner(int id, string name, string address, string phone, string mobile, double?money)
        {
            try
            {
                partner pt = DB.partner.Where(p => p.id == id).Single();
                pt.name    = name;
                pt.address = address;
                pt.phone   = phone;
                pt.mobile  = mobile;
                if (money == null)
                {
                    pt.money = 0;
                }
                else
                {
                    pt.money = money;
                }

                DB.Entry(pt).State = EntityState.Modified;
                DB.SaveChanges();

                return(Json(new { msg = "تم تعديل بيانات الشريك بنجاح" }));
            }
            catch
            {
                return(Json(new { msg = "لم تتم عمليه التعديل .. حاول مره اخري" }));
            }
        }
Пример #5
0
        public IActionResult UpdateUgovor(ugovor ugovor)
        {
            ugovor.Korisnik = null;
            var pon = _dbContext.ugovor.Include(u => u.rate).FirstOrDefault(p => p.broj == ugovor.broj);

            if (pon == null)
            {
                return(NotFound());
            }
            else
            {
                try
                {
                    foreach (var r in pon.rate)
                    {
                        _dbContext.Remove(r);
                    }

                    _dbContext.SaveChanges();
                    Helper.CopyPropertiesTo <ugovor, ugovor>(ugovor, pon);

                    partner partner;
                    if (ugovor.partner.sifra == null)
                    {
                        partner = new partner();

                        partner.naziv        = ugovor.kupac_naziv;
                        partner.adresa       = ugovor.kupac_adresa;
                        partner.telefon      = ugovor.kupac_telefon;
                        partner.broj_lk      = ugovor.kupac_broj_lk;
                        partner.maticni_broj = ugovor.kupac_maticni_broj;
                        partner.tip          = "F";
                        pon.kupac_sifra      = null;
                        pon.partner          = partner;
                    }
                    else
                    {
                        partner = _dbContext.partner.Where(p => p.sifra == ugovor.kupac_sifra).FirstOrDefault();

                        partner.naziv        = ugovor.kupac_naziv;
                        partner.adresa       = ugovor.kupac_adresa;
                        partner.telefon      = ugovor.kupac_telefon;
                        partner.broj_lk      = ugovor.kupac_broj_lk;
                        partner.maticni_broj = ugovor.kupac_maticni_broj;
                        partner.tip          = "F";
                        _dbContext.SaveChanges();

                        pon.partner = partner;
                    }

                    _dbContext.SaveChanges();
                    return(Ok(pon));
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex));
                }
            }
        }
Пример #6
0
        public ActionResult DeleteConfirmed(long id)
        {
            partner pt = db.partners.Find(id);

            db.partners.Remove(pt);
            db.SaveChanges();
            return(RedirectToAction("Admin"));
        }
Пример #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            partner partner = db.partners.Find(id);

            db.partners.Remove(partner);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
 public ActionResult Edit(partner partner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(partner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(partner));
 }
Пример #9
0
        public IActionResult UpdatePrijava(prijava prijava)
        {
            prijava.Korisnik = null;
            var pon = _dbContext.prijava.FirstOrDefault(p => p.broj == prijava.broj);

            if (pon == null)
            {
                return(NotFound());
            }
            else
            {
                try
                {
                    Helper.CopyPropertiesTo <prijava, prijava>(prijava, pon);

                    partner partner;
                    if (prijava.partner.sifra == null)
                    {
                        partner = new partner();

                        partner.naziv   = prijava.kupac_ime;
                        partner.adresa  = prijava.kupac_adresa;
                        partner.telefon = prijava.kupac_telefon;
                        partner.email   = prijava.kupac_email;
                        partner.tip     = "P";
                        pon.kupac_sifra = null;
                        pon.partner     = partner;
                    }
                    else
                    {
                        partner = _dbContext.partner.Where(p => p.sifra == prijava.kupac_sifra).FirstOrDefault();

                        partner.naziv   = prijava.kupac_ime;
                        partner.adresa  = prijava.kupac_adresa;
                        partner.telefon = prijava.kupac_telefon;
                        partner.email   = prijava.kupac_email;
                        partner.tip     = "P";
                        _dbContext.SaveChanges();

                        pon.partner = partner;
                    }
                    if (prijava.dobavljac_partner != null)
                    {
                        partner = _dbContext.partner.Where(p => p.sifra == prijava.dobavljac_sifra).FirstOrDefault();
                        prijava.dobavljac_partner = partner;
                    }
                    _dbContext.SaveChanges();
                    return(Ok(pon));
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex));
                }
            }
        }
Пример #10
0
        public IActionResult UpdatePonuda(ponuda ponuda)
        {
            ponuda.Korisnik = null;
            var pon = _dbContext.ponuda.FirstOrDefault(p => p.broj == ponuda.broj);

            if (pon == null)
            {
                return(NotFound());
            }
            else
            {
                try
                {
                    Helper.CopyPropertiesTo <ponuda, ponuda>(ponuda, pon);

                    partner partner;
                    if (ponuda.partner.sifra == null)
                    {
                        partner = new partner();

                        partner.naziv        = ponuda.partner_naziv;
                        partner.adresa       = ponuda.partner_adresa;
                        partner.maticni_broj = ponuda.partner_jib;
                        partner.telefon      = ponuda.partner_telefon;
                        partner.email        = ponuda.partner_email;
                        partner.tip          = "P";
                        pon.partner_sifra    = null;
                        pon.partner          = partner;
                    }
                    else
                    {
                        partner = _dbContext.partner.Where(p => p.sifra == ponuda.partner_sifra).FirstOrDefault();

                        partner.naziv        = ponuda.partner_naziv;
                        partner.adresa       = ponuda.partner_adresa;
                        partner.maticni_broj = ponuda.partner_jib;
                        partner.telefon      = ponuda.partner_telefon;
                        partner.email        = ponuda.partner_email;
                        partner.tip          = "P";
                        _dbContext.SaveChanges();

                        pon.partner = partner;
                    }

                    _dbContext.SaveChanges();
                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex));
                }
            }
        }
Пример #11
0
 public ActionResult Edit([Bind(Include = "idPartner,name,lastname,idcard,photo,address,phone,gender,age,birthdate,afilliate,partnership,workplace,officeaddress,officephone,partnershipstatus,addmisiondate,departuredate")] partner partner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(partner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.gender      = new SelectList(db.genders, "idGender", "description", partner.gender);
     ViewBag.afilliate   = new SelectList(db.partners, "idPartner", "name", partner.afilliate);
     ViewBag.partnership = new SelectList(db.partnerships, "idPartnership", "description", partner.partnership);
     return(View(partner));
 }
Пример #12
0
        // GET: Partners/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            partner partner = db.partners.Find(id);

            if (partner == null)
            {
                return(HttpNotFound());
            }
            return(View(partner));
        }
Пример #13
0
        public ActionResult Create([Bind(Include = "id,name,img,describe,background")] partner partner)
        {
            if (ModelState.IsValid)
            {
                db.partners.Add(partner);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(partner));
            }
        }
Пример #14
0
 public ActionResult Edit(partner partner)
 {
     if (!ModelState.IsValid)
     {
         TempData["error"] = "Vui lòng kiểm tra lại các trường.";
         return(RedirectToAction("Edit", new { id = partner.id }));
     }
     if (ModelState.IsValid)
     {
         db.Entry(partner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Admin"));
     }
     return(View(partner));
 }
Пример #15
0
        public ActionResult Edit(int?id)
        {
            if (id == null || id == 0)
            {
                return(RedirectToRoute("Admin"));
            }
            partner _model = db.partners.Find(id);

            if (_model == null)
            {
                return(View(_model));
            }

            return(View(_model));
        }
Пример #16
0
        public async Task <ActionResult> Create([Bind(Include = "idcenter,name,location,idpartner_FK,flag,min_family_id,max_family_id,min_person_id,max_person_id")] center center)
        {
            if (ModelState.IsValid)
            {
                partner p = db.partners.SingleOrDefault(pa => pa.idpartner == center.idpartner_FK);
                center.idcenter = p.idpartner + center.flag;
                db.centers.Add(center);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.idpartner_FK = new SelectList(db.partners, "idpartner", "name", center.idpartner_FK);
            return(View(center));
        }
//===============================================
        public JsonResult delete_partner(int id)
        {
            try
            {
                partner pt = DB.partner.Where(p => p.id == id).Single();

                DB.partner.Remove(pt);
                DB.SaveChanges();

                return(Json(new { msg = "تم حذف الشريك بنجاح" }));
            }
            catch
            {
                return(Json(new { msg = "لم تتم عمليه الحذف .. حاول مره اخري" }));
            }
        }
Пример #18
0
        // GET: Partners/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            partner partner = db.partners.Find(id);

            if (partner == null)
            {
                return(HttpNotFound());
            }
            ViewBag.gender      = new SelectList(db.genders, "idGender", "description", partner.gender);
            ViewBag.afilliate   = new SelectList(db.partners, "idPartner", "name", partner.afilliate);
            ViewBag.partnership = new SelectList(db.partnerships, "idPartnership", "description", partner.partnership);
            return(View(partner));
        }
Пример #19
0
        public ActionResult Delete(int?id)
        {
            if (Configs.getCookie("admin") == null || Configs.getCookie("admin") == "")
            {
                return(RedirectToAction("Login", "Admin"));
            }
            if (id == null || id == 0)
            {
                return(RedirectToRoute("Admin"));
            }
            partner _model = db.partners.Find(id);

            if (_model == null)
            {
                return(View(_model));
            }

            return(View(_model));
        }
Пример #20
0
        public IActionResult UpdatePartner(partner partner)
        {
            var pon = _dbContext.partner.FirstOrDefault(p => p.sifra == partner.sifra);

            if (pon == null)
            {
                return(NotFound());
            }
            else
            {
                try
                {
                    Helper.CopyPropertiesTo <partner, partner>(partner, pon);
                    _dbContext.SaveChanges();
                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex));
                }
            }
        }
Пример #21
0
        private void testDoSale()
        {
            CustomerSalesServicesClient client = new CustomerSalesServicesClient();

            doSaleRequest request = new doSaleRequest();

            customer c = new customer();

            c.birthDate          = new DateTime(1984, 3, 3);
            c.birthDateSpecified = true;

            addressDTO add = new addressDTO();

            add.addressDetail     = "Rua 1";
            add.type              = addressType.RESIDENTIAL;
            add.typeSpecified     = true;
            add.addressNumber     = "123";
            add.addressPostalCode = "06871120";
            add.city              = "Embu";
            add.neighborhood      = "Marilú";
            add.state             = "SP";

            phoneDTO phone = new phoneDTO();

            phone.phoneNumber   = "1143216363";
            phone.type          = phoneType.RESIDENTIAL;
            phone.typeSpecified = true;

            c.fullName        = "Teste Abobrinha";
            c.gender          = gender.MALE;
            c.genderSpecified = true;

            identityDTO iden = new identityDTO();

            iden.documentType          = document.CPF;
            iden.documentTypeSpecified = true;
            iden.documentValue         = "40614102022";


            c.maritalStatus          = maritalStatus.SINGLE;
            c.maritalStatusSpecified = true;
            //criar novo contato para celular e repetir
            //cus.contacts[1].phone.phoneNumber = segurosuppro.Celular;
            //cus.contacts[1].phone.type = phoneType.MOBILE;

            cardPaymentDTO card = new cardPaymentDTO();

            card.cardDisplayName       = "THIAGO SANTANA";
            card.cardFlag              = "luiza";
            card.cardNumber            = "5307804589564512";
            card.cardSecurityCode      = "456";
            card.cardValidity          = new DateTime(1985, 1, 26);
            card.cardValiditySpecified = true;
            card.cardValue             = Convert.ToDecimal("19,90");
            card.cardValueSpecified    = true;

            productDTO prod = new productDTO();

            prod.descripton  = "CARTÃO PROTEGIDO";
            prod.ID          = 25;
            prod.IDSpecified = true;

            contactDTO cc = new contactDTO();

            cc.address = add;
            cc.phone   = phone;

            contactDTO[] contatos = new contactDTO[] { cc };
            c.contacts = contatos;
            c.identity = iden;

            paymentMethod payM = new paymentMethod();

            payM.cardPayment = card;

            identityDTO idensales = new identityDTO();

            idensales.documentType          = document.CPF;
            idensales.documentTypeSpecified = true;
            idensales.documentValue         = "10752104969";

            loginDTO log = new loginDTO();

            log.username = "******";
            log.password = "******";

            partner part = new partner();

            part.ID          = 001;
            part.IDSpecified = true;

            salesman salman = new salesman();

            salman.identity     = idensales;
            salman.login        = log;
            salman.partner      = part;
            salman.operatorName = "Saulo Mezencio";

            sale sa = new sale();

            sa.customer      = c;
            sa.paymentMethod = payM;
            sa.product       = prod;
            sa.salesman      = salman;

            request.sale = sa;

            doSaleResponse response = null;

            try {
                response = client.doSale(request);

                Console.WriteLine("Response = " + response);
                Console.WriteLine("PARANDO PARA VISUALIZAR JANELA");
            } catch (Microsoft.Web.Services3.ResponseProcessingException exR) {
                Console.WriteLine("Exception to call service FAULT: " + exR.Response.OuterXml);
                Console.WriteLine("PARANDO PARA VISUALIZAR JANELA ANTERIOR");
            }/* catch (Exception ex) {
              * Console.WriteLine("Exception : " + ex);
              * Console.WriteLine("PARANDO PARA VISUALIZAR JANELA");
              * }*/
        }
Пример #22
0
        public IActionResult InsertUgovor(ugovor ugovor)
        {
            try
            {
                var    ugovori = _dbContext.ugovor.Include(p => p.partner).Include(p => p.Korisnik).Where(p => p.datum.Year == DateTime.Now.Year);
                string maxBroj = null;
                int    year    = ugovor.datum.Year;
                int?   broj    = null;
                if (ugovori != null && ugovori.Count() > 0)
                {
                    maxBroj = ugovori.Max(p => p.broj);
                    int dbroj = int.Parse(maxBroj.Split("/")[0]);
                    broj = dbroj + 1;
                }
                else
                {
                    broj = 1;
                }
                ugovor.radnik              = User.Identity.Name;
                ugovor.broj                = broj.Value.ToString("D5") + "/" + year.ToString();
                ugovor.uplaceno_po_ratama  = 0;
                ugovor.preostalo_za_uplatu = ugovor.iznos_sa_pdv - ugovor.inicijalno_placeno;
                partner partner;
                if (ugovor.partner.sifra == null)
                {
                    partner = new partner();

                    partner.naziv        = ugovor.kupac_naziv;
                    partner.adresa       = ugovor.kupac_adresa;
                    partner.telefon      = ugovor.kupac_telefon;
                    partner.broj_lk      = ugovor.kupac_broj_lk;
                    partner.maticni_broj = ugovor.kupac_maticni_broj;
                    partner.tip          = "P";

                    ugovor.partner = partner;
                }
                else
                {
                    partner = _dbContext.partner.Where(p => p.sifra == ugovor.kupac_sifra).FirstOrDefault();

                    partner.naziv        = ugovor.kupac_naziv;
                    partner.adresa       = ugovor.kupac_adresa;
                    partner.telefon      = ugovor.kupac_telefon;
                    partner.broj_lk      = ugovor.kupac_broj_lk;
                    partner.maticni_broj = ugovor.kupac_maticni_broj;

                    partner.tip = "P";
                    _dbContext.SaveChanges();

                    ugovor.partner = partner;
                }

                ugovor.status = "E";
                _dbContext.ugovor.Add(ugovor);
                _dbContext.SaveChanges();

                ugovor.Korisnik = _dbContext.korisnik.FirstOrDefault(k => k.korisnicko_ime == ugovor.radnik);
                return(Ok(ugovor));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #23
0
        public ActionResult DetailsConfirmed(int id)
        {
            partner partner = db.partners.Find(id);

            return(View(partner));
        }
Пример #24
0
        public IActionResult InsertPrijava(prijava prijava)
        {
            try
            {
                var    prijave        = _dbContext.prijava.Include(p => p.partner).Include(p => p.Korisnik).Include(p => p.dobavljac_partner).Where(p => p.datum.Value.Year == DateTime.Now.Year);
                string maxPrijavaBroj = null;
                int    year           = prijava.datum.Value.Year;
                int?   broj           = null;
                if (prijave != null && prijave.Count() > 0)
                {
                    maxPrijavaBroj = prijave.Max(p => p.broj);
                    int dbroj = int.Parse(maxPrijavaBroj.Split("/")[0]);
                    broj = dbroj + 1;
                }
                else
                {
                    broj = 1;
                }
                prijava.serviser_primio = User.Identity.Name;
                prijava.broj            = broj.Value.ToString("D5") + "/" + year.ToString();

                partner partner;
                if (prijava.partner.sifra == null)
                {
                    partner = new partner();

                    partner.naziv   = prijava.kupac_ime;
                    partner.adresa  = prijava.kupac_adresa;
                    partner.telefon = prijava.kupac_telefon;
                    partner.email   = prijava.kupac_email;
                    partner.tip     = "P";

                    prijava.partner = partner;
                }
                else
                {
                    partner = _dbContext.partner.Where(p => p.sifra == prijava.kupac_sifra).FirstOrDefault();

                    partner.naziv   = prijava.kupac_ime;
                    partner.adresa  = prijava.kupac_adresa;
                    partner.telefon = prijava.kupac_telefon;
                    partner.email   = prijava.kupac_email;
                    partner.tip     = "P";
                    _dbContext.SaveChanges();

                    prijava.partner = partner;
                }
                if (prijava.dobavljac_partner != null)
                {
                    partner = _dbContext.partner.Where(p => p.sifra == prijava.dobavljac_sifra).FirstOrDefault();
                    prijava.dobavljac_partner = partner;
                }

                _dbContext.prijava.Add(prijava);
                _dbContext.SaveChanges();

                prijava.Korisnik = _dbContext.korisnik.FirstOrDefault(k => k.korisnicko_ime == prijava.serviser_primio);
                return(Ok(prijava));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Пример #25
0
        public IActionResult InsertPonuda(ponuda ponuda)
        {
            try
            {
                var    ponude        = _dbContext.ponuda.Where(p => p.datum.Year == DateTime.Now.Year);
                string maxPonudaBroj = null;
                int    year          = ponuda.datum.Year;
                int?   broj          = null;
                if (ponude != null && ponude.Count() > 0)
                {
                    maxPonudaBroj = ponude.Max(p => p.broj);
                    int dbroj = int.Parse(maxPonudaBroj.Split("/")[0]);
                    broj = dbroj + 1;
                }
                else
                {
                    broj = 1;
                }
                ponuda.radnik           = User.Identity.Name;
                ponuda.status           = "E";
                ponuda.broj             = broj.Value.ToString("D5") + "/" + year.ToString();
                ponuda.iznos_bez_rabata = 0;
                ponuda.iznos_sa_pdv     = 0;
                ponuda.iznos_sa_pdv     = 0;
                ponuda.pdv = 0;
                ponuda.iznos_sa_rabatom = 0;
                ponuda.rabat            = 0;
                partner partner;
                if (ponuda.partner.sifra == null)
                {
                    partner = new partner();

                    partner.naziv        = ponuda.partner_naziv;
                    partner.adresa       = ponuda.partner_adresa;
                    partner.maticni_broj = ponuda.partner_jib;
                    partner.telefon      = ponuda.partner_telefon;
                    partner.email        = ponuda.partner_email;
                    partner.tip          = "P";

                    ponuda.partner = partner;
                }
                else
                {
                    partner = _dbContext.partner.Where(p => p.sifra == ponuda.partner_sifra).FirstOrDefault();

                    partner.naziv        = ponuda.partner_naziv;
                    partner.adresa       = ponuda.partner_adresa;
                    partner.maticni_broj = ponuda.partner_jib;
                    partner.telefon      = ponuda.partner_telefon;
                    partner.email        = ponuda.partner_email;
                    partner.tip          = "P";
                    _dbContext.SaveChanges();

                    ponuda.partner = partner;
                }


                _dbContext.ponuda.Add(ponuda);
                _dbContext.SaveChanges();
                ponuda.Korisnik = _dbContext.korisnik.FirstOrDefault(k => k.korisnicko_ime == ponuda.radnik);
                return(Ok(ponuda));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception");
                return(BadRequest(ex));
            }
        }