Beispiel #1
0
        /// <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
        }