private void OpenFile(string fileName) { if (UIMessage.ShowMessage(CommonConst.OPEN_FILE_QUES, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = fileName; process.StartInfo.Verb = "Open"; process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; process.Start(); } catch { DevExpress.XtraEditors.XtraMessageBox.Show(this, "Cannot find an application on your system suitable for openning the file with exported data.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool SaveDataTable(DataTable dtTable, string[] tableName) { if (dtTable == null) { return(false); } if (dtTable.Rows.Count <= 0) { return(false); } bool isDuplicate = false; DataRow drOld = null; DataRow dr = null; DataTable dtSave = dtTable.Copy(); dtTable.RejectChanges(); try { if ((dtSave != null) && dtSave.Rows.Count > 0) { //foreach(DataRow dr in dtSave.Rows) for (int i = 0; i < dtSave.Rows.Count; i++) { foreach (string tblN in tableName) { dr = dtSave.Rows[i]; if (IsEmptyRow(dr, tblN)) { continue; } if (dr.RowState == DataRowState.Added) { //Check duplicate isDuplicate = IsDupplication(dr, dtSave, tblN); if (isDuplicate) { return(!isDuplicate); } //Insert new record MakeInsertNewQuery(dr, dtSave, tblN); EZLog(dr, dr, tblN); } else if (dr.RowState == DataRowState.Modified) { // Update existing record MakeUpdateQuery(dr, tblN); if (!isNoUpdate) { drOld = dtTable.Rows[i]; EZLog(drOld, dr, tblN); } } } } } if (!isDuplicate) { dtSave.AcceptChanges(); UIMessage.ShowMessage(Common.CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { // dtSave.RejectChanges(); throw (ex); } return(true); }