Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         TxtUserId.Focus();
     }
 }
Ejemplo n.º 2
0
 private void TxtDivision_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         TxtUserId.Focus();
     }
 }
Ejemplo n.º 3
0
 protected void ClearScr()
 {
     TxtUserId.Text          = string.Empty;
     TxtCurrentPassword.Text = string.Empty;
     TxtNewpassword.Text     = string.Empty;
     TxtConfirmPwd.Text      = string.Empty;
     TxtUserId.Focus();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["UserName"] == null)
            {
                Response.Redirect("FrmLogin.aspx");
            }
        }

        TxtUserId.Focus();
    }
Ejemplo n.º 5
0
 protected void BtnNew_Click(object sender, EventArgs e)
 {
     try
     {
         ClearAll();
         TxtUserId.Focus();
     }
     catch (Exception ex)
     {
         Response.Write(ex.ToString());
     }
 }
Ejemplo n.º 6
0
 private void Window_Initialized(object sender, EventArgs e)
 {
     TxtUserId.Focus();
 }
Ejemplo n.º 7
0
 private void FrmLogin_Load(object sender, EventArgs e)
 {
     TxtUserId.Focus();
     this.Activate();    // 실행했을때 포커스를 잡아주고 바로 키보드 입력가능하게 만들어줌.
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Name:Login
 /// Description:Only set Focus on textbox and set submit button as default button.
 /// Author:Monal shah
 /// Created Date:2010/10/28
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Form.DefaultButton = BtnSubmit.UniqueID;
     TxtUserId.Focus();
 }
