public async Task <IActionResult> Edit(int id, [Bind("PunetoriId,Emri,Mbiemri,Gjinia,RoliId,NumriPersonal")] Punetori punetori)
        {
            if (id != punetori.PunetoriId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(punetori);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PunetoriExists(punetori.PunetoriId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoliId"] = new SelectList(_context.Roli, "RoliId", "RoliId", punetori.RoliId);
            return(View(punetori));
        }
Пример #2
0
 private void Map()
 {
     this.punetori = new Punetori()
     {
         Emri    = textBox1.Text.ToString(),
         Mbiemri = textBox2.Text.ToString()
     };
 }
Пример #3
0
        private void artikujList_Click(object sender, EventArgs e)
        {
            Punetori punetori = (Punetori)punetoretList.SelectedItem;

            if (punetori == null)
            {
                return;
            }
            new PopUp(new UpdateDeletePunetoret(punetori, new UpdateEvent(Load))).Show();
        }
Пример #4
0
 private void DeleteForm(int ID, string page)
 {
     if (page == "/Views/Punetoret/Index.aspx")
     {
         Punetori obj = new Punetori();
         obj.PunetoriID = ID;
         PunetoriMapper objm = new PunetoriMapper(obj);
         objm.Delete();
     }
 }
        public async Task <IActionResult> Create([Bind("PunetoriId,Emri,Mbiemri,Gjinia,RoliId,NumriPersonal")] Punetori punetori)
        {
            if (ModelState.IsValid)
            {
                _context.Add(punetori);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoliId"] = new SelectList(_context.Roli, "RoliId", "RoliId", punetori.RoliId);
            return(View(punetori));
        }
Пример #6
0
        private void placeShenimet()
        {
            Index form = (Index)Context.Handler;
            int   ID   = form.SelectedID;

            ViewState["SelectedID"] = ID;
            PunetoriiDLL();


            Punetori       ex = new Punetori();
            PunetoriMapper em = new PunetoriMapper(ex);

            em.SelectedID(ID);
        }
Пример #7
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (EmriTextBox.Text.Length == 0)
            {
                lblError.Visible = true;

                EmriTextBox.Focus();
                return;
            }
            else if (MbiemriTextBox.Text.Length == 0)
            {
                lblError.Visible = true;

                MbiemriTextBox.Focus();
                return;
            }
            else if (GjiniaTextBox.Text.Length == 0)
            {
                lblError.Visible = true;

                GjiniaTextBox.Focus();
                return;
            }
            else
            {
                int            ID   = Convert.ToInt32(ViewState["SelectedID"].ToString());
                Punetori       obj  = new Punetori();
                PunetoriMapper objm = new PunetoriMapper(obj);
                objm.SelectedID(ID);



                obj.Emri    = EmriTextBox.Text;
                obj.Mbiemri = MbiemriTextBox.Text;
                obj.Gjinia  = GjiniaTextBox.Text;
                obj.RoliID  = Int32.Parse(RoliDropDownList.SelectedItem.Value);

                objm.Update();
                Response.Redirect("Index.aspx");
            }
        }
Пример #8
0
        public void SelectAllPunetoret()
        {
            SqlConnection con = Generals.GetNewConnection();

            try
            {
                SqlCommand cmd = new SqlCommand("PunetoriSelectAll", con);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Punetori p = new Punetori();
                    p.PunetoriID = (int)rdr["PunetoriID"];
                    if (rdr["Emri"] != DBNull.Value)
                    {
                        p.Emri = (string)rdr["Emri"];
                    }
                    if (rdr["Mbiemri"] != DBNull.Value)
                    {
                        p.Mbiemri = (string)rdr["Mbiemri"];
                    }
                    if (rdr["Gjinia"] != DBNull.Value)
                    {
                        p.Gjinia = (string)rdr["Gjinia"];
                    }
                    if (rdr["RoliID"] != DBNull.Value)
                    {
                        p.RoliID = (int)rdr["RoliID"];
                    }

                    mPunetoret.Add(p);
                }
            }
            finally
            {
                con.Close();
            }
        }
Пример #9
0
        public async Task <ActionResult> CreateAsync(PunetoriCreateViewModel model)
        {
            //bool showError = false;
            if (ModelState.IsValid)
            {
                try
                {
                    var role = await roleManager.FindByNameAsync("User");

                    var addPunetor = new Punetori
                    {
                        UserId         = null,
                        Emri           = model.Emri,
                        Mbiemri        = model.Mbiemri,
                        NumriPersonal  = model.NumriPersonal,
                        Datelindja     = model.Datelindja,
                        Adresa         = model.Adresa,
                        KomunaId       = model.KomunaId,
                        KompaniaId     = model.KompaniaId,
                        DepartamentiId = model.DepartamentiId,
                        PozitaId       = model.PozitaId,
                        BankaId        = model.BankaId,
                        Xhirollogaria  = model.Xhirollogaria,
                        GradaId        = model.GradaId,
                        Created        = DateTime.Now,
                        CreatedBy      = user.UserId,
                        Email          = model.Email,
                        Telefoni       = model.Telefoni
                    };

                    var result = await punetoriRepository.AddAsync(addPunetor);

                    var addUser = new ApplicationUser
                    {
                        FirstName      = model.Emri,
                        LastName       = model.Mbiemri,
                        Email          = model.Email,
                        UserName       = model.NumriPersonal,
                        Address        = model.Adresa,
                        PhoneNumber    = model.Telefoni,
                        KompaniaId     = model.KompaniaId,
                        EmailConfirmed = true,
                        DepartamentiId = model.DepartamentiId
                    };

                    var resultUser = await userManager.CreateAsync(addUser, "123456789Aa#");

                    if (resultUser.Succeeded)
                    {
                        logger.LogInformation("Administrator created new user.");


                        resultUser = await userManager.AddToRoleAsync(addUser, role.Name);
                    }

                    var updatePunetoriUserID = await punetoriRepository.Get(addPunetor.Id);

                    updatePunetoriUserID.UserId = addUser.Id;

                    var updatedPunetori = await punetoriRepository.Update(updatePunetoriUserID);

                    alertService.Success("Punetori u regjistrua me sukses!");

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    var exception = ex;
                    alertService.Danger("Diqka shkoi keq!");
                    ViewBag.KomunaId = await kompaniaRepository.LoadKomuna(null);

                    ViewBag.Departamenti = await departamentiRepository.DepartamentiSelectList(null, false, false);

                    ViewBag.Kompania = await kompaniaRepository.KompaniaSelectList(null, false, false);

                    ViewBag.Pozita = await pozitaRepository.PozitaSelectList(null, false, false);

                    ViewBag.Banka = await bankaRepository.BankaSelectList(null, false, false);

                    ViewBag.Grada = await gradaRepository.GradaSelectList(null, false, false);

                    return(View(model));
                }
            }

            alertService.Information("Mbushi te gjitha fushat!");
            ViewBag.KomunaId = await kompaniaRepository.LoadKomuna(null);

            ViewBag.Departamenti = await departamentiRepository.DepartamentiSelectList(null, false, false);

            ViewBag.Kompania = await kompaniaRepository.KompaniaSelectList(null, false, false);

            ViewBag.Pozita = await pozitaRepository.PozitaSelectList(null, false, false);

            ViewBag.Banka = await bankaRepository.BankaSelectList(null, false, false);

            ViewBag.Grada = await gradaRepository.GradaSelectList(null, false, false);

            return(View(model));
        }
Пример #10
0
 public UpdateDeletePunetoret(Punetori punetori, UpdateEvent updateEvent)
 {
     InitializeComponent();
     this.punetori    = punetori;
     this.updateEvent = updateEvent;
 }
Пример #11
0
 public PunetoriMapper(Punetori p)
 {
     mPunetori = p;
 }