Beispiel #1
0
        public bool SendOTP(EmpProperty dataItem)
        {
            bool _result = false;

            try
            {
                string OTP = this.GetOTP();
                if (this.InsertOTP(dataItem, OTP))
                {
                    string EXP = this.GetEXP_OTP(dataItem, OTP);
                    if (EXP != "")
                    {
                        string sendTo  = dataItem.email;
                        string Subject = @"Program : Login";
                        string Body    = @"OTP for Program Login is " + OTP + @" 
                                <br>EXP : " + EXP + @"
                                <br>Do not open this code to other people.";

                        if (_emailControllors.SentEmail(sendTo, Subject, Body))
                        {
                            _result = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_result);
        }
Beispiel #2
0
        public string GetEXP_OTP(EmpProperty dataItem, string OTP)
        {
            string _result = "";

            try
            {
                resultData = _models.SearchOTP(dataItem, OTP);
                if (resultData.StatusOnDb == true)
                {
                    if (resultData.ResultOnDb.Rows.Count > 0)
                    {
                        string EXP_OTP = resultData.ResultOnDb.Rows[0]["EXP_OTP"].ToString();
                        _result = EXP_OTP;
                    }
                }
                else
                {
                    MessageBox.Show(resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_result);
        }
Beispiel #3
0
        public bool CheckEmpCompanyExist(EmpProperty dataItem)
        {
            bool _result = false;

            try
            {
                resultData = _models.SearchEmpCompany(dataItem);
                if (resultData.StatusOnDb == true)
                {
                    if (resultData.ResultOnDb.Rows.Count > 0)
                    {
                        if (resultData.ResultOnDb.Rows[0]["EMP_STATUS"].ToString() == "1")
                        {
                            _result = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Couldn't find Employee ID", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
                else
                {
                    MessageBox.Show(resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }

            return(_result);
        }
Beispiel #4
0
        public EmpProperty GetEmpProperty(EmpProperty dataItem)
        {
            EmpProperty _result = new EmpProperty();

            try
            {
                resultData = _models.SearchEmpCompany(dataItem);
                if (resultData.StatusOnDb == true)
                {
                    if (resultData.ResultOnDb.Rows.Count > 0)
                    {
                        _result = new EmpProperty
                        {
                            code       = resultData.ResultOnDb.Rows[0]["EMP_ID"].ToString(),
                            name       = resultData.ResultOnDb.Rows[0]["EMP_NAME"].ToString(),
                            sername    = resultData.ResultOnDb.Rows[0]["EMP_SURNAME"].ToString(),
                            email      = resultData.ResultOnDb.Rows[0]["EMP_EMAIL"].ToString(),
                            startwork  = resultData.ResultOnDb.Rows[0]["START_WORK"].ToString(),
                            depertment = resultData.ResultOnDb.Rows[0]["DEPARTMENT"].ToString(),
                            position   = resultData.ResultOnDb.Rows[0]["POSITION"].ToString()
                        };
                    }
                }
                else
                {
                    MessageBox.Show(resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(_result);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(_result);
            }
        }
Beispiel #5
0
        private void lblLogOut_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Do you want Logout?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                this.panShowName.Visible     = false;
                this.panSettingTopic.Visible = false;

                this.btnLogin.Visible = true;

                //btn
                this.btnSearch.Visible = true;

                this.btnInput.Visible             = false;
                this.btnSetFlow.Visible           = false;
                this.btnSetPurchase.Visible       = false;
                this.btnUpdateInput.Visible       = false;
                this.btnProcessSetting.Visible    = false;
                this.btnCreateProductType.Visible = false;
                this.btnPO.Visible = false;

                _empLogin = new EmpProperty();
                this.Load_PageSearch();
            }
        }
Beispiel #6
0
        private void picChangePass_Click(object sender, EventArgs e)
        {
            frmChangePass_Main _frmChangePass_Main = new frmChangePass_Main(_empLogin);

            _frmChangePass_Main.ShowDialog();
            if (_frmChangePass_Main.DialogResult == DialogResult.OK)
            {
                this.panShowName.Visible     = false;
                this.panSettingTopic.Visible = false;

                this.btnLogin.Visible = true;

                this.btnSearch.Visible = true;

                this.btnInput.Visible             = false;
                this.btnSetFlow.Visible           = false;
                this.btnSetPurchase.Visible       = false;
                this.btnUpdateInput.Visible       = false;
                this.btnProcessSetting.Visible    = false;
                this.btnCreateProductType.Visible = false;

                _empLogin = new EmpProperty();
                this.Load_PageSearch();
            }
        }
Beispiel #7
0
        public string UpdatePassLoginFitelGroup(EmpProperty dataItem)
        {
            sql = @"UPDATE `logon_fitel_group` SET 
                    `PASSWORD` = UNHEX(MD5('" + dataItem.pass + @"'))
                    WHERE `EMP_ID` = '" + dataItem.code + @"'";

            return(sql);
        }
Beispiel #8
0
        public string SearchEmpFitelGroup(EmpProperty dataItem)
        {
            sql = @"SELECT *
                    FROM `logon_fitel_group`
                    WHERE EMP_ID = '" + dataItem.code + @"';";

            return(sql);
        }
Beispiel #9
0
        public string UpdateOTPUsed(EmpProperty emp, string OTP)
        {
            sql = @"UPDATE `otp`  SET USED  = 1
                    WHERE EMP_ID = '" + emp.code + @"'
                    AND OTP = '" + OTP + @"'";

            return(sql);
        }
Beispiel #10
0
 public OutputOnDbProperty UpdateOTPUsed(EmpProperty dataItem, string OTP)
 {
     TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionPersonnel"].ConnectionString;
     sql        = _sqlFactory.UpdateOTPUsed(dataItem, OTP);
     resultData = base.UpdateBySql(sql);
     TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionStrMysql"].ConnectionString;
     return(resultData);
 }
Beispiel #11
0
 public OutputOnDbProperty UpdatePassLoginFitelGroup(EmpProperty dataItem)
 {
     TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionPersonnel"].ConnectionString;
     sql        = _sqlFactory.UpdatePassLoginFitelGroup(dataItem);
     resultData = base.UpdateBySql(sql);
     TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionStrMysql"].ConnectionString;
     return(resultData);
 }
Beispiel #12
0
 public OutputOnDbProperty SearchEmpCompany(EmpProperty dataItem)
 {
     TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionLogin"].ConnectionString;
     sql        = _sqlFactory.SearchEmpCompany(dataItem);
     resultData = base.SearchBySql(sql);
     TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionStrMysql"].ConnectionString;
     return(resultData);
 }
Beispiel #13
0
 public string DeleteOTP(EmpProperty emp)
 {
     sql = @"DELETE
             FROM `otp`
             WHERE EMP_ID = '" + emp.code + @"'
             OR USED = 1
             OR EXP_OTP < NOW();";
     return(sql);
 }
Beispiel #14
0
        public string LoginFitelGroup(EmpProperty dataItem)
        {
            sql = @"SELECT*
                    FROM `logon_fitel_group`
                    WHERE EMP_ID = '" + dataItem.code + @"'
                    AND `PASSWORD` = UNHEX(MD5('" + dataItem.pass + "'))";

            return(sql);
        }
Beispiel #15
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            frmLogin_Main _frmLogin = new frmLogin_Main();

            _frmLogin.ShowDialog();
            _resultLogin = _frmLogin._resultLogin;

            //_resultLogin = new LoginProperty
            //{
            //    loginStatus = true,
            //    empDetial = new EmpProperty
            //    {
            //        name = "Ausada",
            //        sername = "Sukkheesuec"
            //    }
            //};

            if (_resultLogin.loginStatus == true)
            {
                _empLogin = _resultLogin.empDetial;

                this.btnLogin.Visible = false;

                this.panShowName.Visible     = true;
                this.panSettingTopic.Visible = true;

                this.btnInput.Visible             = true;
                this.btnSetFlow.Visible           = true;
                this.btnSetPurchase.Visible       = true;
                this.btnUpdateInput.Visible       = true;
                this.btnProcessSetting.Visible    = true;
                this.btnSubProcessSetting.Visible = true;
                this.btnCreateProductType.Visible = true;
                this.btnPO.Visible = true;

                this.lblShowName.Text = String.Format("{0} {1}.", _empLogin.name, _empLogin.sername.Substring(0, 3));


                //if (_empPCControllors.CheckEmpPCExist(_empLogin) == true)
                //{
                //    this.bttNewOrder.Visible = true;
                //    this.panOnNewOrder.Visible = true;

                //    this.bttNewCondition.Visible = true;
                //    this.panOnNewCondition.Visible = true;

                //    this.bttUploadFile.Visible = true;
                //    this.panOnUploadFile.Visible = true;

                //    this.bttUpdateData.Visible = true;
                //    this.panOnUpdateData.Visible = true;

                //}
            }
        }
Beispiel #16
0
        public OutputOnDbProperty InsertOTP(EmpProperty dataItem, string OTP)
        {
            //Delete OTP Hittory
            OutputOnDbProperty _resultData = this.DeleteOTP(dataItem);

            TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionPersonnel"].ConnectionString;
            sql        = _sqlFactory.InsertOTP(dataItem, OTP);
            resultData = base.InsertBySql(sql);
            TransMysqlModels.strConnection = ConfigurationManager.ConnectionStrings["ConnectionStrMysql"].ConnectionString;
            return(resultData);
        }
Beispiel #17
0
        public string SearchOTP(EmpProperty emp, string OTP)
        {
            sql = @"SELECT EMP_ID 
                        ,USED
                        ,OTP
                        ,EXP_OTP

                    FROM `otp`
                    WHERE EMP_ID = '" + emp.code + @"'
                    AND OTP = '" + OTP + @"'";
            return(sql);
        }
Beispiel #18
0
        public string InsertLoginFitelGroup(EmpProperty dataItem)
        {
            sql = @"INSERT INTO `logon_fitel_group` (
                        `EMP_ID`
                        , `PASSWORD`
                        , `CREATE_ACC_DATE`
                    )
                    VALUES(
                        '" + dataItem.code + @"'
                        ,UNHEX(MD5('" + dataItem.pass + @"'))
                        , NOW()
                    );";

            return(sql);
        }
Beispiel #19
0
        public bool EnterOTP(EmpProperty dataItem, string OTP)
        {
            bool _result = false;

            try
            {
                resultData = _models.SearchOTP(dataItem, OTP);
                if (resultData.StatusOnDb == true)
                {
                    if (resultData.ResultOnDb.Rows.Count > 0)
                    {
                        //Check EXP Date.
                        string   EXP_OTP     = resultData.ResultOnDb.Rows[0]["EXP_OTP"].ToString();
                        DateTime oEXP_OTP    = DateTime.Parse(EXP_OTP);
                        string   dateTimeNow = this.GetDateTime();
                        if (dateTimeNow != "")
                        {
                            DateTime odateTimeNow = DateTime.Parse(dateTimeNow);
                            if (oEXP_OTP >= odateTimeNow)
                            {
                                if (this.UpdateOTPUsed(dataItem, OTP))
                                {
                                    _result = true;
                                }
                            }
                            else
                            {
                                MessageBox.Show("OTP has expired, please click 'Send again.'", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("You have entered an incorrect code. Please try again.", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show(resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(_result);
        }
Beispiel #20
0
        public string SearchEmpCompany(EmpProperty dataItem)
        {
            sql = @"SELECT EmpCode AS EMP_ID
                        ,IF(EmpCodeResign IS NULL,'1','0') AS EMP_STATUS
                        ,EmpName AS EMP_NAME
                        ,EmpSurname AS EMP_SURNAME 
                        ,EmpEmail AS EMP_EMAIL
                        ,EmpStartwork AS START_WORK
						,EmpPosition AS `POSITION`
						,EmpDept AS `DEPARTMENT`

                    FROM `info_employees`
                    WHERE empCode = '" + dataItem.code + @"';";

            return(sql);
        }
Beispiel #21
0
 public string InsertOTP(EmpProperty emp, string OTP)
 {
     sql = @"INSERT INTO `otp` (
                 EMP_ID
                 ,USED
                 ,OTP
                 ,EXP_OTP
             )
             VALUES(
                  '" + emp.code + @"'
                 ,0
                 ,'" + OTP + @"'
                 ,NOW() + INTERVAL 3 MINUTE
             );";
     return(sql);
 }
Beispiel #22
0
        private void bttNext_Click(object sender, EventArgs e)
        {
            if (this.txtEmpID.Text.Trim() == "")
            {
                return;
            }
            _empProperty = new EmpProperty {
                code = this.txtEmpID.Text.Trim()
            };

            if (_controllors.CheckEmpCompanyExist(_empProperty) == true)
            {
                _empProperty = _controllors.GetEmpProperty(_empProperty);
            }
            else
            {
                this.txtEmpID.Text = ""; return;
            }

            _frmMain._resultLogin.empDetial = _empProperty;
            if (_controllors.CheckEmpFitelGroupExist(_empProperty) == true)
            {
                //Clear panel Body.
                _frmMain.panBody.Controls.Clear();

                //Load page search.
                pageEnter_Password _pageEnter_User = new pageEnter_Password(_frmMain);
                _frmMain.panBody.Controls.Add(_pageEnter_User);
                _pageEnter_User.Dock = DockStyle.Fill;
                _pageEnter_User.BringToFront();
            }
            else
            {
                //Clear panel Body.
                _frmMain.panBody.Controls.Clear();

                //Load page search.
                pageEnter_Create _pageEnter_User = new pageEnter_Create(_frmMain);
                _frmMain.panBody.Controls.Add(_pageEnter_User);
                _pageEnter_User.Dock = DockStyle.Fill;
                _pageEnter_User.BringToFront();
            }
        }
Beispiel #23
0
        public bool InsertLoginFitelGroup(EmpProperty dataItem)
        {
            bool _result = false;

            try
            {
                resultData = _models.InsertLoginFitelGroup(dataItem);
                if (resultData.StatusOnDb == true)
                {
                    _result = true;
                }
                else
                {
                    MessageBox.Show(resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            return(_result);
        }
Beispiel #24
0
        public bool UpdateOTPUsed(EmpProperty dataItem, string OTP)
        {
            bool _result = false;

            try
            {
                resultData = _models.UpdateOTPUsed(dataItem, OTP);
                if (resultData.StatusOnDb == true)
                {
                    _result = true;
                }
                else
                {
                    MessageBox.Show(resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            return(_result);
        }
Beispiel #25
0
        public bool SendNewPassword(EmpProperty dataItem)
        {
            bool _result = false;

            try
            {
                string sendTo  = dataItem.email;
                string Subject = @"Program : Login";
                string Body    = "Your new password is : " + dataItem.pass;

                if (_emailControllors.SentEmail(sendTo, Subject, Body))
                {
                    _result = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_result);
        }
Beispiel #26
0
        public bool CheckEmpFitelGroupExist(EmpProperty dataItem)
        {
            bool _result = false;

            try
            {
                resultData = _models.SearchEmpFitelGroup(dataItem);
                if (resultData.StatusOnDb == true)
                {
                    if (resultData.ResultOnDb.Rows.Count > 0)
                    {
                        _result = true;
                    }
                }
                else
                {
                    MessageBox.Show(resultData.MessageOnDb, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            return(_result);
        }
Beispiel #27
0
 public OutputOnDbProperty SearchOTP(EmpProperty dataItem, string OTP)
 {
     resultData = _services.SearchOTP(dataItem, OTP);
     return(resultData);
 }
Beispiel #28
0
 public frmEnter_OTP(EmpProperty empIN)
 {
     InitializeComponent();
     emp = empIN;
     this.DialogResult = DialogResult.None;
 }
Beispiel #29
0
 public OutputOnDbProperty UpdateOTPUsed(EmpProperty dataItem, string OTP)
 {
     resultData = _services.UpdateOTPUsed(dataItem, OTP);
     return(resultData);
 }
Beispiel #30
0
 public OutputOnDbProperty UpdatePassLoginFitelGroup(EmpProperty dataItem)
 {
     resultData = _services.UpdatePassLoginFitelGroup(dataItem);
     return(resultData);
 }