private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { string stmtUpdate = string.Empty; string stmtInsert = string.Empty; BYamaya mBYamaya = new BYamaya(); switch (mModule) { case BYamaya.TAB_KEY_AREA: stmtUpdate = YamayaStmt.UPD_AREA_DATA; stmtInsert = YamayaStmt.INS_AREA_DATA; break; case BYamaya.TAB_KEY_CATEGORY: stmtUpdate = YamayaStmt.UPD_CATEGROY_DATA; stmtInsert = YamayaStmt.INS_CATEGORY_DATA; break; case BYamaya.TAB_KEY_ITEM: stmtUpdate = YamayaStmt.UPD_ITEM_DATA; stmtInsert = YamayaStmt.INS_ITEM_DATA; break; case BYamaya.TAB_KEY_ITEM_DESC: stmtUpdate = YamayaStmt.UPD_ITEMDESC_DATA; stmtInsert = YamayaStmt.INS_ITEMDESC_DATA; break; } iConn = new OracleConnection(mDBConnection); iConn.Open(); iTran = iConn.BeginTransaction(); int columnLength = mDataTable.Columns.Count; string stmt = string.Empty; mRowCount = mDataTable.Rows.Count; if (mRowCount == 0) return; string[] value = new string[columnLength]; for (int a = 1; a < mRowCount; a++) { if (backgroundWorker1.CancellationPending == true) { e.Cancel = true; return; } DataRow row = mDataTable.Rows[a]; for (int b = 0; b < value.Length; b++) { string temp = string.Empty; string actual = string.Empty; if (b == 0) { temp = row[b].ToString(); //if (temp.Length == 1) // actual = string.Empty; //else // actual = temp.Substring(1, (temp.Length - 1)); if (temp.Length == 0) actual = string.Empty; else actual = temp; } else if (b == (value.Length - 1)) { temp = row[b].ToString(); //if (temp.Length == 1) // actual = string.Empty; //else // actual = temp.Substring(0, (temp.Length - 1)); if (temp.Length == 0) actual = string.Empty; else actual = temp; } else { actual = row[b].ToString(); } value[b] = actual.Trim().Replace("'", "''"); ; } stmt = string.Format(stmtUpdate, value); int i = mBYamaya.executeNonQuery(iTran, CommandType.Text, stmt, (IDbDataParameter[])null); if (i == 0) { stmt = string.Format(stmtInsert, value); mBYamaya.executeNonQuery(iTran, CommandType.Text, stmt, (IDbDataParameter[])null); } //System.Threading.Thread.Sleep(100); backgroundWorker1.ReportProgress(a); } switch (mModule) { case BYamaya.TAB_KEY_AREA: mBYamaya.UpdateAreaMapping(iTran); break; case BYamaya.TAB_KEY_CATEGORY: mBYamaya.UpdateCategoryMapping(iTran); break; case BYamaya.TAB_KEY_ITEM: mBYamaya.UpdateItemMapping(iTran); break; case BYamaya.TAB_KEY_ITEM_DESC: mBYamaya.UpdateItemDescMapping(iTran); break; } }
private void tsbtnSave_Click(object sender, EventArgs e) { try { focusTabUpdate(); BYamaya mBYamaya = new BYamaya(); mBYamaya.saveRecords(setSaveDataTableValue(), mConnString); if (dtArea != null) { dtArea.AcceptChanges(); gridEXArea.Refetch(); } if (dtStore != null) { dtStore.AcceptChanges(); gridEXStore.Refetch(); } if (dtCategory != null) { dtCategory.AcceptChanges(); gridEXCategory.Refetch(); } if (dtItem != null) { dtItem.AcceptChanges(); gridEXItem.Refetch(); } if (dtItemDesc != null) { dtItemDesc.AcceptChanges(); gridEXItemDesc.Refetch(); } tsbtnSave.Enabled = false; tsbtnCancel.Enabled = false; tsbtnUpload.Enabled = true; tsbtnRefresh.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } }
private void uiTab1_SelectedTabChanged(object sender, Janus.Windows.UI.Tab.TabEventArgs e) { try { if (tsbtnSave.Enabled == false) { if (e.Page.Key == TAB_KEY_STORE) { tsbtnUpload.Enabled = false; } else { tsbtnUpload.Enabled = true; } } BYamaya mBYamaya = new BYamaya(); switch (e.Page.Key) { case TAB_KEY_AREA: if (dtArea == null || dtArea.GetChanges() == null) { refreshGrid(gridEXArea, dtArea = mBYamaya.getAreaDT(mConnString)); } break; case TAB_KEY_CATEGORY: if (dtCategory == null || dtCategory.GetChanges() == null) { refreshGrid(gridEXCategory, dtCategory = mBYamaya.getCategoryDT(mConnString)); } break; case TAB_KEY_STORE: if (dtStore == null || dtStore.GetChanges() == null) { refreshGrid(gridEXStore, dtStore = mBYamaya.getStoreDT(mConnString)); } break; case TAB_KEY_ITEM: if (dtItem == null || dtItem.GetChanges() == null) { refreshGrid(gridEXItem, dtItem = mBYamaya.getItemDT(mConnString)); } break; case TAB_KEY_ITEM_DESC: if (dtItemDesc == null || dtItemDesc.GetChanges() == null) { refreshGrid(gridEXItemDesc, dtItemDesc = mBYamaya.getItemDescDT(mConnString)); } break; default: break; } } catch (Exception ex) { tsbtnUpload.Enabled = false; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } }
private void refreshScreen(string module) { BYamaya mBYamaya = new BYamaya(); switch (module) { case TAB_KEY_AREA: if (dtArea == null || dtArea.GetChanges() == null) { refreshGrid(gridEXArea, dtArea = mBYamaya.getAreaDT(mConnString)); //if (!ds.Tables.Contains(TAB_KEY_AREA)) // ds.Tables.Add(dtArea); } break; case TAB_KEY_CATEGORY: if (dtCategory == null || dtCategory.GetChanges() == null) { refreshGrid(gridEXCategory, dtCategory = mBYamaya.getCategoryDT(mConnString)); //if (!ds.Tables.Contains(TAB_KEY_CATEGORY)) // ds.Tables.Add(dtCategory); } break; case TAB_KEY_STORE: if (dtStore == null || dtStore.GetChanges() == null) { refreshGrid(gridEXStore, dtStore = mBYamaya.getStoreDT(mConnString)); //if (!ds.Tables.Contains(TAB_KEY_STORE)) // ds.Tables.Add(dtStore); } break; case TAB_KEY_ITEM: if (dtItem == null || dtItem.GetChanges() == null) { refreshGrid(gridEXItem, dtItem = mBYamaya.getItemDT(mConnString)); //if (!ds.Tables.Contains(TAB_KEY_ITEM)) // ds.Tables.Add(dtItem); } break; case TAB_KEY_ITEM_DESC: if (dtItemDesc == null || dtItemDesc.GetChanges() == null) { refreshGrid(gridEXItemDesc, dtItemDesc = mBYamaya.getItemDescDT(mConnString)); //if (!ds.Tables.Contains(TAB_KEY_ITEM_DESC)) // ds.Tables.Add(dtItemDesc); } break; default: break; } }