Ejemplo n.º 9
0
        private void LoginProcess()
        {
            if (string.IsNullOrEmpty(TxtUserId.Text) || string.IsNullOrEmpty(TxtPassword.Text))
            // if (TxtUserId.Text == "" || TxtUserId.Text == null || TxtPassword.Text == null || TxtPassword.Text == "")
            {
                MetroMessageBox.Show(this, "아이디, 패스워드를 입력하세요", "로그인", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtUserId.Focus();
                return;
            }

            // 실제 DB처리
            string resultId = string.Empty;

            try
            {
                using (MySqlConnection conn = new MySqlConnection(Commons.CONNSTR))
                {
                    conn.Open();
                    // MetroMessageBox.Show(this, "DB접속성공");
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.Connection  = conn;
                    cmd.CommandText = "SELECT userID FROM userTBL " +
                                      " WHERE userID = @userID " +
                                      "   AND password = @password ";   // 띄어쓰기, 줄을 맞춰주지않으면 syntax에러발생

                    MySqlParameter paramUserId = new MySqlParameter("@userID", MySqlDbType.VarChar, 12);
                    paramUserId.Value = TxtUserId.Text.Trim();
                    MySqlParameter paramPassword = new MySqlParameter("@password", MySqlDbType.VarChar);

                    var md5Hash        = MD5.Create();
                    var cryptoPassword = Commons.GetMd5Hash(md5Hash, TxtPassword.Text.Trim());
                    //MD5는 단방향
                    paramPassword.Value = cryptoPassword;

                    cmd.Parameters.Add(paramUserId);
                    cmd.Parameters.Add(paramPassword);

                    MySqlDataReader reader = cmd.ExecuteReader();
                    reader.Read();

                    if (!reader.HasRows)
                    {
                        MetroMessageBox.Show(this, "아이디, 패스워드를 정확하게 입력하세요", "로그인실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TxtUserId.Text = TxtPassword.Text = string.Empty;
                        TxtUserId.Focus();
                        return;
                    }
                    else
                    {
                        resultId       = reader["userID"] != null ? reader["userID"].ToString() : string.Empty;
                        Commons.USERID = resultId; //200720 12:30추가
                        MetroMessageBox.Show(this, $"{resultId} 로그인성공");
                    }
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, $"DB접속에러 : {ex.Message}", "로그인 에러", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrEmpty(resultId))
            {
                MetroMessageBox.Show(this, "아이디, 패스워드를 정확하게 입력하세요", "로그인실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtUserId.Text = TxtPassword.Text = string.Empty;
                TxtUserId.Focus();
                return;
            }
            else
            {
                this.Close();
            }
        }
Ejemplo n.º 10
0
 private void FrmUsuarios_Load(object sender, EventArgs e)
 {
     TxtUserId.Focus();
 }
Ejemplo n.º 11
0
        private async Task LoginProcess()
        {
            // ID, Password 빈칸일경우 재입력 요청
            if (string.IsNullOrEmpty(TxtUserId.Text) || string.IsNullOrEmpty(TxtUserPwd.Text))
            {
                MetroMessageBox.Show(this, "ID, Password를 입력해주세요.",
                                     "Login",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Information);
                TxtUserId.Focus();
                return;
            }

            // DB에 연결하여 로그인정보 확인
            try
            {
                using (MySqlConnection connection = new MySqlConnection(Commons.CONNSTR))
                {
                    await connection.OpenAsync();

                    //MetroMessageBox.Show(this, "DB Connection OK.");

                    MySqlCommand command = new MySqlCommand()
                    {
                        Connection = connection
                    };
                    command.CommandText = @"SELECT userID FROM usertbl
                                            WHERE userID = @userID
                                            AND password = @password";


                    MySqlParameter userId = new MySqlParameter("@userID", MySqlDbType.VarChar, TxtUserId.Text.Length);
                    userId.Value = TxtUserId.Text.Trim();
                    command.Parameters.Add(userId);

                    MySqlParameter userPwd = new MySqlParameter("@password", MySqlDbType.VarChar, TxtUserPwd.Text.Length);
                    userPwd.Value = TxtUserPwd.Text.Trim();
                    command.Parameters.Add(userPwd);

                    MySqlDataReader reader = await Task.Run(() => command.ExecuteReader());

                    await reader.ReadAsync();

                    string resultId = reader["userID"]?.ToString();

                    if (reader.HasRows == false || string.IsNullOrEmpty(resultId))
                    {
                        MetroMessageBox.Show(this, "ID / Password check again", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TxtUserId.Clear();
                        TxtUserPwd.Clear();
                        TxtUserId.Focus();
                        return;
                    }
                    else
                    {
                        MetroMessageBox.Show(this, $"{resultId} Login");
                        this.Owner.Focus();
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, $"DB Connection Error: {ex.Message}",
                                     "Login Error",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                return;
            }
        }
Ejemplo n.º 12
0
 private void FrmLogin_Activated(object sender, EventArgs e)
 {
     TxtUserId.Focus();
 }
Ejemplo n.º 13
0
        private void ViewMode()
        {
            switch (_pMode)
            {
            case "ADD":
                grButton1.Enabled     = false;
                dataGridView1.Enabled = false;
                this.Height           = 440;
                DesFor.ColorChange(ref btnAdd);
                #region "Load Text Box Clear"
                TxtUserId.Text            = "";
                txtBranchID.Text          = "";
                lblNameBranch.Text        = "";
                TxtStaffId.Text           = "";
                TxtUserName.Text          = "";
                dExpiredDate.Text         = "";
                chkUsingCheck.Checked     = true;
                chkChangePWDLogon.Checked = true;
                TxtUserId.Enabled         = true;
                TxtStaffId.Enabled        = false;
                txtBranchID.Enabled       = true;
                #endregion
                TxtUserId.Focus();
                DesFor.AlignCenterToScreen();
                break;

            case "FIND":
                grButton1.Enabled     = false;
                dataGridView1.Enabled = false;
                this.Height           = 440;
                DesFor.ColorChange(ref btnFind);
                #region "Load Text Box Clear"
                TxtUserId.Text            = "";
                txtBranchID.Text          = "";
                lblNameBranch.Text        = "";
                TxtStaffId.Text           = "";
                TxtUserName.Text          = "";
                dExpiredDate.Text         = "";
                chkUsingCheck.Checked     = true;
                chkChangePWDLogon.Checked = false;
                TxtUserId.Enabled         = true;
                TxtStaffId.Enabled        = true;
                txtBranchID.Enabled       = true;
                #endregion
                TxtUserId.Focus();
                DesFor.AlignCenterToScreen();
                break;

            case "EDIT":
                grButton1.Enabled     = false;
                dataGridView1.Enabled = false;
                this.Height           = 440;
                DesFor.ColorChange(ref btnEdit);
                #region "Load Text Box"
                TxtUserId.Text            = dataGridView1.CurrentRow.Cells["CODE"].Value.ToString();
                txtBranchID.Text          = dataGridView1.CurrentRow.Cells["MA_DVI"].Value.ToString();
                lblNameBranch.Text        = dataGridView1.CurrentRow.Cells["TEN_DVI"].Value.ToString();
                TxtStaffId.Text           = dataGridView1.CurrentRow.Cells["MA_NHAN_VIEN"].Value.ToString();
                TxtUserName.Text          = dataGridView1.CurrentRow.Cells["TEN_NHAN_VIEN"].Value.ToString();
                dExpiredDate.Text         = dataGridView1.CurrentRow.Cells["NGAY_HET_HAN"].Value.ToString();
                chkUsingCheck.Checked     = dataGridView1.CurrentRow.Cells["SDUNG"].Value.ToString() == "C" ? true : false;
                chkChangePWDLogon.Checked = dataGridView1.CurrentRow.Cells["CHECK_PASS"].Value.ToString() == "Y" ? true : false;
                TxtUserId.Enabled         = false;
                TxtStaffId.Enabled        = false;
                txtBranchID.Enabled       = false;
                #endregion
                TxtUserName.Focus();
                DesFor.AlignCenterToScreen();
                break;

            case "":
                grButton1.Enabled     = true;
                dataGridView1.Enabled = true;
                #region "Load Text Box Clear"
                TxtUserId.Text            = "";
                txtBranchID.Text          = "";
                lblNameBranch.Text        = "";
                TxtStaffId.Text           = "";
                TxtUserName.Text          = "";
                dExpiredDate.Text         = "";
                chkUsingCheck.Checked     = false;
                chkChangePWDLogon.Checked = false;
                TxtUserId.Enabled         = true;
                TxtStaffId.Enabled        = true;
                txtBranchID.Enabled       = true;
                #endregion
                this.Height = 336;
                DesFor.AlignCenterToScreen();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 14
0
 private void FrmLogin_Load(object sender, EventArgs e)
 {
     // 폼 활성화, 포커스 제공
     this.Activate();
     TxtUserId.Focus();
 }
Ejemplo n.º 15
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (TxtUserId.Text.Length == 0)
            {
                // LblMsg.Text = "User Id Is Blank, Enter Valid User Id....";
                TxtUserId.Focus();
                return;
            }

            if (TxtUserName.Text.Length == 0)
            {
                // LblMsg.Text = "User Name Is Blank, Enter Valid User Name....";
                TxtUserName.Focus();
                return;
            }

            if (TxtLoginName.Text.Length == 0)
            {
                //LblMsg.Text = "Login Name Is Blank, Enter Valid Login Name....";
                TxtLoginName.Focus();
                return;
            }

            if (DDLUserGroup.SelectedValue == "0")
            {
                //LblMsg.Text = "Select User Group....";
                DDLUserGroup.Focus();
                return;
            }

            if (TxtDOB.Text.Length == 0)
            {
                //LblMsg.Text = "DOB Is Blank, Enter Valid Brith Date....";
                TxtDOB.Focus();
                return;
            }

            if (TxtEMailId.Text.Length == 0)
            {
                //LblMsg.Text = "EMail Id Is Blank, Enter Valid EMail Id....";
                TxtEMailId.Focus();
                return;
            }

            if (TxtMobNo.Text.Length == 0)
            {
                //LblMsg.Text = "Mob.No Is Blank, Enter Valid Mob.No....";
                TxtMobNo.Focus();
                return;
            }

            if (TxtPassword.Text.Length == 0)
            {
                //LblMsg.Text = "Password Is Blank, Enter Valid Password....";
                TxtPassword.Focus();
                return;
            }

            if (TxtQuestion.Text.Length == 0)
            {
                //LblMsg.Text = "Question Is Blank, Enter Valid Question....";
                TxtQuestion.Focus();
                return;
            }

            if (TxtAnswer.Text.Length == 0)
            {
                //LblMsg.Text = "Answer Is Blank, Enter Valid Answer....";
                TxtAnswer.Focus();
                return;
            }

            StrSql        = new StringBuilder();
            StrSql.Length = 0;


            if (HidFldId.Value.Length == 0)
            {
                StrSql.AppendLine("Insert Into User_Mast (UId,UserName,LoginName");
                StrSql.AppendLine(",UserGroup,Password ");
                StrSql.AppendLine(",Gender,EMailId,DOB");
                StrSql.AppendLine(",CountryId,StateId,CityId");
                StrSql.AppendLine(",MobNo,Phone");
                StrSql.AppendLine(",Question,Answer");
                StrSql.AppendLine(",Activation");
                StrSql.AppendLine(",Entry_Date,Entry_Time");
                StrSql.AppendLine(",Entry_UID,UPDFLAG)");

                StrSql.AppendLine("Values(@UserId,@UserName,@LoginName");
                StrSql.AppendLine(",@UserGroup,@Password ");
                StrSql.AppendLine(",@Gender,@EMailId,@DOB");
                StrSql.AppendLine(",@CountryId,@StateId,@CityId");
                StrSql.AppendLine(",@MobNo,@Phone");
                StrSql.AppendLine(",@Question,@Answer");
                StrSql.AppendLine(",@Activation");
                StrSql.AppendLine(",GetDate(),Convert(VarChar,GetDate(),108)");
                StrSql.AppendLine(",@Entry_UID,0)");
            }
            else
            {
                StrSql.AppendLine("Update User_Mast Set UId=@UserId,UserName=@UserName,LoginName=@LoginName");
                StrSql.AppendLine(",UserGroup=@UserGroup,Password=@Password ");
                StrSql.AppendLine(",Gender=@Gender,EMailId=@EMailId,DOB=@DOB");
                StrSql.AppendLine(",CountryId=@CountryId,StateId=@StateId,CityId=@CityId");
                StrSql.AppendLine(",MobNo=@MobNo,Phone=@Phone");
                StrSql.AppendLine(",Question=@Question,Answer=@Answer");
                StrSql.AppendLine(",Activation=@Activation");
                StrSql.AppendLine(",MEntry_Date=GetDate(),MEntry_Time=Convert(Varchar,GetDate(),108)");
                StrSql.AppendLine(",MEntry_UID=@Entry_UID,UPDFLAG=IsNull(UPDFlag,0)+1");
                StrSql.AppendLine("Where Id=@Id");
            }

            Cmd = new SqlCommand(StrSql.ToString(), SqlFunc.gConn);
            Cmd.Parameters.AddWithValue("@UserId", TxtUserId.Text.Trim());
            Cmd.Parameters.AddWithValue("@UserName", TxtUserName.Text.Trim());
            Cmd.Parameters.AddWithValue("@LoginName", TxtLoginName.Text.Trim());
            Cmd.Parameters.AddWithValue("@UserGroup", DDLUserGroup.SelectedValue);
            Cmd.Parameters.AddWithValue("@Password", Sec.Encrypt(TxtPassword.Text.Trim()));
            Cmd.Parameters.AddWithValue("@Gender", rblGender.SelectedValue);
            Cmd.Parameters.AddWithValue("@EMailId", TxtEMailId.Text.Trim());

            Cmd.Parameters.AddWithValue("@DOB", ValueConvert.ConvertDate(TxtDOB.Text));

            if (ddlCountry.SelectedValue != "0")
            {
                Cmd.Parameters.AddWithValue("@CountryId", ddlCountry.SelectedValue);
            }
            else
            {
                Cmd.Parameters.AddWithValue("@CountryId", DBNull.Value);
            }
            if (ddlState.SelectedValue != "0")
            {
                Cmd.Parameters.AddWithValue("@StateId", ddlState.SelectedValue);
            }
            else
            {
                Cmd.Parameters.AddWithValue("@StateId", DBNull.Value);
            }
            if (ddlCity.SelectedValue != "0")
            {
                Cmd.Parameters.AddWithValue("@CityId", ddlCity.SelectedValue);
            }
            else
            {
                Cmd.Parameters.AddWithValue("@CityId", DBNull.Value);
            }
            Cmd.Parameters.AddWithValue("@MobNo", TxtMobNo.Text.Trim());
            Cmd.Parameters.AddWithValue("@Phone", TxtPhone.Text.Trim());
            Cmd.Parameters.AddWithValue("@Question", TxtQuestion.Text.Trim());
            Cmd.Parameters.AddWithValue("@Answer", TxtAnswer.Text.Trim());
            Cmd.Parameters.AddWithValue("@Activation", 0);
            Cmd.Parameters.AddWithValue("@Entry_UID", HidFldUID.Value.ToString());

            if (HidFldId.Value.Length == 0)
            {
                SqlFunc.ExecuteNonQuery(Cmd);
                LblMsg.Text = "User added successfully";
            }
            else
            {
                Cmd.Parameters.AddWithValue("@ID", HidFldId.Value.ToString());

                SqlFunc.ExecuteNonQuery(Cmd);
                LblMsg.Text = "User updated successfully";
            }


            FillGrid();

            ClearAll();

            MyMenu.Items[0].Selected    = true;
            MyMenu.Items[0].ImageUrl    = "~/Images/ViewEnable.jpg";
            MyMultiView.ActiveViewIndex = 0;
            MyMenu.Items[1].ImageUrl    = "~/Images/NewOrEditDisable.jpg";
        }
        catch (Exception ex)
        {
            Response.Write(ex);
        }
    }
Ejemplo n.º 16
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        StrSql        = new StringBuilder();
        StrSql.Length = 0;
        if (DdlUserGrp.Value == "EMP")
        {
            StrSql.AppendLine("Select EM.EmpName,EM.EMailId,EM.ID,DM.DesigName");
            StrSql.AppendLine("From Emp_Mast EM ");
            StrSql.AppendLine("Left Join Desig_Mast DM On EM.DesigId=DM.Id");
            StrSql.AppendLine("Where ISDATE(EM.LeftDate)=0 And EM.EMailId ='" + TxtUserId.Value + "'");
            StrSql.AppendLine("And EM.Password='******'");
        }
        else
        {
            StrSql.AppendLine("Select UM.LoginName,UM.EMailId,UM.ID,UM.UID,UG.Group_Name");
            StrSql.AppendLine("From User_Mast UM ");
            StrSql.AppendLine("Left Join User_Group UG On UM.UserGroup=UG.Id");
            StrSql.AppendLine("Where (UM.EMailId ='" + TxtUserId.Value + "' Or UM.MobNo='" + TxtUserId.Value + "')");
            StrSql.AppendLine("And UM.Password='******'");
            StrSql.AppendLine("And UM.UserGroup=" + int.Parse(DdlUserGrp.Value));
        }

        dtTemp = new DataTable();
        dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString());

        if (dtTemp.Rows.Count > 0)
        {
            if (ChkRememberMe.Checked)
            {
                Response.Cookies["UserId"].Expires   = DateTime.Now.AddDays(15);
                Response.Cookies["Password"].Expires = DateTime.Now.AddDays(15);
            }
            else
            {
                Response.Cookies["UserId"].Expires   = DateTime.Now.AddDays(-1);
                Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
            }
            Response.Cookies["UserId"].Value   = TxtUserId.Value.Trim();
            Response.Cookies["Password"].Value = TxtPassword.Value.Trim();

            if (DdlUserGrp.Value == "EMP")
            {
                Session["LoginName"]     = dtTemp.Rows[0]["EmpName"].ToString();
                Session["LoginEMailId"]  = dtTemp.Rows[0]["EMailId"].ToString();
                Session["LoginId"]       = dtTemp.Rows[0]["ID"].ToString();
                Session["LoginEmpDesig"] = dtTemp.Rows[0]["DesigName"].ToString();

                Session["LoginUser"]    = dtTemp.Rows[0]["ID"].ToString();
                Session["LoginUserId"]  = dtTemp.Rows[0]["ID"].ToString();
                Session["LoginUserGrp"] = "EMP"; //dtTemp.Rows[0]["EmpName"].ToString();

                //Response.Redirect("EmpHome.aspx");
                //Response.Redirect("HomePage.aspx");
            }
            else
            {
                Session["LoginName"]     = dtTemp.Rows[0]["LoginName"].ToString();
                Session["LoginEMailId"]  = dtTemp.Rows[0]["EMailId"].ToString();
                Session["LoginId"]       = dtTemp.Rows[0]["ID"].ToString();
                Session["LoginEmpDesig"] = dtTemp.Rows[0]["Group_Name"].ToString();

                Session["LoginUser"]    = dtTemp.Rows[0]["UID"].ToString();
                Session["LoginUserId"]  = dtTemp.Rows[0]["ID"].ToString() + "-" + dtTemp.Rows[0]["UID"].ToString();
                Session["LoginUserGrp"] = dtTemp.Rows[0]["Group_Name"].ToString();

                //Response.Redirect("HomePage.aspx");
            }

            if (Session["LoginUserGrp"].ToString().ToUpper() == "ADMIN")
            {
                Session["MasterFile"] = "/MasterHome.master";
            }
            else if (Session["LoginUserGrp"].ToString().ToUpper() == "USER")
            {
                Session["MasterFile"] = "/MasterHomeUser.master";
            }
            else if (Session["LoginUserGrp"].ToString().ToUpper() == "REPORT")
            {
                Session["MasterFile"] = "/MasterHomeReport.master";
            }
            else if (Session["LoginUserGrp"].ToString().ToUpper() == "EMP")
            {
                Session["MasterFile"] = "/MasterHomeEmp.master";
            }
            else
            {
                Session["MasterFile"] = "/MasterHomeBlank.master";
            }

            Response.Redirect("~/HomePage.aspx");
        }
        else
        {
            LblMsg.Text = "UserName/Passwrod incorrect.";
            TxtUserId.Focus();
        }
    }