public async Task <IActionResult> Edit(int id, Pagesa pagesa) { if (id != pagesa.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pagesa); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PagesaExists(pagesa.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(pagesa)); }
private void UpdateData() { try { var data = new Pagesa(); if (!_isNewPayment && _parent.PaymentIDs.Contains(_parent.PaymentID)) { data = DatabaseModel.Instance.Pagesas.First(x => x.PageseId == _parent.PaymentID); } data.FormaPageses = txtPaymentForm.Text; data.PershkrimiPageses = txtServiceDescription.Text; data.Data = dtpDate.Value; data.ShumaPaguar = decimal.Parse(txtTotalPaid.Text); data.Zbritje = decimal.Parse(txtDiscount.Text); if (_isNewPayment) { DatabaseModel.Instance.Pagesas.Add(data); DatabaseModel.Instance.SaveChanges(); _parent.UpdatePaymentIds(); } else { DatabaseModel.Instance.SaveChanges(); } _parent.PaymentID = data.PageseId; } catch { MessageBox.Show("There was an error"); } }
protected void Button2_Click(object sender, EventArgs e) { DataClasses1DataContext financa_sh = new DataClasses1DataContext(); Pagesa p = new Pagesa(); if ((DropDownList1.SelectedItem.Text == "Shkolla")) { var pag_id = from c in financa_sh.Kestets from pag in financa_sh.Pagesas where (c.Id_pagesa == Convert.ToInt64(TextBox1.Text)) && (c.Id_pagesa == pag.Id_pagesa) select new { c.Id_nxenesi, pag.Id_pagesa, pag.Data, pag.Totali, pag.Monedha, pag.Nr_kestesh, pag.Skonto, pag.Penaliteti, pag.Koment }; GridView1.DataSource = pag_id.Distinct(); GridView1.DataBind(); } if ((DropDownList1.SelectedItem.Text == "Transporti")) { var pag_id = from c in financa_sh.Transportis from pag in financa_sh.Pagesas where (c.Id_pagesa == Convert.ToInt64(TextBox1.Text)) && (c.Id_pagesa == pag.Id_pagesa) select new { c.Id_nxenesi, pag.Id_pagesa, pag.Data, pag.Totali, pag.Monedha, pag.Nr_kestesh, pag.Skonto, pag.Penaliteti, pag.Koment }; GridView1.DataSource = pag_id.Distinct(); GridView1.DataBind(); } if ((DropDownList1.SelectedItem.Text == "Prenotim")) { var pag_id = from c in financa_sh.Prenotimis from pag in financa_sh.Pagesas where (c.Id_pagesa == Convert.ToInt64(TextBox1.Text)) && (c.Id_pagesa == pag.Id_pagesa) select new { c.Id_nxenesi, pag.Id_pagesa, pag.Data, pag.Totali, pag.Monedha, pag.Nr_kestesh, pag.Skonto, pag.Penaliteti, pag.Koment }; GridView1.DataSource = pag_id.Distinct(); GridView1.DataBind(); } }
protected void bind() { DataClasses1DataContext financa_sh = new DataClasses1DataContext(); Kestet k = new Kestet(); Pagesa p = new Pagesa(); GridView1.SelectedIndex = -1; var pag_n = from c in financa_sh.Kestets from d in financa_sh.Pagesas from pg in financa_sh.Prenotimis where ((c.Id_nxenesi.ToString() == Nxenesiddl.SelectedValue) && (c.Id_pagesa == d.Id_pagesa) && (d.Anulluar == false)) || ((pg.Id_pagesa == d.Id_pagesa) && (pg.Id_nxenesi == Convert.ToInt64(Nxenesiddl.SelectedItem.Value))) select new { d.Id_pagesa, d.Data, d.Totali, d.Monedha, d.Skonto, d.Penaliteti, d.Nr_kestesh, d.Koment, tr = (from t in financa_sh.Arkas where (t.Id_transaksioni == d.Id_transaksioni) select t).FirstOrDefault().Vendndodhja.ToString() }; GridView1.DataSource = pag_n.Distinct(); GridView1.DataBind(); if (GridView1.Rows.Count == 0) { Label6.Visible = false; Label8.Visible = false; } else { Label6.Visible = true; Label8.Visible = true; } }
protected void bind() { DataClasses1DataContext financa_sh = new DataClasses1DataContext(); Kestet k = new Kestet(); Pagesa p = new Pagesa(); //var pag_n = from c in financa_sh.Kestets // from d in financa_sh.Pagesas // where (c.Id_nxenesi.ToString() == Nxenesiddl.SelectedValue) && (c.Id_pagesa == d.Id_pagesa) // select new // { // d.Id_pagesa, // d.Data, // d.Totali, // d.Monedha, // d.Skonto, // d.Penaliteti, // tr = (from t in financa_sh.Arkas // where (t.Id_transaksioni == d.Id_transaksioni) // select t).FirstOrDefault().Koment.ToString().Remove(0,7) // }; var pag_n = from c in financa_sh.Transportis from d in financa_sh.Pagesas where (c.Id_nxenesi.ToString() == Nxenesiddl.SelectedValue) && (c.Id_pagesa == d.Id_pagesa) && (d.Anulluar == false) select new { d.Id_pagesa, d.Data, d.Totali, d.Monedha, d.Skonto, d.Penaliteti, d.Nr_kestesh, d.Koment, tr = (from t in financa_sh.Arkas where (t.Id_transaksioni == d.Id_transaksioni) select t).FirstOrDefault().Vendndodhja.ToString() }; GridView1.DataSource = pag_n.Distinct(); GridView1.DataBind(); }
protected void in_koment(long id_tr, string koment) { DataClasses1DataContext financa_sh = new DataClasses1DataContext(); Kestet k = new Kestet(); Pagesa pag = new Pagesa(); Arka a = new Arka(); var kom_tr = from c in financa_sh.Arkas where c.Id_transaksioni == id_tr select c; kom_tr.FirstOrDefault().Koment = koment; financa_sh.SubmitChanges(); }
public async Task <IActionResult> Create(Pagesa pagesa) { try { if (ModelState.IsValid) { pagesa.Active = true; pagesa.DataEPageses = DateTime.Now; switch (pagesa.Shuma) { case 5: pagesa.DataESkadimit = DateTime.Now.AddMonths(1); break; case 10: pagesa.DataESkadimit = DateTime.Now.AddMonths(3); break; case 15: pagesa.DataESkadimit = DateTime.Now.AddMonths(6); break; } _context.Add(pagesa); Klienti klienti = _context.Klienti.Where(k => k.id == pagesa.Klienti_id).First(); klienti.Aktiv = true; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } }catch (DbUpdateException ex) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(pagesa)); }
protected void Button1_Click(object sender, EventArgs e) { DataClasses1DataContext financa_sh = new DataClasses1DataContext(); Kestet k = new Kestet(); Pagesa pag = new Pagesa(); Arka a = new Arka(); CheckBox chbTemp1 = GridView1.Rows[0].FindControl("CheckBox1") as CheckBox; int j = 0; // gjen sa chckbox jane te chekuara for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox chbTemp = GridView1.Rows[i].FindControl("CheckBox1") as CheckBox; if ((chbTemp.Checked) && (chbTemp.Enabled == true)) { j = j + 1; } } if (j > 0) { //insert te tabela e arkes var vlera_fundit = from t in financa_sh.Arkas orderby t.Id_transaksioni descending select new { t.Tot_E, t.Tot_L, t.Tot_S }; if (valutalbl0.Text == "EUR") { a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + Convert.ToDecimal(totalilbl.Text); a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + 0; a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + 0; } if (valutalbl0.Text == "USD") { a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + Convert.ToDecimal(totalilbl.Text); a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + 0; a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + 0; } if (valutalbl0.Text == "LEK") { a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + Convert.ToDecimal(totalilbl.Text); a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + 0; a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + 0; } a.Vendndodhja = DropDownList1.SelectedItem.Text; a.Data = DateTime.Now; a.Modifikuar_nga = HttpContext.Current.User.Identity.Name; a.Vlera = Convert.ToDecimal(totalilbl.Text); a.Valuta = valutalbl0.Text; financa_sh.Arkas.InsertOnSubmit(a); financa_sh.SubmitChanges(); // gjej id e transaksionit e fundit var tr_fundit = from t in financa_sh.Arkas orderby t.Id_transaksioni descending select t.Id_transaksioni; //insert te tabela e pageses pag.Data = DateTime.Now; pag.Monedha = valutalbl0.Text; pag.Totali = Convert.ToDecimal(totalilbl.Text); pag.Skonto = Convert.ToDecimal(skontolbl.Text); pag.Penaliteti = Convert.ToDecimal(penlbl.Text); pag.Id_transaksioni = tr_fundit.FirstOrDefault(); pag.Nr_kestesh = j; pag.Koment = datepicker0.Text; pag.Anulluar = false; financa_sh.Pagesas.InsertOnSubmit(pag); financa_sh.SubmitChanges(); // gjej id e pag e fundit var pg_fundit = from t in financa_sh.Pagesas orderby t.Id_pagesa descending select t.Id_pagesa; //paguar = true ne tabelen e kesteve te transportit var keste_pa = from c in financa_sh.Transportis where (c.Id_nxenesi.ToString() == Nxenesiddl.SelectedValue) //&& (c.Paguar == false) select c; int numer_keste = 0; int count = 0; foreach (var d in keste_pa) { CheckBox chbTemp = GridView1.Rows[count].FindControl("CheckBox1") as CheckBox; if (chbTemp.Checked && chbTemp.Enabled) { d.Paguar = true; d.Id_pagesa = pg_fundit.FirstOrDefault(); numer_keste = numer_keste + 1; } count = count + 1; } financa_sh.SubmitChanges(); GridViewRow row = GridView1.Rows[0]; string s; s = (row.Cells[0].Text); if (s != "0") { in_koment(tr_fundit.FirstOrDefault(), "Pagese trans Nr keste : " + numer_keste.ToString() + " Skonto : " + skontolbl.Text + "% Pen : " + penlbl.Text + "%"); } else { in_koment(tr_fundit.FirstOrDefault(), "Pagese trans Nr keste : " + "P + " + (numer_keste - 1).ToString() + " Skonto : " + skontolbl.Text + "% Pen : " + penlbl.Text + "%"); } msbox("Pagesa u krye !"); hide(); } else { msbox("Duhet te zgjidhni te pakten nje kest !"); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataClasses1DataContext financa_sh = new DataClasses1DataContext(); long id = Convert.ToInt64(GridView1.DataKeys[e.RowIndex].Value); Skonto sk = new Skonto(); Kestet k = new Kestet(); Pagesa pag = new Pagesa(); Arka a = new Arka(); //fshin skontot nga tabela e skontove var skonto_id = from c in financa_sh.Skontos where (c.Id_nxenesi == id) select c; //kontrollon nese ka pagesa var join_pg = from pg in financa_sh.Pagesas from ks in financa_sh.Kestets where (pg.Id_pagesa == ks.Id_pagesa) && (pg.Anulluar == false) select pg; //foreach (var v in join_pg) //{ // v.Anulluar = true; // v.Koment = "Anulluar"; //}; //var join_pg1 = from pg in financa_sh.Pagesas // from ks in financa_sh.Kestets // where (pg.Id_pagesa == ks.Id_pagesa) // select ks; //foreach (var v in join_pg1) //{ // v.Paguar = false; //}; //fshin kestet var kestet_id = from p in financa_sh.Kestets where (p.Id_nxenesi == id) select p; if (join_pg.Count() == 0) { financa_sh.Skontos.DeleteAllOnSubmit(skonto_id); financa_sh.Kestets.DeleteAllOnSubmit(kestet_id); //financa_sh.Pagesas.DeleteAllOnSubmit(join_pg); financa_sh.SubmitChanges(); bind(); } else { msbox("Kestet nuk u fshine pasi jane bere pagesa !"); } ////ANULLON transaksionet e bera e bera //var ar = from ak in financa_sh.Arkas // from p in join_pg // where (ak.Id_transaksioni == p.Id_transaksioni) // select ak; //foreach (var v in ar) //{ // v.Anulluar = true; // v.Koment = "Fshirje kestesh"; //}; }
protected void anullo_keste_shkolla() { DataClasses1DataContext financa_sh = new DataClasses1DataContext(); Pagesa p = new Pagesa(); Kestet k = new Kestet(); Arka a = new Arka(); //anullon pagesen if (TextBox1.Text == "") { return; } var pag_id = from c in financa_sh.Pagesas where (c.Id_pagesa == Convert.ToInt64(TextBox1.Text)) select c; if (pag_id.Count() == 0) { return; } foreach (var v in pag_id) { v.Anulluar = true; v.Koment = TextBox2.Text; } //fshin kestet nqs ka var kestet_p = from c in financa_sh.Kestets where (c.Id_pagesa == Convert.ToInt64(TextBox1.Text)) select c; foreach (var v in kestet_p) { v.Paguar = false; v.Id_pagesa = 0; } //anullon transaksionin var arka_pag = from c in financa_sh.Arkas where (c.Id_transaksioni == pag_id.FirstOrDefault().Id_transaksioni) select c; var vlera_fundit = from t in financa_sh.Arkas orderby t.Id_transaksioni descending select new { t.Tot_E, t.Tot_L, t.Tot_S }; if (pag_id.FirstOrDefault().Monedha.Trim() == "EUR") { a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E - pag_id.FirstOrDefault().Totali; a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + 0; a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + 0; } if (pag_id.FirstOrDefault().Monedha.Trim() == "USD") { a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S - pag_id.FirstOrDefault().Totali; a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + 0; a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + 0; } if (pag_id.FirstOrDefault().Monedha.Trim() == "LEK") { a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L - pag_id.FirstOrDefault().Totali; a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + 0; a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + 0; } a.Data = DateTime.Now; a.Modifikuar_nga = HttpContext.Current.User.Identity.Name; a.Vendndodhja = arka_pag.FirstOrDefault().Vendndodhja; a.Vlera = -pag_id.FirstOrDefault().Totali; a.Valuta = arka_pag.FirstOrDefault().Valuta; a.Koment = "Anulluar pagesa shkolla nr : " + pag_id.FirstOrDefault().Id_pagesa.ToString(); financa_sh.Arkas.InsertOnSubmit(a); //a.Anulluar = true; //a.Koment = "Anulluar pagese nr :" +TextBox1.Text; //if (pag_id.FirstOrDefault().Monedha.Trim() == "EUR") // a.Tot_E = a.Tot_E - pag_id.FirstOrDefault().Totali; //if (pag_id.FirstOrDefault().Monedha.Trim() == "USD") // a.Tot_S = a.Tot_S - pag_id.FirstOrDefault().Totali; //if (pag_id.FirstOrDefault().Monedha.Trim() == "LEK") // a.Tot_L = a.Tot_L - pag_id.FirstOrDefault().Totali; //financa_sh.Arkas.InsertOnSubmit(a); // gjen pagesat qe ka bere nxenesi var kestet_id = from c in financa_sh.Kestets where (c.Id_nxenesi == kestet_p.FirstOrDefault().Id_nxenesi) select c; //nqs ka bere pagesa te mevoneshme nuk ben submit int i = kestet_id.Count(); foreach (var v in kestet_id) { if (v.Id_pagesa > Convert.ToInt64(TextBox1.Text)) { msbox("Pagesa nuk mund te anullohet sepse nxenesi ka pagesa te metejshme !"); return; } } financa_sh.SubmitChanges(); msbox("Pagesa u anullua me sukses !"); }
protected void CheckBox1_CheckedChanged1(object sender, EventArgs e) { long id; bool pag_tru; bool chk_enabled; DataClasses1DataContext financa_sh = new DataClasses1DataContext(); // String scriptText = //"return confirm('Do you want to submit the page?')"; // ClientScript.RegisterOnSubmitStatement(this.GetType(), // "alert", scriptText); msbox1("aaa"); if (cmimi_pren() > 0) { for (int i = 0; i < GridView1.Rows.Count; i++) { Prenotimi nxenesit = new Prenotimi(); Pagesa pag = new Pagesa(); Arka a = new Arka(); id = Convert.ToInt64((GridView1.Rows[i].Cells[3].Text).ToString()); var pr_id = financa_sh.Prenotimis.Single (p => p.Id_nxenesi == id); pr_id.Paguar = Convert.ToBoolean(((CheckBox)GridView1.Rows[i].FindControl("CheckBox1")).Checked);// paguan kestet qe jane checked dhe pag = false per ato qe sjane te checkuara pag_tru = pr_id.Paguar; chk_enabled = Convert.ToBoolean(((CheckBox)GridView1.Rows[i].FindControl("CheckBox1")).Enabled); financa_sh.SubmitChanges(); if (pag_tru && chk_enabled) { // insert te tabela e arkes var vlera_fundit = from t in financa_sh.Arkas orderby t.Id_transaksioni descending select new { t.Tot_E, t.Tot_L, t.Tot_S }; if (Valuta_pren() == "EUR") { a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + cmimi_pren(); a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + 0; a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + 0; } if (Valuta_pren() == "USD") { a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + cmimi_pren(); a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + 0; a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + 0; } if (Valuta_pren() == "LEK") { a.Tot_L = vlera_fundit.FirstOrDefault().Tot_L + cmimi_pren(); a.Tot_E = vlera_fundit.FirstOrDefault().Tot_E + 0; a.Tot_S = vlera_fundit.FirstOrDefault().Tot_S + 0; } a.Vendndodhja = "Cash"; a.Data = DateTime.Now; a.Modifikuar_nga = HttpContext.Current.User.Identity.Name; a.Vlera = cmimi_pren(); a.Valuta = Valuta_pren(); a.Koment = "Pagese prenotimi shkolla."; financa_sh.Arkas.InsertOnSubmit(a); financa_sh.SubmitChanges(); // gjej id e transaksionit e fundit var tr_fundit = from t in financa_sh.Arkas orderby t.Id_transaksioni descending select t.Id_transaksioni; //insert te tabela e pageses pag.Data = DateTime.Now; pag.Monedha = Valuta_pren(); pag.Totali = cmimi_pren(); pag.Skonto = 0; pag.Penaliteti = 0; pag.Id_transaksioni = tr_fundit.FirstOrDefault(); pag.Nr_kestesh = 0; pag.Koment = "Pagese prenotimi"; pag.Anulluar = false; financa_sh.Pagesas.InsertOnSubmit(pag); financa_sh.SubmitChanges(); // gjej id e pag e fundit var pg_fundit = from t in financa_sh.Pagesas orderby t.Id_pagesa descending select t.Id_pagesa; var pren = from c in financa_sh.Prenotimis where (c.Id_nxenesi == id) select c; foreach (var d in pren) { d.Id_pagesa = pg_fundit.FirstOrDefault(); } financa_sh.SubmitChanges(); } } //insert te tabela se prenotimit //var pg_fundit = from t in financa_sh.Pagesas // orderby t.Id_pagesa descending // select t.Id_pagesa; //var nx_p = from c in financa_sh.Prenotimis // where (c.Id_nxenesi == id) // select c; //int count = 0; //foreach (var d in nx_p) //{ // CheckBox chbTemp = GridView1.Rows[count].FindControl("CheckBox1") as CheckBox; // if (chbTemp.Checked) // { // d.Paguar = true; // d.Id_pagesa = pg_fundit.FirstOrDefault(); // } // count = count + 1; //} //financa_sh.SubmitChanges(); GridView1.EditIndex = -1; bind(); } else { msbox("Klases nuk i jane konfiguruar cmimet per vitin shkollor perkates !"); } }