public static CommonBO GetCommonInfoByID(string id) { try { if (CommonInfo == null) { CommonBO _collection = new CommonBO(); var collection = MongoClientHelper.Current.ConnectDatabase().GetCollection <BsonDocument>("commoninfo"); var filterBuilder = Builders <BsonDocument> .Filter; var filter = filterBuilder.Eq("_id", id); var cursor = collection.Find(filter).FirstOrDefault(); if (cursor == null) { return(null); } _collection = BsonSerializer.Deserialize <CommonBO>(cursor); CommonInfo = _collection; return(_collection); } else { return(CommonInfo); } } catch (Exception ex) { throw ex; } }
//thong tin chung public ActionResult CommonInfo() { var commonInfo = LocationDAO.GetCommonInfoByID("commoninfo"); if (commonInfo == null) { commonInfo = new CommonBO(); } return(View(commonInfo)); }
public static bool UpdateCommonInfo(CommonBO updateModel, ref string errorMessage) { var collection = MongoClientHelper.Current.ConnectDatabase().GetCollection <CommonBO>("commoninfo"); var filterBuilder = Builders <CommonBO> .Filter; var filter = filterBuilder.Eq("id", updateModel.id); var result = collection.ReplaceOne(filter, updateModel); if (result.IsAcknowledged) { return(true); } return(false); }
/// <summary> /// GetDataByRoleID /// </summary> /// <param name="pintRoleID"></param> /// <param name="pstrSecurityTableName"></param> /// <returns></returns> /// <author>Trada</author> /// <date>Thursday, Nov 17 2005</date> public DataSet GetDataByRoleID(int pintRoleID, string pstrSecurityTableName, string pstrSourceTableName) { const string METHOD_NAME = THIS + ".GetDataByRoleID()"; DataSet dstPCS = new DataSet(); OleDbConnection oconPCS = null; OleDbCommand ocmdPCS = null; try { string strSql = String.Empty; CommonBO boCommon = new CommonBO(); strPKColumnName = boCommon.GetPKColumnName(pstrSecurityTableName); strFKColumnName = boCommon.GetFKColumnName(pstrSourceTableName, pstrSecurityTableName); strSql = "SELECT " + strPKColumnName + "," + sys_RolePartyTable.ROLEID_FLD + "," + strFKColumnName + " FROM " + pstrSecurityTableName + " WHERE " + sys_RolePartyTable.ROLEID_FLD + " = " + pintRoleID.ToString(); Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); ocmdPCS.Connection.Open(); OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS); odadPCS.Fill(dstPCS, pstrSecurityTableName); return(dstPCS); } catch (OleDbException ex) { throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex); } catch (Exception ex) { throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex); } finally { if (oconPCS != null) { if (oconPCS.State != ConnectionState.Closed) { oconPCS.Close(); } } } }
public ActionResult UpdateCommonInfo(CommonBO updateBO, FormCollection form) { string accName = form["accountname"]; string bankName = form["bankname"]; string accNumber = form["accountnumber"]; updateBO.bankinfo = new List <BankInfo>(); updateBO.bankinfo.Add(new BankInfo() { accountname = accName, accountnumber = accNumber, bankname = bankName }); if (ModelState.IsValid) { var updateModel = LocationDAO.GetCommonInfoByID(updateBO.id); if (updateModel == null || String.IsNullOrEmpty(updateModel.id)) { SetAlert($"Không tồn tại Common này!", "error"); return(View("CommonInfo", updateBO)); } updateModel.email = updateBO.email; updateModel.facebookchat = updateBO.facebookchat; updateModel.facebookpage = updateBO.facebookpage; updateModel.factoryaddress = updateBO.factoryaddress; updateModel.hotline = updateBO.hotline; updateModel.phone = updateBO.phone; updateModel.mapurl = updateBO.mapurl; updateModel.officeaddress = updateBO.officeaddress; updateModel.zalochat = updateBO.zalochat; updateModel.bankinfo = new List <BankInfo>(); updateModel.bankinfo.Add(new BankInfo() { accountname = accName, accountnumber = accNumber, bankname = bankName }); string errorMessage = ""; var result = LocationDAO.UpdateCommonInfo(updateModel, ref errorMessage); SetAlert($"Cập nhật thông tin chung thành công", "success"); return(RedirectToAction("CommonInfo")); } return(View("CommonInfo", updateBO)); }
/// <summary> /// This method uses to validate data on this form /// </summary> /// <returns></returns> /// <author> Son HT, Dec 13, 2004</author> private bool IsValidated() { const string METHOD_NAME = THIS + ".IsValidated()"; bool blnIsCorrect = true; try { CommonBO boCommon = new CommonBO(); //blnIsCorrect = boCommon.IsCorrectedPassword(strUserName,txtOldPassword.Text); } catch (PCSException ex) { // displays the error message. PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error); // log message. try { Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR); } catch { PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error); } } // if incorrect old password if (!blnIsCorrect) { PCSMessageBox.Show(ErrorCode.INVALID_PASSWORD, MessageBoxIcon.Error); txtOldPassword.Focus(); txtOldPassword.Select(0, txtOldPassword.Text.Length); return(false); } // if new password != confirm password if (txtNewPassword.Text != txtConfirmPassword.Text) { PCSMessageBox.Show(ErrorCode.NEWPASSWORD_DIFFERENT_CONFIRMPASSWORD, MessageBoxIcon.Error); txtNewPassword.Focus(); txtNewPassword.Select(0, txtNewPassword.Text.Length); return(false); } return(true); }
private Sys_UserVO CheckAuthenticate(Sys_UserVO pobjObjecVO) { CommonBO boCommon = new CommonBO(); try { Sys_UserVO sysUserVO = new Sys_UserVO(); object obj = (object)pobjObjecVO; sysUserVO = (Sys_UserVO)boCommon.CheckAuthenticate(obj); return(sysUserVO); } catch (PCSException ex) { throw ex; } catch (Exception ex1) { throw ex1; } }
/// <summary> /// Event for Ok click /// If user's information is correct then login system else then messages /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <Author> Tuan DM, Jan 10, 2005</Author> private void btnOk_Click(object sender, System.EventArgs e) { // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.WaitCursor; #endregion Code Inserted Automatically const string METHOD_NAME = THIS + "btnOk_Click()"; const string HOME_CURRENCY = "HomeCurrency"; const string EMPLOYEE_NAME = "EmployeeName"; const string MASTERLOCATIONCODE = "MasterLocationCode"; const string MASTERLOCATIONNAME = "MasterLocationName"; const string PCSMAIN = "PCSMain.Exe"; pObjobjecVO = new Sys_UserVO(); if (ValidateData()) { pObjobjecVO.UserName = txtUser.Text.Trim(); pObjobjecVO.Pwd = txtPwd.Text.Trim(); try { DataSet dstData = (new UtilsBO()).GetDefaultInfomation(); ErrorMessage.dsErrorMessage = dstData.Tables[Sys_Error_MsgTable.TABLE_NAME]; Sys_UserVO sysUserVO = new Sys_UserVO(); sysUserVO = CheckAuthenticate(pObjobjecVO); CommonBO boCommon = new CommonBO(); // HACK: Trada 14-12-2005 DataSet dstRoleAndParam = boCommon.ListRoleAndSysParam(sysUserVO.UserID, pObjobjecVO.UserName); //check if no-right assigned if (dstRoleAndParam.Tables[0].Rows.Count == 0) { PCSMessageBox.Show(ErrorCode.MESSAGE_NORIGHT_LOGIN, MessageBoxButtons.OK); txtUser.SelectionStart = 0; txtUser.SelectionLength = txtUser.Text.Length; txtUser.Focus(); // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.Default; #endregion Code Inserted Automatically return; } pObjobjecVO = new Sys_UserVO(); pObjobjecVO = sysUserVO; SystemProperty.ExecutablePath = Application.StartupPath; SystemProperty.UserID = pObjobjecVO.UserID; SystemProperty.UserName = pObjobjecVO.UserName; // Get the first Role SystemProperty.RoleID = int.Parse(dstRoleAndParam.Tables[0].Rows[0][Sys_RoleTable.ROLEID_FLD].ToString()); //Set SystemProperties DataRow drowMST_CCN = dstRoleAndParam.Tables[1].Rows[0]; SystemProperty.CCNID = int.Parse(drowMST_CCN[MST_CCNTable.CCNID_FLD].ToString()); SystemProperty.CCNCode = drowMST_CCN[MST_CCNTable.CODE_FLD].ToString(); SystemProperty.CCNDescription = drowMST_CCN[MST_CCNTable.DESCRIPTION_FLD].ToString(); if (drowMST_CCN[MST_CCNTable.CITYID_FLD].ToString() != string.Empty) { SystemProperty.CityID = int.Parse(drowMST_CCN[MST_CCNTable.CITYID_FLD].ToString()); } else { SystemProperty.CityID = 0; } SystemProperty.Code = drowMST_CCN[MST_CCNTable.CODE_FLD].ToString(); if (drowMST_CCN[MST_CCNTable.CITYID_FLD].ToString() != string.Empty) { SystemProperty.CountryID = int.Parse(drowMST_CCN[MST_CCNTable.COUNTRYID_FLD].ToString()); } else { SystemProperty.CountryID = 0; } if (drowMST_CCN[MST_CCNTable.DEFAULTCURRENCYID_FLD].ToString() != string.Empty) { SystemProperty.DefaultCurrencyID = int.Parse(drowMST_CCN[MST_CCNTable.DEFAULTCURRENCYID_FLD].ToString()); } SystemProperty.Description = drowMST_CCN[MST_CCNTable.DESCRIPTION_FLD].ToString(); SystemProperty.Email = drowMST_CCN[MST_CCNTable.EMAIL_FLD].ToString(); if (drowMST_CCN[MST_CCNTable.EXCHANGERATE_FLD].ToString() != string.Empty) { SystemProperty.ExchangeRate = float.Parse(drowMST_CCN[MST_CCNTable.EXCHANGERATE_FLD].ToString()); } else { SystemProperty.ExchangeRate = 0; } SystemProperty.ExchangeRateOperator = drowMST_CCN[MST_CCNTable.EXCHANGERATEOPERATOR_FLD].ToString(); SystemProperty.Fax = drowMST_CCN[MST_CCNTable.FAX_FLD].ToString(); if (drowMST_CCN[MST_CCNTable.HOMECURRENCYID_FLD].ToString() != string.Empty) { SystemProperty.HomeCurrencyID = int.Parse(drowMST_CCN[MST_CCNTable.HOMECURRENCYID_FLD].ToString()); } else { SystemProperty.HomeCurrencyID = 0; } SystemProperty.HomeCurrency = drowMST_CCN[HOME_CURRENCY].ToString(); SystemProperty.Name = drowMST_CCN[MST_CCNTable.NAME_FLD].ToString(); SystemProperty.Phone = drowMST_CCN[MST_CCNTable.PHONE_FLD].ToString(); SystemProperty.State = drowMST_CCN[MST_CCNTable.STATE_FLD].ToString(); SystemProperty.VAT = drowMST_CCN[MST_CCNTable.VAT_FLD].ToString(); SystemProperty.WebSite = drowMST_CCN[MST_CCNTable.WEBSITE_FLD].ToString(); SystemProperty.ZipCode = drowMST_CCN[MST_CCNTable.ZIPCODE_FLD].ToString(); if (drowMST_CCN[MST_EmployeeTable.EMPLOYEEID_FLD].ToString() != string.Empty) { SystemProperty.EmployeeID = int.Parse(drowMST_CCN[MST_EmployeeTable.EMPLOYEEID_FLD].ToString()); } else { SystemProperty.EmployeeID = 0; } SystemProperty.EmployeeName = drowMST_CCN[EMPLOYEE_NAME].ToString(); SystemProperty.MasterLocationID = int.Parse(drowMST_CCN[MST_MasterLocationTable.MASTERLOCATIONID_FLD].ToString()); SystemProperty.MasterLocationCode = drowMST_CCN[MASTERLOCATIONCODE].ToString(); SystemProperty.MasterLocationName = drowMST_CCN[MASTERLOCATIONNAME].ToString(); // HACK: dungla 10-21-2005 // get all system parameters NameValueCollection objParam = new NameValueCollection(); // put to Collection foreach (DataRow drowData in dstRoleAndParam.Tables[2].Rows) { objParam.Add(drowData[Sys_ParamTable.NAME_FLD].ToString().Trim(), drowData[Sys_ParamTable.VALUE_FLD].ToString().Trim()); } SystemProperty.SytemParams = objParam; // set the report logo file name SystemProperty.LogoFile = Application.StartupPath + @"\logo.jpg"; // END: dungla 10-21-2005 this.DialogResult = DialogResult.OK; // HACKED: 23/05/2006 Thachnn : Delete Temporary PCS Report File string mstrReportDefFolder = Application.StartupPath + "\\" + Constants.REPORT_DEFINITION_STORE_LOCATION; FormControlComponents.DeletePCSTempReportFile(mstrReportDefFolder); // ENDHACKED: 23/05/2006 Thachnn : Delete Temporary PCS Report File this.Close(); } catch (PCSException ex) { PCSMessageBox.Show(ex.mCode); try { Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR); } catch { PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION); } txtUser.SelectionStart = 0; txtUser.SelectionLength = txtUser.Text.Length; txtUser.Focus(); } catch (Exception ex) { PCSMessageBox.Show(ErrorCode.OTHER_ERROR); try { Logger.LogMessage(ex, METHOD_NAME, Level.ERROR); } catch { PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION); } } } // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.Default; #endregion Code Inserted Automatically }
/// <summary> /// Processing click event on OK button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <author> Son HT, Dec 13, 2004</author> private void btnOK_Click(object sender, System.EventArgs e) { // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.WaitCursor; #endregion Code Inserted Automatically const string METHOD_NAME = THIS + ".btnOK_Click()"; try { // check mandatory old password if (CheckMandatory(txtOldPassword)) { PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Error); txtOldPassword.Focus(); txtOldPassword.SelectAll(); // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.Default; #endregion Code Inserted Automatically return; } // check mandatory new password if (CheckMandatory(txtNewPassword)) { PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Error); txtNewPassword.Focus(); txtNewPassword.SelectAll(); // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.Default; #endregion Code Inserted Automatically return; } // check mandatory confirm password if (CheckMandatory(txtConfirmPassword)) { PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID, MessageBoxIcon.Error); txtConfirmPassword.Focus(); txtConfirmPassword.SelectAll(); // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.Default; #endregion Code Inserted Automatically return; } if (IsValidated()) { // Update password CommonBO boCommon = new CommonBO(); boCommon.UpdateNewPassword(strUserName, txtNewPassword.Text); PCSMessageBox.Show(ErrorCode.PASSWORD_UPDATE_SUCCESSFUL); Close(); } } catch (PCSException ex) { // Displays the error message if throwed from PCSException. PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error); try { // Log error message into log file. Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR); } catch { // Show message if logger has an error. PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error); } } catch (Exception ex) { // Displays the error message if throwed from system. PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error); try { // Log error message into log file. Logger.LogMessage(ex, METHOD_NAME, Level.ERROR); } catch { // Show message if logger has an error. PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error); } } // Code Inserted Automatically #region Code Inserted Automatically this.Cursor = Cursors.Default; #endregion Code Inserted Automatically }
/// <summary> /// Set all right for a user on form /// </summary> /// <Inputs> /// pForm : the form needs to set /// pstrUserName : contains UserName /// </Inputs> /// <Return> /// void /// </Return> /// <Authors> /// TuanDm /// </Authors> /// <History> /// Friday - January 13 - 2005 /// </History> public int SetRightForUserOnForm(Form pForm, string pstrUserName) { // SetButtonForRight_View(pForm); if (!pForm.Modal) { bool blnIsFound = false; #region Search form which assign security foreach (object t in SystemProperty.ArrayForms) { try { var objInforForm = (FormInfo)t; if (objInforForm.mForm == pForm) { blnIsFound = true; break; } } catch { } } #endregion if (!blnIsFound) { #region // if not found add to Array form to manage var list = (from obj in SystemProperty.TableMenuEntry where (obj.FormLoad == pForm.GetType().FullName&& obj.IsUserCreated == 0) orderby obj.Menu_EntryID ascending select obj).ToList(); FormInfo infoForm = list.Count > 0 ? new FormInfo(pForm, list[0].Prefix, list[0].TransFormat, list[0].TableName, list[0].TransNoFieldName, SystemProperty.UserName) : new FormInfo(pForm, string.Empty, string.Empty, string.Empty, string.Empty, SystemProperty.UserName); SystemProperty.ArrayForms.Add(infoForm); #endregion } } var boCommon = new CommonBO(); DataSet dstSecurity = boCommon.GetSecurityInfo(pstrUserName, pForm.GetType().FullName); int intFullPermission = int.Parse(dstSecurity.Tables[Sys_RightTable.TABLE_NAME].Rows[0][0].ToString()); #region // HACK: Added by Tuan TQ update code to manage super admin user if (pstrUserName.Equals(Constants.SUPER_ADMIN_USER)) { // HACK: SONHT HardCode DialogResult result = PCSMessageBox.Show(MessageCreateDataVisibility, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { var frmGroupControl = new GroupControls(pForm); frmGroupControl.Show(); if (pForm.Modal) { pForm.Show(); } } intFullPermission = FullPermission;// (2 exp 5) -1 } #endregion #region // if has no permission if (intFullPermission == 0) { int intCountExisted = int.Parse(dstSecurity.Tables[Sys_Menu_EntryTable.TABLE_NAME].Rows[0][0].ToString()); if (intCountExisted > 0) { return(intFullPermission); } intFullPermission = FullPermission;// (2 exp 5) -1 } #endregion // Set visible control DataTable dtbTable = dstSecurity.Tables[Sys_VisibilityGroup_RoleTable.TABLE_NAME]; // Set other property for form pForm.StartPosition = FormStartPosition.CenterScreen; pForm.KeyPreview = true; Control objControl = pForm; #region // Scan control on form to set default property while (true) { #region // Get next control objControl = pForm.GetNextControl(objControl, true); if (objControl == null) { break; } #endregion #region // Set OnEnter and OnLeave if (objControl.GetType().Equals(typeof(TextBox)) || objControl.GetType().Equals(typeof(ComboBox)) || objControl.GetType().Equals(typeof(C1Combo)) || objControl.GetType().Equals(typeof(C1DateEdit)) || objControl.GetType().Equals(typeof(C1TextBox)) || objControl.GetType().Equals(typeof(C1NumericEdit)) || objControl.GetType().Equals(typeof(NumericUpDown))) { objControl.Enter += FormControlComponents.OnEnterControl; objControl.Leave += FormControlComponents.OnLeaveControl; } if (objControl.GetType().Equals(typeof(Button))) { if (objControl.Name == "btnHelp" || objControl.Name == "HelpButton") { objControl.Click += FormControlComponents.OnHelpClick; } } #endregion if (objControl.GetType().Equals(typeof(TextBox))) { #region // If it's TextBox var txtBox = (TextBox)objControl; txtBox.TextAlign = HorizontalAlignment.Left; //HACK : TUANDM 18 - 10 - 2005 txtBox.Text = txtBox.Text.Trim(); if (txtBox.Text != string.Empty) { var btnSearch = (Button)FindButtonControlByName(pForm, txtBox.Text); if (btnSearch != null) { txtBox.Validating += FormControlComponents.ControlValidating; txtBox.Text = string.Empty; } } #endregion //END: TUANDM 18 - 10 - 2005 } else if (objControl.GetType().Equals(typeof(C1TextBox))) { #region C1TextBox var txtC1Text = (C1TextBox)objControl; txtC1Text.TextAlign = HorizontalAlignment.Left; //HACK : TUANDM 18 - 10 - 2005 txtC1Text.Value = txtC1Text.Value.ToString().Trim(); if (txtC1Text.Value.ToString() != string.Empty) { var btnSearch = (Button)FindButtonControlByName(pForm, txtC1Text.Value.ToString()); if (btnSearch != null) { txtC1Text.Validating += FormControlComponents.ControlValidating; txtC1Text.Value = string.Empty; } } #endregion } else if (objControl.GetType().Equals(typeof(C1DateEdit))) { var dtmC1Date = (C1DateEdit)objControl; dtmC1Date.Validated += FormControlComponents.C1DateEdit_Validated; dtmC1Date.TextAlign = HorizontalAlignment.Center; dtmC1Date.AcceptsEscape = false; #region // Set default dd-MM-yyyy format if (dtmC1Date.CustomFormat.Trim().Length == 0) { dtmC1Date.CustomFormat = Constants.DATETIME_FORMAT; dtmC1Date.FormatType = FormatTypeEnum.CustomFormat; } string strMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_INPUT_VALUE); strMsg = strMsg.Replace(Chara, string.Empty); string strSecondMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_OR_MSG); // if it has no Intervals if (dtmC1Date.PostValidation.Intervals.Count == 0) { continue; } strMsg = dtmC1Date.PostValidation.Intervals.Cast <ValueInterval>().Aggregate(strMsg, (current, vlInterval) => current + (Constants.OPEN_SBRACKET + vlInterval.MinValue + Constants.COMMA + Constants.WHITE_SPACE + vlInterval.MaxValue + Constants.CLOSE_SBRACKET + Constants.WHITE_SPACE + strSecondMsg + Constants.WHITE_SPACE)); strMsg = strMsg.Substring(0, strMsg.Length - strSecondMsg.Length - 1); dtmC1Date.ErrorInfo.ShowErrorMessage = true; dtmC1Date.ErrorInfo.ErrorMessageCaption = Constants.APPLICATION_NAME; dtmC1Date.ErrorInfo.ErrorMessage = strMsg; dtmC1Date.ErrorInfo.CanLoseFocus = false; #endregion } else if (objControl.GetType().Equals(typeof(C1NumericEdit))) { #region // if it is C1NumericEdit var dtmC1Num = (C1NumericEdit)objControl; dtmC1Num.TextAlign = HorizontalAlignment.Right; dtmC1Num.AcceptsEscape = false; // Set default number format if (dtmC1Num.CustomFormat.Trim().Length == 0) { dtmC1Num.CustomFormat = Constants.DECIMAL_NUMBERFORMAT; dtmC1Num.FormatType = FormatTypeEnum.CustomFormat; } string strMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_INPUT_VALUE); strMsg = strMsg.Replace(Chara, string.Empty); string strSecondMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_OR_MSG); // if it has no Intervals if (dtmC1Num.PostValidation.Intervals.Count == 0) { continue; } strMsg = dtmC1Num.PostValidation.Intervals.Cast <ValueInterval>().Aggregate(strMsg, (current, vlInterval) => current + (Constants.OPEN_SBRACKET + vlInterval.MinValue + Constants.COMMA + Constants.WHITE_SPACE + vlInterval.MaxValue + Constants.CLOSE_SBRACKET + Constants.WHITE_SPACE + strSecondMsg + Constants.WHITE_SPACE)); strMsg = strMsg.Substring(0, strMsg.Length - strSecondMsg.Length - 1); dtmC1Num.ErrorInfo.ShowErrorMessage = true; dtmC1Num.ErrorInfo.ErrorMessageCaption = Constants.APPLICATION_NAME; dtmC1Num.ErrorInfo.ErrorMessage = strMsg; dtmC1Num.ErrorInfo.CanLoseFocus = false; #endregion } else if (objControl.GetType().Equals(typeof(C1Combo))) { #region // if it is C1Combo var cboC1 = (C1Combo)objControl; cboC1.DropDownWidth = Constants.DEFAULT_C1COMBO_DROPDOWNWIDTH; cboC1.KeyDown += FormControlComponents.C1Combo_KeyDown; cboC1.ComboStyle = ComboStyleEnum.DropdownList; // Enable cboCCN control if (cboC1.Name == Cboccn) { cboC1.Enabled = true; cboC1.EnabledChanged += EnabledChanged; } #endregion } else if (objControl.GetType().Equals(typeof(C1TrueDBGrid))) { #region // if is C1TrueDBGrid control var grid = (C1TrueDBGrid)objControl; grid.RowHeight = Constants.DEFAULT_ROW_HEIGHT; grid.MarqueeStyle = MarqueeEnum.HighlightCell; grid.HighLightRowStyle.BackColor = Color.FromArgb(Constants.BACKGROUND_COLOUR_R, Constants.BACKGROUND_COLOUR_G, Constants.BACKGROUND_COLOUR_B); grid.HighLightRowStyle.ForeColor = Color.FromArgb(Constants.FORE_COLOUR_R, Constants.FORE_COLOUR_R, Constants.FORE_COLOUR_R); grid.Style.VerticalAlignment = AlignVertEnum.Center; if (grid.Splits.Count > 0) { // Set default alignment foreach (C1DisplayColumn c1Column in grid.Splits[0].DisplayColumns) { c1Column.HeadingStyle.HorizontalAlignment = AlignHorzEnum.Center; } } // Not allow user change column order grid.AllowColMove = false; grid.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; // Set Maximize and Resize pForm.MaximizeBox = true; pForm.FormBorderStyle = FormBorderStyle.Sizable; #endregion } } #endregion if (!pstrUserName.Equals(Constants.SUPER_ADMIN_USER)) { #region // Scan data from datatable to set visible control if (dtbTable != null) { foreach (DataRow drowData in dtbTable.Rows) { Control objCon = pForm.GetNextControl(pForm, true); while (objCon != null) { // if is C1TrueDBGrid control if (objCon.GetType().Equals(typeof(C1TrueDBGrid))) { var grid = (C1TrueDBGrid)objCon; foreach (C1DisplayColumn objCol in grid.Splits[0].DisplayColumns) { // do not process if col is invisible if (!objCol.Visible) { objCol.AllowSizing = objCol.Visible = false; continue; } if ((objCol.DataColumn.DataField == drowData[Sys_HiddenControlsTable.CONTROLNAME_FLD].ToString().Trim()) && (drowData[Sys_VisibilityItemTable.TYPE_FLD].ToString() == VisibilityItemTypeEnum.ColumnTrueDBGrid.GetHashCode().ToString())) { objCol.AllowSizing = objCol.Visible = false; } } } // If control is C1TabControl else if (objCon.GetType().Equals(typeof(C1DockingTab))) { var c1DockingTab = (C1DockingTab)objCon; for (int k = 0; k < c1DockingTab.TabCount; k++) { if (c1DockingTab.TabPages[k].Name == drowData[Sys_HiddenControlsTable.CONTROLNAME_FLD].ToString().Trim()) { c1DockingTab.TabPages[k].TabVisible = false; } } } // set visible if it is normal control else if (objCon.Name == drowData[Sys_HiddenControlsTable.CONTROLNAME_FLD].ToString().Trim()) { objCon.Visible = false; } // Get next control objCon = pForm.GetNextControl(objCon, true); } } } #endregion } // return full permission return(intFullPermission); }
/// <summary> /// UpdateSecurityTable /// </summary> /// <param name="pdstSecurityTable"></param> /// <param name="pstrSecurityTableName"></param> /// <author>Trada</author> /// <date>Friday, Nov 18 2005</date> public void UpdateSecurityTable(DataSet pdstSecurityTable, string pstrSecurityTableName, string pstrSourceTableName) { const string METHOD_NAME = THIS + ".UpdateSecurityTable()"; string strSql; OleDbConnection oconPCS = null; OleDbCommandBuilder odcbPCS; OleDbDataAdapter odadPCS = new OleDbDataAdapter(); try { CommonBO boCommon = new CommonBO(); //strPKColumnName = boCommon.GetPKColumnName(pstrSecurityTableName); //strFKColumnName = boCommon.GetFKColumnName(pstrSourceTableName, pstrSecurityTableName); const string FKTABLE_NAME = "FKTABLE_NAME"; const string FKCOLUMN_NAME = "FKCOLUMN_NAME"; const string PKCOLUMN_NAME = "COLUMN_NAME"; // HACK: Trada 12-12-2005 Get FK Column Name DataTable dtbFKTable = GetFKColumnName(pstrSourceTableName); foreach (DataRow drow in dtbFKTable.Rows) { if (drow[FKTABLE_NAME].ToString() == pstrSecurityTableName) { strFKColumnName = drow[FKCOLUMN_NAME].ToString(); } } // END: Trada 12-12-2005 dtbFKTable = GetPKColumnName(pstrSecurityTableName); if (dtbFKTable.Rows.Count == 0) { strPKColumnName = string.Empty; } else { strPKColumnName = dtbFKTable.Rows[0][PKCOLUMN_NAME].ToString(); } strSql = "SELECT " + strPKColumnName + "," + sys_RolePartyTable.ROLEID_FLD + "," + strFKColumnName + " FROM " + pstrSecurityTableName; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS); odcbPCS = new OleDbCommandBuilder(odadPCS); pdstSecurityTable.EnforceConstraints = false; odadPCS.Update(pdstSecurityTable, pstrSecurityTableName); } catch (OleDbException ex) { if (ex.Errors.Count > 1) { if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE) { throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex); } else if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE) { throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex); } } else { throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex); } } catch (InvalidOperationException ex) { throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex); } catch (Exception ex) { throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex); } finally { if (oconPCS != null) { if (oconPCS.State != ConnectionState.Closed) { oconPCS.Close(); } } } }