Exemplo n.º 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);
        }
Exemplo n.º 2
0
 private void Reset_btn_Click(object sender, EventArgs e)
 {
     UserName_txt.Text = "";
     Password_txt.Text = "";
     UserName_txt.Select();
     //Set up the Reset button action
 }
Exemplo n.º 3
0
        /// <summary>
        /// Handles Load event for user data Insert/Update operations
        /// Loading user data for update user data and binding controls with selected user record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddUserMasterForm_Load(object sender, EventArgs e)
        {
            FormDatatableFromVo();

            ComboBind(Country_cmb, cntryLangDatatable, "countrycode", "LocaleId");

            ComboBind(FactoryCode_cmb, factoryDatatable, "code", "code");

            UserCode_txt.Select();

            if (string.Equals(mode, CommonConstants.MODE_UPDATE))
            {
                LoadUserData(updateData);
                UserCode_txt.Enabled = false;
                UserName_txt.Select();
            }
        }
        private void EditUserInformation_Load(object sender, EventArgs e)
        {
            UserName_txt.Select();
            DBConnect();
            showDataGrid();
            UserInfoGV.RowHeadersVisible     = false;
            this.UserInfoGV.Columns[0].Width = 80;
            this.UserInfoGV.Columns[1].Width = 80;
            this.UserInfoGV.Columns[2].Width = 80;
            this.UserInfoGV.Columns[3].Width = 80;
            this.UserInfoGV.Columns[4].Width = 80;
            this.UserInfoGV.Columns[5].Width = 80;
            this.UserInfoGV.Columns[6].Width = 80;
            UserInfoGV.ColumnHeadersDefaultCellStyle.Font = new Font("Tahoma", 7, FontStyle.Bold);

            this.Resize += new EventHandler(Form1_Resize);

            X = this.Width;
            Y = this.Height;


            setTag(this);
            Form1_Resize(new object(), new EventArgs());
        }
Exemplo n.º 5
0
 private void Reset_btn_Click(object sender, EventArgs e)
 {
     UserName_txt.Text = "";
     Password_txt.Text = "";
     UserName_txt.Select();
 }
Exemplo n.º 6
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();
                }
            }
        }
Exemplo n.º 7
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();
            }
        }