public static void EZLog(DataRow drOld, DataRow dr, string tblN, string ASSEMBLY_NAME, string formName, object userID) { string keysValue = string.Empty; string keysName = string.Empty; string strEmployeeID = string.Empty; if (dr.Table.Columns.Contains("EmployeeID")) { strEmployeeID = drOld["EmployeeID"].ToString(); } string columnName = string.Empty; try { if (tblN.Equals(string.Empty)) { keysValue = ""; } else { keysValue = GetKeyValue(drOld, tblN); } switch (dr.RowState) { case DataRowState.Deleted: //log delete data keysName = GetKeyName(tblN); EZLog("Delete", keysName, keysValue, "", tblN, ASSEMBLY_NAME, formName, userID, strEmployeeID); break; case DataRowState.Added: keysName = GetKeyName(tblN); EZLog("Add new", keysName, "", keysValue, tblN, ASSEMBLY_NAME, formName, userID, strEmployeeID); break; case DataRowState.Modified: for (int i = 0; i < dr.Table.Columns.Count; i++) { if (!(dr[i].ToString().Equals(drOld[i].ToString()))) { //Log modified columnName = UIMessage.Get_Message(dr.Table.Columns[i].Caption); keysName = String.Format("({0} , {1})", keysValue, columnName); EZLog("Modified", keysName, drOld[i].ToString(), dr[i].ToString(), tblN, ASSEMBLY_NAME, formName, userID, strEmployeeID); } } break; default: //log delete data keysName = GetKeyName(tblN); EZLog("Delete", keysName, keysValue, "", tblN, ASSEMBLY_NAME, formName, userID, strEmployeeID); break; } } catch (Exception ex) { throw ex; } }
private static void SetValidationToControl(ref Control ctr, DataRow dr) { try { if (ctr is DevExpress.XtraEditors.LookUpEdit) { DevExpress.XtraEditors.LookUpEdit led = ctr as DevExpress.XtraEditors.LookUpEdit; AddDataSource(ref led, UIMessage.DBEngine.execReturnDataTable(dr[CommonConst.Validation].ToString(), CommonConst.A_LoginID, UIMessage.userID)); } else { //Devexpress valiation rules string[] strSpl = dr[CommonConst.Validation].ToString().Split(':'); if (strSpl[0].Contains("ConditionValidationRule")) { ConditionValidationRule cvr = new ConditionValidationRule(); switch (strSpl[1]) { case "IsNotBlank": cvr.ConditionOperator = ConditionOperator.IsNotBlank; cvr.ErrorText = UIMessage.Get_Message(dr[CommonConst.ValidationMessID].ToString()); break; case "Between": cvr.ConditionOperator = ConditionOperator.Between; cvr.Value1 = Convert.ToInt64(strSpl[2]); cvr.Value2 = Convert.ToInt64(strSpl[3]); cvr.ErrorText = string.Format(UIMessage.Get_Message(dr[CommonConst.ValidationMessID].ToString()), cvr.Value1, cvr.Value2); break; case "Contains": cvr.ConditionOperator = ConditionOperator.Contains; cvr.Value1 = Convert.ToInt64(strSpl[2]); cvr.ErrorText = string.Format(UIMessage.Get_Message(dr[CommonConst.ValidationMessID].ToString()), cvr.Value1); break; case "NotAnyOf": cvr.ConditionOperator = ConditionOperator.NotAnyOf; cvr.Value1 = Convert.ToInt64(strSpl[2]); cvr.ErrorText = string.Format(UIMessage.Get_Message(dr[CommonConst.ValidationMessID].ToString()), cvr.Value1); break; } cvr.ErrorType = ErrorType.Default; dxValidationProvider1.SetValidationRule(ctr, cvr); dxValidationProvider1.ValidationMode = ValidationMode.Auto; } } } catch (Exception ex) { Helper.LogError(ex, ex.Message, "SetValidationToControl"); } }
private void EZLog(DataRow drOld, DataRow dr, string tblN) { string keysValue = string.Empty; string keysName = string.Empty; string columnName = string.Empty; string strEmployeeID = string.Empty; try { keysValue = GetKeyValue(drOld, tblN); if (dr.Table.Columns.Contains(CommonConst.EmployeeID)) { strEmployeeID = dr[CommonConst.EmployeeID].ToString(); } switch (dr.RowState) { case DataRowState.Deleted: //log delete data keysName = GetKeyName(tblN); EZLog("Delete", keysName, keysValue, "", tblN, strEmployeeID); break; case DataRowState.Added: keysName = GetKeyName(tblN); EZLog("Add new", keysName, "", keysValue, tblN, strEmployeeID); break; case DataRowState.Modified: for (int i = 0; i < dr.Table.Columns.Count; i++) { if (!(dr[i].ToString().Equals(drOld[i].ToString()))) { //Log modified columnName = UIMessage.Get_Message(dr.Table.Columns[i].Caption); keysName = String.Format("({0} , {1})", keysValue, columnName); EZLog("Modified", keysName, drOld[i].ToString(), dr[i].ToString(), tblN, strEmployeeID); } } break; default: //log delete data keysName = GetKeyName(tblN); EZLog("Delete", keysName, keysValue, "", tblN, strEmployeeID); break; } } catch (Exception ex) { throw ex; } }
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); } } }
// ======================================================= // NAME: ShowException // TASK: show information of an exception. // this function is used to unify the way we notify an error to user. // PARAM: - e is the exception shown // - strLocation is where the exception is thrown // - strOtherInformation is additional information to describe the error // RETURN: NA // THROW: // REV: // 2003-05-02 created by TRAN VIET HA // ======================================================= /// <summary> /// show information of an exception /// </summary> public static void ShowException(Exception e, string strLocation, string strOtherInformation) { System.Diagnostics.Trace.Assert(e != null); string str = e.Message; str += "\n\n" + e.StackTrace; if (strLocation != null) { str += "\n\nThis error is throwed from " + strLocation; } if (strOtherInformation != null) { str += "\n\n" + strOtherInformation; } UIMessage.Error(str); LogError(e, strLocation, strOtherInformation); }
public static void LoadControlsLayOut(ref System.Windows.Forms.SplitContainer ctrs, string formName) { int height = 0; const int width = 250; const int heightBox = 32; Control ctlParent = ctrs.Panel1; try { string ControlName = string.Empty; DataTable dt = UIMessage.DBEngine.execReturnDataTable(string.Format("select * from tblFormLayout where FormName = '{0}' and (IsLayout is null or IsLayout =0)", formName)); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { ControlName = dr["ControlName"].ToString(); if (ctlParent.Controls.Find(ControlName, true).Length <= 0) { DevExpress.XtraEditors.LabelControl lbl = new DevExpress.XtraEditors.LabelControl() { Name = string.Format("lbl{0}", ControlName), Text = UIMessage.Get_Message(string.Format("lbl{0}", ControlName)), Location = new Point(10, height) }; ctlParent.Controls.Add(lbl); switch (dr["SystemType"].ToString()) { case "ComboBox": DevExpress.XtraEditors.LookUpEdit led = new DevExpress.XtraEditors.LookUpEdit() { Name = string.Format("cbx{0}", ControlName), Location = new Point(130, height), Width = width, Height = heightBox }; ctlParent.Controls.Add(led); break; case "Datetime": case "Date": if (!ControlName.ToLower().Contains("time")) { DevExpress.XtraEditors.DateEdit dtp = new DevExpress.XtraEditors.DateEdit() { Name = string.Format("dtp{0}", ControlName), Location = new Point(130, height), Width = width, Height = heightBox }; ctlParent.Controls.Add(dtp); } else { DevExpress.XtraEditors.TimeEdit tid = new DevExpress.XtraEditors.TimeEdit() { Name = string.Format("tid{0}", ControlName), Location = new Point(130, height), Width = width, Height = heightBox }; ctlParent.Controls.Add(tid); } break; case "Time": DevExpress.XtraEditors.TimeEdit tid1 = new DevExpress.XtraEditors.TimeEdit() { Name = string.Format("tid{0}", ControlName), Location = new Point(130, height), Width = width, Height = heightBox }; ctlParent.Controls.Add(tid1); break; case "CheckEdit": DevExpress.XtraEditors.CheckEdit ckb = new DevExpress.XtraEditors.CheckEdit() { Name = string.Format("ckb{0}", ControlName), Location = new Point(130, height), Width = width, Height = heightBox }; ctlParent.Controls.Add(ckb); break; case "PictureEdit": DevExpress.XtraEditors.PictureEdit pic = new DevExpress.XtraEditors.PictureEdit() { Name = string.Format("ckb{0}", ControlName), Location = new Point(130, height), Width = width, Height = heightBox }; ctlParent.Controls.Add(pic); break; default: DevExpress.XtraEditors.TextEdit txt = new DevExpress.XtraEditors.TextEdit() { Name = string.Format("txt{0}", ControlName), Location = new Point(130, height), Width = width, Height = heightBox }; ctlParent.Controls.Add(txt); break; } height += 25; } } } } catch (Exception ex) { Helper.LogError(ex, ex.Message, "LoadControlsLayOut()"); } LoadDesignedControls(ctrs, formName); }
// ======================================================= // NAME: ShowMessage // TASK: show a message stored in resource // PARAM: resource name // RETURN: NA // THROW: // REV: // 2003-06-06 created by TRAN VIET HA // ======================================================= /// <summary> /// show a message stored in resource /// </summary> public static void ShowMessage(string strResourceContainer, string strResourceName) { UIMessage.Notify(GetString(strResourceContainer, strResourceName, System.Reflection.Assembly.GetCallingAssembly())); }
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); }