public virtual void Fill() { this.PreFill(); this.dsAMSKUPINEDataSet1 = new AMSKUPINEDataSet(); this.m_StartRow = 0; this.Cursor = Cursors.WaitCursor; this.m_GridLoading = true; ThreadPool.QueueUserWorkItem(new WaitCallback(this.FillDataThread), Thread.CurrentPrincipal); }
public void DosImportHandler(object sender, EventArgs e) { int num = 0; OSDataSet dataSet = new OSDataSet(); OSDataAdapter adapter2 = new OSDataAdapter(); if (Interaction.MsgBox("Ukoliko prebacujete OS pritisnite tipku <YES>", MsgBoxStyle.YesNo, "Osnovna sredstva / SI") == MsgBoxResult.Yes) { num = 1; } else { num = 2; } if (Interaction.MsgBox("Postojeća OS biti će obrisane, želite li stvarno nastaviti???", MsgBoxStyle.YesNo, "Osnovna sredstva / SI") != MsgBoxResult.No) { IEnumerator enumerator = null; try { enumerator = this.userControlDataGridOS.DataGrid.DataSet.OS.Rows.GetEnumerator(); while (enumerator.MoveNext()) { ((DataRow)enumerator.Current).Delete(); } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } AMSKUPINEDataSet set3 = new AMSKUPINEDataSet(); new AMSKUPINEDataAdapter().Fill(set3); adapter2.Update(this.userControlDataGridOS.DataGrid.DataSet); OpenFileDialog dialog = new OpenFileDialog { InitialDirectory = @"c:\", Filter = "txt files (*.dbf)|*.dbf|All files (*.*)|*.*", FilterIndex = 2, RestoreDirectory = true }; if (dialog.ShowDialog() == DialogResult.OK) { OleDbDataAdapter adapter; string str3 = dialog.FileName.ToUpper().Replace(@"\OSM.DBF", ""); string prompt = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + str3 + ";Extended Properties=dBase IV;"; Interaction.MsgBox(prompt, MsgBoxStyle.OkOnly, null); OleDbConnection selectConnection = new OleDbConnection(prompt); if (Interaction.MsgBox("Želite li prebaciti i sredstva sa količinom 0", MsgBoxStyle.YesNo, null) == MsgBoxResult.Yes) { adapter = new OleDbDataAdapter("select * FROM OSM", selectConnection); } else { adapter = new OleDbDataAdapter("select * FROM OSM where KOLU > 0", selectConnection); } DataSet set2 = new DataSet(); adapter.Fill(set2, "OSA"); if (Interaction.MsgBox("Broj pronađenih zapisa: " + Conversions.ToString(set2.Tables["OSA"].Rows.Count) + "\r\n\r\nŽelite li zadržati importirane zapise?", MsgBoxStyle.YesNo, null) == MsgBoxResult.No) { set2.RejectChanges(); } else { IEnumerator enumerator2 = null; int num2 = 1; try { enumerator2 = set2.Tables["OSA"].Rows.GetEnumerator(); while (enumerator2.MoveNext()) { DataRow current = (DataRow)enumerator2.Current; DataRow row = dataSet.OS.NewRow(); if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["SIFRA"]))) { DateTime now; DateTime time2; string str4 = string.Empty; string str6 = string.Empty; string str5 = string.Empty; if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["NAZIV"]))) { str5 = DB.Ko437to852(Conversions.ToString(current["NAZIV"])).Substring(0, DB.Ko437to852(Conversions.ToString(current["NAZIV"])).Length - 1); } else { str5 = "Nije postojao upisani naziv"; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["DATUM"]))) { now = Conversions.ToDate(Interaction.IIf(Information.IsDate(RuntimeHelpers.GetObjectValue(current["DATUM"])), Conversions.ToDate(current["DATUM"]), DateTime.Now)); } else { now = DateTime.Now; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["DATUMUP"]))) { time2 = Conversions.ToDate(Interaction.IIf(Information.IsDate(RuntimeHelpers.GetObjectValue(current["DATUMUP"])), Conversions.ToDate(current["DATUMUP"]), DateTime.Now)); } else { time2 = DateTime.Now; } if (DateTime.Compare(time2, Conversions.ToDate("01/01/1754")) < 0) { time2 = DateTime.Now; } if (DateTime.Compare(now, Conversions.ToDate("01/01/1754")) < 0) { now = DateTime.Now; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["AMORT"]))) { str6 = Conversions.ToString(current["AMORT"]); } else { str6 = ""; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["NAPOMENA"]))) { str4 = DB.Ko437to852(Conversions.ToString(current["NAPOMENA"])).Substring(0, DB.Ko437to852(Conversions.ToString(current["NAPOMENA"])).Length - 1); } else { str4 = "Nije postojala upisana napomena"; } row["invbroj"] = Conversions.ToInteger(current["SIFRA"]); row["nazivos"] = Strings.Left(str5, 0x31); row["datumnabavke"] = now; row["datumuporabe"] = time2; if (set3.AMSKUPINE.Select("kratkasifra = '" + str6 + "'").Length == 0) { row["idamskupine"] = 0x270f; } else { row["idamskupine"] = RuntimeHelpers.GetObjectValue(set3.AMSKUPINE.Select("kratkasifra = '" + str6 + "'")[0]["idamskupine"]); } row["idosvrsta"] = num; row["napomenaos"] = Strings.Left(str4, 0x31); dataSet.OS.Rows.Add(row); DataRow row4 = dataSet.OSTEMELJNICA.NewRow(); row4["invbroj"] = Conversions.ToInteger(current["SIFRA"]); row4["idosdokument"] = 1; row4["osbrojdokumenta"] = 0; row4["osdatumdok"] = time2; row4["oskolicina"] = Convert.ToInt32(DB.N20(RuntimeHelpers.GetObjectValue(current["KOLU"]))); row4["osstopa"] = 0; row4["ososnovica"] = 0; if (Convert.ToInt32(DB.N20(RuntimeHelpers.GetObjectValue(current["KOLU"]))) > 0) { row4["osduguje"] = decimal.Multiply(DB.N20(RuntimeHelpers.GetObjectValue(current["NABVRI"])), new decimal(Convert.ToInt32(DB.N20(RuntimeHelpers.GetObjectValue(current["KOLU"]))))); } else { row4["osduguje"] = DB.N20(RuntimeHelpers.GetObjectValue(current["NABVRI"])); } row4["ospotrazuje"] = 0; row4["osOPIS"] = "PS-Nabavna"; dataSet.OSTEMELJNICA.Rows.Add(row4); row4 = dataSet.OSTEMELJNICA.NewRow(); row4["invbroj"] = Conversions.ToInteger(current["SIFRA"]); row4["idosdokument"] = 2; row4["osbrojdokumenta"] = 0; row4["osdatumdok"] = time2; row4["oskolicina"] = Convert.ToInt32(DB.N20(RuntimeHelpers.GetObjectValue(current["KOLU"]))); row4["osstopa"] = 0; row4["ososnovica"] = 0; row4["osduguje"] = 0; if (Convert.ToInt32(DB.N20(RuntimeHelpers.GetObjectValue(current["KOLU"]))) > 0) { row4["ospotrazuje"] = decimal.Multiply(DB.N20(RuntimeHelpers.GetObjectValue(current["ISPVRI"])), new decimal(Convert.ToInt32(DB.N20(RuntimeHelpers.GetObjectValue(current["KOLU"]))))); } else { row4["ospotrazuje"] = DB.N20(RuntimeHelpers.GetObjectValue(current["ISPVRI"])); } row4["osOPIS"] = "PS-Ispravak"; dataSet.OSTEMELJNICA.Rows.Add(row4); num2++; try { adapter2.Update(dataSet); continue; } catch (System.Exception exception1) { throw exception1; //continue; } } } } finally { if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } MessageBox.Show("Importiranje OS/SI završeno!", "Import", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); adapter2.Fill(this.userControlDataGridOS.DataGrid.DataSet); } } } }
private void SetComboBoxColumnProperties(bool setColumnsWidth) { if (DataAdapterFactory.Provider == null) { DataAdapterFactory.Provider = new SimpleDataAdapterFactory(); } DataSet dataSet = new OSVRSTADataSet(); if (DataAdapterFactory.Provider != null) { DataAdapterFactory.GetOSVRSTADataAdapter().Fill(dataSet); } System.Data.DataView dataList = new System.Data.DataView(dataSet.Tables["OSVRSTA"]) { Sort = "OSV" }; CreateValueList(this.DataGrid, "OSVRSTAIDOSVRSTA", dataList, "IDOSVRSTA", "OSV"); UltraGridColumn column2 = this.DataGrid.DisplayLayout.Bands["OS"].Columns["IDOSVRSTA"]; column2.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; column2.ValueList = this.DataGrid.DisplayLayout.ValueLists["OSVRSTAIDOSVRSTA"]; if (setColumnsWidth) { column2.Width = 0x145; } DataSet set = new AMSKUPINEDataSet(); if (DataAdapterFactory.Provider != null) { DataAdapterFactory.GetAMSKUPINEDataAdapter().Fill(set); } System.Data.DataView view = new System.Data.DataView(set.Tables["AMSKUPINE"]) { Sort = "AM" }; CreateValueList(this.DataGrid, "AMSKUPINEIDAMSKUPINE", view, "IDAMSKUPINE", "AM"); UltraGridColumn column = this.DataGrid.DisplayLayout.Bands["OS"].Columns["IDAMSKUPINE"]; column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; column.ValueList = this.DataGrid.DisplayLayout.ValueLists["AMSKUPINEIDAMSKUPINE"]; if (setColumnsWidth) { column.Width = 370; } DataSet set3 = new OSDOKUMENTDataSet(); if (DataAdapterFactory.Provider != null) { DataAdapterFactory.GetOSDOKUMENTDataAdapter().Fill(set3); } System.Data.DataView view3 = new System.Data.DataView(set3.Tables["OSDOKUMENT"]) { Sort = "OSDK" }; CreateValueList(this.DataGrid, "OSDOKUMENTIDOSDOKUMENT", view3, "IDOSDOKUMENT", "OSDK"); UltraGridColumn column3 = this.DataGrid.DisplayLayout.Bands["OS_OSTEMELJNICA"].Columns["IDOSDOKUMENT"]; column3.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; column3.ValueList = this.DataGrid.DisplayLayout.ValueLists["OSDOKUMENTIDOSDOKUMENT"]; if (setColumnsWidth) { column3.Width = 370; } DataSet set4 = new LOKACIJEDataSet(); if (DataAdapterFactory.Provider != null) { DataAdapterFactory.GetLOKACIJEDataAdapter().Fill(set4); } System.Data.DataView view4 = new System.Data.DataView(set4.Tables["LOKACIJE"]) { Sort = "LOK" }; CreateValueList(this.DataGrid, "LOKACIJERASHODLOKACIJEIDLOKACIJE", view4, "IDLOKACIJE", "LOK"); UltraGridColumn column4 = this.DataGrid.DisplayLayout.Bands["OS_OSTEMELJNICA"].Columns["RASHODLOKACIJEIDLOKACIJE"]; column4.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; column4.ValueList = this.DataGrid.DisplayLayout.ValueLists["LOKACIJERASHODLOKACIJEIDLOKACIJE"]; if (setColumnsWidth) { column4.Width = 370; } }
public void DosImportHandler(object sender, EventArgs e) { AMSKUPINEDataSet dataSet = new AMSKUPINEDataSet(); AMSKUPINEDataAdapter adapter2 = new AMSKUPINEDataAdapter(); if (Interaction.MsgBox("Postojeće AM skupine biti će obrisane, želite li stvarno nastaviti???", MsgBoxStyle.YesNo, "Osnovna sredstva / SI") != MsgBoxResult.No) { IEnumerator enumerator = null; try { enumerator = this.userControlDataGridAMSKUPINE.DataGrid.DataSet.AMSKUPINE.Rows.GetEnumerator(); while (enumerator.MoveNext()) { ((DataRow)enumerator.Current).Delete(); } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } adapter2.Update(this.userControlDataGridAMSKUPINE.DataGrid.DataSet); OpenFileDialog dialog = new OpenFileDialog { InitialDirectory = @"c:\", Filter = "txt files (*.dbf)|*.dbf|All files (*.*)|*.*", FilterIndex = 2, RestoreDirectory = true }; if (dialog.ShowDialog() == DialogResult.OK) { string str4 = dialog.FileName.ToUpper().Replace(@"\OSM.DBF", ""); string prompt = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + str4 + ";Extended Properties=dBase IV;"; Interaction.MsgBox(prompt, MsgBoxStyle.OkOnly, null); OleDbConnection selectConnection = new OleDbConnection(prompt); OleDbDataAdapter adapter = new OleDbDataAdapter("select * from OSA ORDER BY SIFRA", selectConnection); DataSet set2 = new DataSet(); try { adapter.Fill(set2, "OSA"); if (Interaction.MsgBox("Broj pronađenih zapisa: " + Conversions.ToString(set2.Tables["OSA"].Rows.Count) + "\r\n\r\nŽelite li zadržati importirane zapise?", MsgBoxStyle.YesNo, null) == MsgBoxResult.No) { set2.RejectChanges(); } else { DataRow row3; IEnumerator enumerator2 = null; int num2 = 1; try { enumerator2 = set2.Tables["OSA"].Rows.GetEnumerator(); while (enumerator2.MoveNext()) { DataRow current = (DataRow)enumerator2.Current; if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["sifra"]))) { string str = string.Empty; decimal num = 0; if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["NAZIV"]))) { str = DB.Ko437to852(Conversions.ToString(current["NAZIV"])).Substring(0, DB.Ko437to852(Conversions.ToString(current["NAZIV"])).Length - 1); } else { str = "Nije bila upisana"; } if (Information.IsDBNull(RuntimeHelpers.GetObjectValue(current["stopa"]))) { num = new decimal(); } else { num = Conversions.ToDecimal(current["stopa"]); } str = Strings.Left(str, 0x31); row3 = dataSet.AMSKUPINE.NewRow(); row3["IDAMSKUPINE"] = num2; row3["kratkasifra"] = RuntimeHelpers.GetObjectValue(current["SIFRA"]); row3["OPISAMSKUPINE"] = str; row3["AMSKUPINASTOPA"] = num; row3["KTONABAVKEIDKONTO"] = "0"; row3["KTOISPRAVKAIDKONTO"] = "0"; row3["KTOIZVORAIDKONTO"] = "9"; dataSet.AMSKUPINE.Rows.Add(row3); try { adapter2.Update(dataSet); } catch (System.Exception exception1) { throw exception1; } } num2++; } } finally { if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } row3 = dataSet.AMSKUPINE.NewRow(); row3["IDAMSKUPINE"] = 0x270f; row3["OPISAMSKUPINE"] = "Nepostojeća skupina"; row3["AMSKUPINASTOPA"] = 0; row3["KTONABAVKEIDKONTO"] = "0"; row3["KTOISPRAVKAIDKONTO"] = "0"; row3["KTOIZVORAIDKONTO"] = "9"; dataSet.AMSKUPINE.Rows.Add(row3); try { adapter2.Update(dataSet); } catch (System.Exception exception4) { throw exception4; //System.Exception exception2 = exception4; //Interaction.MsgBox(exception2.Message, MsgBoxStyle.OkOnly, null); } MessageBox.Show("Importiranje skupina amortizacije završeno!", "Import", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); adapter2.Fill(this.userControlDataGridAMSKUPINE.DataGrid.DataSet); } } catch (System.Exception exception5) { throw exception5; //System.Exception exception3 = exception5; //Interaction.MsgBox("Greška prilikom prebacivanja podataka!" + exception3.Message, MsgBoxStyle.OkOnly, null); } } } }