Пример #1
0
        /// <summary>
        /// Checks mandatory fields
        /// </summary>
        /// <returns></returns>
        private bool CheckMandatory()
        {
            if (UserCode_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, UserCode_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                UserCode_txt.Focus();

                return(false);
            }
            if (UserName_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, UserName_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                UserName_txt.Focus();

                return(false);
            }

            if (Password_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Password_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                Password_txt.Focus();

                return(false);
            }

            if (Country_cmb.Text == string.Empty || Country_cmb.SelectedIndex < 0)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Country_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                Country_cmb.Focus();

                return(false);
            }
            //if (Language_cmb.Text == string.Empty || Language_cmb.SelectedIndex < 0)
            //{
            //    messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Language_lbl.Text);
            //    popUpMessage.Warning(messageData, Text);

            //    Language_cmb.Focus();

            //    return false;
            //}
            if (FactoryCode_cmb.Text == string.Empty || FactoryCode_cmb.SelectedIndex < 0)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, FactoryCode_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                FactoryCode_cmb.Focus();

                return(false);
            }
            return(true);
        }
Пример #2
0
        /// <summary>
        /// update data to db
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            var sch = StringCheckHelper.GetInstance();

            if (CheckMandatory())
            {
                if (string.IsNullOrEmpty(UserCode_txt.Text) || string.IsNullOrEmpty(UserName_txt.Text))
                {
                    messageData = new MessageData("mmce00003", Properties.Resources.mmce00003);
                    logger.Info(messageData);
                    popUpMessage.ConfirmationOkCancel(messageData, Text);

                    if (string.IsNullOrEmpty(UserCode_txt.Text))
                    {
                        UserCode_txt.Focus();
                    }
                    else
                    {
                        UserName_txt.Focus();
                    }
                    return;
                }

                string multilogin = string.Empty;
                //string language = string.Empty;
                int country = 0;

                if (MultiLogin_chk.Checked)
                {
                    multilogin = "******";
                }
                if (Country_cmb.SelectedIndex > -1)
                {
                    country = Convert.ToInt32(Country_cmb.SelectedValue.ToString());
                }

                UserVo inVo = new UserVo
                {
                    UserCode = UserCode_txt.Text.Trim(),
                    UserName = UserName_txt.Text.Trim(),
                    // Language = language,
                    MultiLoginFlag = multilogin,
                    IpAddress      = UserData.GetUserData().IpAddress,
                    //RegistrationDateTime = DateTime.Now.ToString(),
                    RegistrationUserCode    = UserData.GetUserData().UserCode,
                    LocaleId                = country,
                    RegistrationFactoryCode = FactoryCode_cmb.SelectedValue.ToString()
                };
                if (string.Equals(mode, CommonConstants.MODE_ADD))
                {
                    UserVo checkVo = DuplicateCheck(inVo);

                    if (checkVo != null && checkVo.AffectedCount > 0)
                    {
                        messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, UserCode_lbl.Text + " : " + UserCode_txt.Text);
                        popUpMessage.ConfirmationOkCancel(messageData, Text);

                        return;
                    }
                }


                try
                {
                    if (string.Equals(mode, CommonConstants.MODE_ADD))
                    {
                        UserVo outVo = (UserVo)base.InvokeCbm(new AddUserMasterMntCbm(), inVo, false);
                        IntSuccess = outVo.AffectedCount;
                    }
                    else if (string.Equals(mode, CommonConstants.MODE_UPDATE))
                    {
                        UserVo outVo = (UserVo)base.InvokeCbm(new UpdateUserMasterMntCbm(), inVo, false);
                        IntSuccess = outVo.AffectedCount;
                    }
                }
                catch (Framework.ApplicationException exception)
                {
                    popUpMessage.ApplicationError(exception.GetMessageData(), Text);
                    logger.Error(exception.GetMessageData());
                    return;
                }

                if ((IntSuccess > 0) || (IntSuccess == 0))
                {
                    this.Close();
                }
            }
        }
Пример #3
0
        private void Accept_btn_Click(object sender, EventArgs e)
        {
            try
            {
                if (UserName_txt.Text == "")
                {
                    MessageBox.Show("Please enter your Username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UserName_txt.Focus();
                }
                else if (Password_txt.Text == "")
                {
                    MessageBox.Show("Please enter your Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Password_txt.Focus();
                }
                else if (UserName_txt.Text == "admin" && Password_txt.Text == "admin3092")
                {
                    role = "System Administrator";

                    MessageBox.Show("Welcome " + role, "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Main_Menu mainfrm = new Main_Menu();
                    this.Hide();
                    mainfrm.Show();

                    ((Form)mainfrm).Controls["User_txt"].Text     = role;
                    ((Form)mainfrm).Controls["Username_lbl"].Text = role;
                    ((Form)mainfrm).Controls["Password_lbl"].Text = Convert.ToString(DateTime.Now);


                    connection.Open();
                    OleDbCommand command = connection.CreateCommand();
                    command             = connection.CreateCommand();
                    command.CommandType = CommandType.Text;
                    command.CommandText = "insert into [System_Log_tbl] (Username,Login_DateTime) values ('" + role + "','" + DateTime.Now + "')";
                    command.ExecuteNonQuery();
                    connection.Close();
                }
                else
                {
                    string           query = "Select [Role] FROM [System_Users_tbl] WHERE Username = '******' and Password = '******'";
                    OleDbDataAdapter sda   = new OleDbDataAdapter(query, connection);
                    DataTable        dtbl  = new DataTable();
                    sda.Fill(dtbl);
                    role = dtbl.Rows[0][0].ToString();

                    if (role != "")
                    {
                        MessageBox.Show("Welcome " + role, "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Main_Menu mainfrm = new Main_Menu();
                        this.Hide();
                        mainfrm.Show();

                        ((Form)mainfrm).Controls["User_txt"].Text     = role;
                        ((Form)mainfrm).Controls["Username_lbl"].Text = UserName_txt.Text.Trim();
                        ((Form)mainfrm).Controls["Password_lbl"].Text = Convert.ToString(DateTime.Now);


                        connection.Open();
                        OleDbCommand command = connection.CreateCommand();
                        command.CommandType = CommandType.Text;
                        command.CommandText = "insert into [System_Log_tbl] (Username,Login_DateTime) values ('" + UserName_txt.Text.Trim() + "','" + DateTime.Now + "')";
                        command.ExecuteNonQuery();
                        connection.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username and/or Password is incorrect", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        UserName_txt.Text = "";
                        Password_txt.Text = "";
                        UserName_txt.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Database not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserName_txt.Text = "";
                Password_txt.Text = "";
                UserName_txt.Focus();
            }
        }