public void Delete(object sender, EventArgs e) { if (ugdFormPregled.ActiveRow.ParentRow != null) { return; //Ovo sprečava da se odabire s menija (insert, update, delete) ukoliko ne radi o Parent redu u gridu (Band[0]) } if (ugdFormPregled.ActiveRow != null) { BusinessLogic.Inventura.pID = Convert.ToInt32(ugdFormPregled.ActiveRow.Cells["ID"].Value); DateTime dt = (DateTime)ugdFormPregled.ActiveRow.Cells["DatumInventure"].Value; string dat = dt.ToShortDateString(); if (MessageBox.Show(string.Format("Obrisati Inventuru sa datumom '{0}'?", dat), "Brisanje Inventure", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { StringBuilder message = new StringBuilder(); if (!objekt.Delete(message)) { MessageBox.Show(message.ToString()); } try { BusinessLogic.Inventura.pSelectedIndex = ugdFormPregled.ActiveRow.Index; } catch { } LoadGridData(); } } } }
private void FormLoad(object sender, EventArgs e) { _loadMode = true;//db - 07.02.2017 using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { LoadSkladiste(objekt, pSkladiste); if (FormEditMode == Enums.FormEditMode.Update || FormEditMode == Enums.FormEditMode.Copy) { foreach (var item in uceStavka.Items) { if (((Mipsed7.DataAccessLayer.SqlClient.FillCombo)(item)).ID == pStavka) { uceStavka.SelectedItem = item; break; } } uneKolicina.Value = pKolicina; uneNabavnaCijena.Value = pNabavnaCijena; uceStavka.DisplayMember = "Naziv"; uceStavka.ValueMember = "ID"; } } _loadMode = false; }
private void FormLoad(object sender, EventArgs e) { BusinessLogic.Inventura.pInventuraStavke = new DataTable(); BusinessLogic.Inventura.pInventuraStavke.Columns.Add("SEL", typeof(bool)); BusinessLogic.Inventura.pInventuraStavke.Columns.Add("ID_Izdatnice", typeof(int)); BusinessLogic.Inventura.pInventuraStavke.Columns.Add("ID_Proizvoda", typeof(int)); BusinessLogic.Inventura.pInventuraStavke.Columns.Add("StavkaSkladista", typeof(string)); BusinessLogic.Inventura.pInventuraStavke.Columns.Add("Kolicina", typeof(decimal)); BusinessLogic.Inventura.pInventuraStavke.Columns.Add("NabavnaCijena", typeof(decimal)); BusinessLogic.Inventura.pInventuraStavke.Columns.Add("RedniBroj", typeof(int)); BusinessLogic.Inventura.pInventuraStavke.PrimaryKey = new DataColumn[] { BusinessLogic.Inventura.pInventuraStavke.Columns["ID_Proizvoda"] }; using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { udtDatumInventure.Enabled = true; udtDatumInventure.Value = DateTime.Now; LoadSkladiste(objekt); if (FormEditMode == Enums.FormEditMode.Update) { LoadForm(objekt); } else if (FormEditMode == Enums.FormEditMode.Copy) { LoadForm(objekt); } } }
private void LoadGridData() { using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { ugdFormPregled.DataSource = objekt.GetMainGridData(); ugdFormPregled.DataBind(); //db - 5.12.2016 string[] popis = new string[] { "StvarnaKolicina" }; //edit grida Utils.Tools.UltraGridStyling(ugdFormPregled, popis); if (ugdFormPregled.DisplayLayout.Bands.Count > 0) { //1. layer u gridu ugdFormPregled.DisplayLayout.Bands[0].Columns["ID"].Hidden = true; ugdFormPregled.DisplayLayout.Bands[0].Columns["TS"].Hidden = true; ugdFormPregled.DisplayLayout.Bands[0].Columns["IDSkladista"].Hidden = true; //2. layer u gridu ugdFormPregled.DisplayLayout.Bands[1].Columns["ID"].Hidden = true; ugdFormPregled.DisplayLayout.Bands[1].Columns["ID_Inventura"].Hidden = true; ugdFormPregled.DisplayLayout.Bands[1].Columns["ID_Proizvod"].Hidden = true; ugdFormPregled.DisplayLayout.Bands[1].Columns["CijenaPDV"].Hidden = false; ////db - 9.11.2016 //ugdFormPregled.DisplayLayout.Bands[0].Columns["Ozn"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; //ugdFormPregled.DisplayLayout.Bands[0].Columns["Ozn"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; //ugdFormPregled.DisplayLayout.Bands[0].Columns["Ozn"].Width = 20; ugdFormPregled.DisplayLayout.Bands[0].Columns["IDGodina"].Header.Caption = "Godina"; ugdFormPregled.DisplayLayout.Bands[1].Columns["NAZIVPROIZVOD"].Header.Caption = "Proizvod"; ugdFormPregled.DisplayLayout.Bands[1].Columns["NAZIVJEDINICAMJERE"].Header.Caption = "Jedinica mjere"; //cijena ugdFormPregled.DisplayLayout.Bands[1].Columns["KolicinaZaliha"].Header.Caption = "Količina zaliha"; ugdFormPregled.DisplayLayout.Bands[1].Columns["StvarnaKolicina"].Header.Caption = "Stvarna količina"; //ugdFormPregled.DisplayLayout.Bands[0].Columns["Sifra"].Width = 55; //ugdFormPregled.DisplayLayout.Bands[0].Columns["Dokument"].Width = 180; //ugdFormPregled.DisplayLayout.Bands[0].Columns["Skladiste"].Width = 130; //ugdFormPregled.DisplayLayout.Bands[0].Columns["UkupanIznos"].Width = 80; //ugdFormPregled.DisplayLayout.Bands[0].Columns["Napomena"].Width = 200; } foreach (UltraGridRow row in ugdFormPregled.Rows) { if (row.Index == BusinessLogic.Inventura.pSelectedIndex) { ugdFormPregled.ActiveRow = row; } } } }
private void LoadForm(BusinessLogic.Inventura objekt) { var selected = objekt.GetSelectedInventura(); if (selected != null) { udtDatumInventure.Value = Convert.ToDateTime(selected["DatumInventure"].ToString()); //udtDatumNastajanja.Enabled = false; uceSkladiste.Value = Convert.ToInt32(selected["IDSkladiste"].ToString()); //setiranje stavki za punjenje grida BusinessLogic.Inventura.pInventuraStavke = objekt.GetPostojeceStavke(); BusinessLogic.Inventura.pInventuraStavke.PrimaryKey = new DataColumn[] { BusinessLogic.Inventura.pInventuraStavke.Columns["ID_Proizvod"] }; //punjenje grida ugdInventuraStavke.DataSource = BusinessLogic.Inventura.pInventuraStavke; ugdInventuraStavke.DataBind(); //selekcija editabilnih kolona Utils.Tools.UltraGridStyling(ugdInventuraStavke); if (ugdInventuraStavke.DisplayLayout.Bands.Count > 0) { ugdInventuraStavke.DisplayLayout.Bands[0].Columns["SEL"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["SEL"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["ID_Inventura"].Hidden = true; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["ID_Proizvod"].Hidden = true; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["StavkaSkladista"].Format = "F4"; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["KolicinaZaliha"].Format = "F4"; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["StvarnaKolicina"].Format = "F4"; //ugdInventuraStavke.DisplayLayout.Bands[0].Columns["RedniBroj"].Header.VisiblePosition = 1; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["StavkaSkladista"].Header.VisiblePosition = 2; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["KolicinaZaliha"].Header.VisiblePosition = 3; ugdInventuraStavke.DisplayLayout.Bands[0].Columns["StvarnaKolicina"].Header.VisiblePosition = 4; } if (BusinessLogic.Inventura.pInventuraStavke.Rows.Count == 0) { btnBrisiStavku.Enabled = false; btnUrediStavku.Enabled = false; } else { btnBrisiStavku.Enabled = true; btnUrediStavku.Enabled = true; } } }
private void FillStanjeNaSkladistu(int stavka) { using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { var row = objekt.GetStanjeSkladiste(stavka, pSkladiste, pDatum); lblStanje.Text = (Convert.ToDecimal(row["Stanje"]) + kolicinaEdit).ToString(); try { uneNabavnaCijena.Value = row["Cijena"]; pNabavnaCijena = Convert.ToDecimal(uneNabavnaCijena.Value); } catch { uneNabavnaCijena.Value = pNabavnaCijena; } } }
public void IspisVishak(object sendr, EventArgs e) { if (ugdFormPregled.ActiveRow != null) { ReportDocument rpt = new ReportDocument(); //NOVI report za selektirane inventure rpt.Load(System.Windows.Forms.Application.StartupPath + @"\Izvjestaji\crpInventuraVishak.rpt"); // Set connection string from config in existing LogonProperties rpt.DataSourceConnections[0].SetConnection(Mipsed7.Core.ApplicationDatabaseInformation.ServerName, Mipsed7.Core.ApplicationDatabaseInformation.DatabaseName, true); rpt.DataSourceConnections[0].SetLogon(Mipsed7.Core.ApplicationDatabaseInformation.SqlUserName, Mipsed7.Core.ApplicationDatabaseInformation.SqlPassword); rpt.DataSourceConnections[0].IntegratedSecurity = false; //Dictionary<int, int> oznaceni = VratiOznaceneInventure(ugdFormPregled.Rows); BusinessLogic.Inventura.pID = (int)ugdFormPregled.ActiveRow.Cells["ID"].Value; int idInv = Convert.ToInt32(ugdFormPregled.ActiveRow.Cells["ID"].Value); DateTime dat = Convert.ToDateTime(ugdFormPregled.ActiveRow.Cells["DatumInventure"].Value); using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { rpt.SetDataSource(objekt.DohvatiInventuruVishak(idInv, dat)); KORISNIKDataSet set2 = new KORISNIKDataSet(); new KORISNIKDataAdapter().Fill(set2); if (set2.KORISNIK.Rows.Count > 0) { rpt.SetParameterValue("NAZIV", RuntimeHelpers.GetObjectValue(set2.KORISNIK.Rows[0]["KORISNIK1NAZIV"])); rpt.SetParameterValue("OIB", RuntimeHelpers.GetObjectValue(set2.KORISNIK.Rows[0]["KORISNIKOIB"])); rpt.SetParameterValue("Adresa", RuntimeHelpers.GetObjectValue(set2.KORISNIK.Rows[0]["KORISNIK1ADRESA"])); rpt.SetParameterValue("Datum", dat); } ExtendedWindowWorkspace workspace = new ExtendedWindowWorkspace(); PreviewReportWorkItem item = this.Controller.WorkItem.Items.Get <PreviewReportWorkItem>("Pregled"); if (item == null) { item = this.Controller.WorkItem.Items.AddNew <PreviewReportWorkItem>("Pregled"); } item.Izvjestaj = rpt; item.Activate(); item.Show(item.Workspaces["main"]); } } }
public void Ispis(object sender, EventArgs e) { if (ugdFormPregled.ActiveRow != null) { ReportDocument rpt = new ReportDocument(); //POTrEBNO JE KREIRATI NOVI REPORT SAMO ZA INVENTURE!! //rpt.Load(System.Windows.Forms.Application.StartupPath + @"\Izvjestaji\crpIzdatnica.rpt"); // Set connection string from config in existing LogonProperties rpt.DataSourceConnections[0].SetConnection(Mipsed7.Core.ApplicationDatabaseInformation.ServerName, Mipsed7.Core.ApplicationDatabaseInformation.DatabaseName, true); rpt.DataSourceConnections[0].SetLogon(Mipsed7.Core.ApplicationDatabaseInformation.SqlUserName, Mipsed7.Core.ApplicationDatabaseInformation.SqlPassword); rpt.DataSourceConnections[0].IntegratedSecurity = false; BusinessLogic.Inventura.pID = (int)ugdFormPregled.ActiveRow.Cells["ID"].Value; using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { rpt.SetDataSource(objekt.GetInventuraIspis()); KORISNIKDataSet set2 = new KORISNIKDataSet(); new KORISNIKDataAdapter().Fill(set2); //if (set2.KORISNIK.Rows.Count > 0) //{ // rpt.SetParameterValue("NAZIV", RuntimeHelpers.GetObjectValue(set2.KORISNIK.Rows[0]["KORISNIK1NAZIV"])); // rpt.SetParameterValue("OIB", RuntimeHelpers.GetObjectValue(set2.KORISNIK.Rows[0]["KORISNIKOIB"])); // rpt.SetParameterValue("Adresa", RuntimeHelpers.GetObjectValue(set2.KORISNIK.Rows[0]["KORISNIK1ADRESA"])); //} ExtendedWindowWorkspace workspace = new ExtendedWindowWorkspace(); PreviewReportWorkItem item = this.Controller.WorkItem.Items.Get <PreviewReportWorkItem>("Pregled"); if (item == null) { item = this.Controller.WorkItem.Items.AddNew <PreviewReportWorkItem>("Pregled"); } item.Izvjestaj = rpt; item.Activate(); item.Show(item.Workspaces["main"]); } } }
private void LoadSkladiste(BusinessLogic.Inventura objekt, int skladiste) { uceStavka.Items.AddRange(objekt.GetStavka(skladiste)); //dohvat iz BAZE!! uceStavka.DisplayMember = "Naziv"; uceStavka.ValueMember = "ID"; }
/// <summary> /// Punjenje skladišta u combo /// </summary> /// <param name="objekt"></param> private void LoadSkladiste(BusinessLogic.Inventura objekt) { uceSkladiste.DataSource = objekt.GetSkladiste(); uceSkladiste.DataBind(); }
private bool SaveData() { if (uceSkladiste.Text == "") { uceSkladiste.Focus(); return(false); } lblValidationMessages.ResetText(); StringBuilder message = ValidateDataInput(); if (message.Length == 0) { using (BusinessLogic.Inventura objekt = new BusinessLogic.Inventura()) { objekt.idSkladiste = (Int32)uceSkladiste.Value; Inventura.datumInventure = udtDatumInventure.DateTime; objekt.idGodina = (Int16)udtDatumInventure.DateTime.Year; ////set current time na odabrani datum ako je vrijeme 0 //if (objekt.pDatumNastajanja.TimeOfDay.TotalSeconds == 0) //{ // DateTime date = objekt.pDatumNastajanja.Date.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second); // objekt.pDatumNastajanja = date; //} if (FormEditMode == Enums.FormEditMode.Insert || FormEditMode == Enums.FormEditMode.Copy) { if (objekt.Insert(message, objekt)) { FormEditMode = Enums.FormEditMode.Update; return(true); } } else if (this.FormEditMode == Enums.FormEditMode.Update) { int brojStavki = 0; brojStavki = ugdInventuraStavke.Rows.Count; //nova tablica koja prima izmjenjene stavke s grida InventuraStavke stav = new InventuraStavke(); DataTable dt = new DataTable(); dt.Columns.Add("IDInventure", typeof(int)); dt.Columns.Add("IDProizvod", typeof(int)); dt.Columns.Add("Cijena", typeof(decimal)); dt.Columns.Add("KolicinaZaliha", typeof(decimal)); dt.Columns.Add("StvarnaKolicina", typeof(decimal)); //dodavanje redova for (int i = 0; i < brojStavki; i++) { DataRow dr = dt.NewRow(); dt.Rows.Add(dr); } //db - 02.02.2017 - ubačena IMENA umjesto indexa kolona //prebacivanje vrijednosti for (int i = 0; i < ugdInventuraStavke.Rows.Count; i++) { dt.Rows[i]["IDInventure"] = Convert.ToInt32(ugdInventuraStavke.Rows[i].Cells["ID_Inventura"].Value); dt.Rows[i]["IDProizvod"] = Convert.ToInt32(ugdInventuraStavke.Rows[i].Cells["ID_Proizvod"].Value); dt.Rows[i]["KolicinaZaliha"] = Convert.ToDecimal(ugdInventuraStavke.Rows[i].Cells["KolicinaZaliha"].Value); if (ugdInventuraStavke.Rows[i].Cells["StvarnaKolicina"].Value == DBNull.Value) { dt.Rows[i]["StvarnaKolicina"] = DBNull.Value; } else { dt.Rows[i]["StvarnaKolicina"] = Convert.ToDecimal(ugdInventuraStavke.Rows[i].Cells["StvarnaKolicina"].Value); } } objekt.UpdateStavke(Convert.ToInt32(dt.Rows[0][0]), dt); return(true); } } } //setiranje natrag na false Materijalno.UI.Dokumenti.InventuraFormPregled._update = false; Materijalno.UI.Dokumenti.InventuraFormPregled._insert = false; lblValidationMessages.Text = message.ToString(); return(false); }