Example #1
0
        private void btnLogin_Click(System.Object sender, System.EventArgs e)
        {
            /*
             * MethodInvoker myProcessStarter = new MethodInvoker(InitialDigSignature);
             *
             * myProcessStarter.BeginInvoke(null, null);
             */

            if (this.txtUsername.Text == "" | this.txtPassword.Text == "")
            {
                ACMS.Utils.UI.ShowErrorMessage(this, "Empty Username & Password!", "Error");
                progressBar1.Value = 0;
            }
            else
            {
                try
                {
                    ProgressBar();

                    ACMSLogic.Login.Login login = new ACMSLogic.Login.Login();
                    //Do.Employee emplogin = login.GetEmployeeByIdAndPassword(this.txtUsername.Text, this.txtPassword.Text);

                    //MessageBox.Show(this, emplogin.Id.ToString()+" "+emplogin.Department.Id+" "+emplogin.RightsLevel.RightsLevelEntrys.Count.ToString());

                    //Rp.EmployeeRepository er = new Rp.EmployeeRepository();
                    Do.Employee emp = login.GetEmployeeByIdAndPassword(this.txtUsername.Text, this.txtPassword.Text);//er.GetEmployeeByIdAndPassword(this.txtUsername.Text, this.txtPassword.Text);

                    System.Security.Principal.WindowsIdentity userLogin = System.Security.Principal.WindowsIdentity.GetCurrent();
                    //System.Security.Principal.WindowsIdentity userLogin = "******";

                    if (login.Check_Concurrent() == false)
                    {
                        ACMS.Utils.UI.ShowErrorMessage(this, "Number of Login Exceed Users Limit!", "Authorisation");
                    }
                    else
                    {
                        //Rp.TerminalUserRepository tup = new Rp.TerminalUserRepository();
                        if (emp != null)
                        {
                            //userLogin.Name="AFPL\EdithGan";

                            //Rev 6.8.0.0 Determine whether is RoadShow or Terminal. Add in 2 config - RoadShow & RoadShowTerminal
                            Acms.Core.Domain.TerminalUser tu = new Acms.Core.Domain.TerminalUser();
                            if (ConfigurationSettings.AppSettings["RoadShow"].ToString() == "1")
                            {
                                tu = login.GetTerminalUserByUserId(ConfigurationSettings.AppSettings["RoadShowTerminal"].ToString()) as Acms.Core.Domain.TerminalUser;
                                ACMSLogic.User.RoadShow = "RS";//jackie 13032012
                            }
                            else
                            {
                                tu = login.GetTerminalUserByUserId(userLogin.Name) as Acms.Core.Domain.TerminalUser;
                                ACMSLogic.User.RoadShow = tu.Branch.Id;
                            }

                            //Acms.Core.Domain.TerminalUser tu = login.GetTerminalUserByUserId("AFPL\\TO-Terminal1") as Acms.Core.Domain.TerminalUser;
                            //Acms.Core.Domain.TerminalUser tu = login.GetTerminalUserByUserId("AFPL\\TO-Terminal2") as Acms.Core.Domain.TerminalUser;

                            //Show AMCS Branch
                            bool Valid = numberUser();
                            //bool Valid = true;
                            if (emp.CanAccess("AB_LOGIN", tu.Branch.Id) && Valid)
                            {
                                //smell tandas code
                                ACMSDAL.TblTerminalUser UserLog = new TblTerminalUser();
                                UserLog.StrTerminalUserCode = userLogin.Name;
                                UserLog.UpdateSession(true, DateTime.Now);

                                modInitForms.fLogin.Hide();
                                ACMSLogic.User.BranchCode = tu.Branch.Id;
                                ACMSLogic.User.EmployeeID = emp.Id;

                                /*
                                 * //cbRoadShow.Checked = true;
                                 * if (cbRoadShow.Checked)
                                 * {
                                 *  ACMSLogic.User.RoadShow = "RS";//jackie 13032012
                                 * }
                                 * else
                                 *  ACMSLogic.User.RoadShow = tu.Branch.Id;*/

                                if (emp.Department != null)
                                {
                                    ACMSLogic.User.DepartmentID = emp.Department.Id;
                                }
                                if (emp.StrEmployeeName != null)
                                {
                                    ACMSLogic.User.EmployeeName = emp.StrEmployeeName;
                                }
                                if (emp.JobPosition.Id != null)
                                {
                                    ACMSLogic.User.JobPositionCode = emp.JobPosition.Id;
                                }
                                if (emp.RightsLevel != null)
                                {
                                    ACMSLogic.User.RightsLevelID = emp.RightsLevel.Id;
                                }

                                try
                                {
                                    //ClassAttendance.CreateClassInstance();
                                    //PackageCode.CreateUnLinkPackage();
                                }
                                catch (Exception ex)
                                {
                                    return;
                                }
                                ACMSLogic.User oUser = new User();

                                if (modInitForms.fBranch != null)
                                {
                                    modInitForms.fBranch.IsLogin = true;
                                    modInitForms.fBranch.Close();
                                    modInitForms.fBranch.Dispose();
                                    if (modInitForms.fStaff != null)
                                    {
                                        modInitForms.fStaff.Close();
                                        modInitForms.fStaff.Dispose();
                                    }
                                    if (modInitForms.fManager != null)
                                    {
                                        modInitForms.fManager.Close();
                                        modInitForms.fManager.Dispose();
                                    }
                                }

                                Thread.Sleep(1000);
                                modInitForms.fBranch = new frmBranch(cmbLanguage.EditValue.ToString());
                                modInitForms.fBranch.SetEmployeeRecord(emp);
                                modInitForms.fBranch.SetTerminalUser(tu);
                                modInitForms.fBranch.OpenDayShift();

                                //						if (UnclosedShift == true)
                                //							MessageBox.Show("There is unclosed shift. Please close the shift.");

                                modInitForms.fBranch.initData(oUser);
                                modInitForms.fBranch.Show();

                                //DateTime end = DateTime.Now;
                                //TimeSpan diff = end.Subtract(start);
                                //MessageBox.Show(diff.TotalSeconds.ToString(),"Time");
                            }
                            else if (emp.CanAccess("AB_TIMECARD_LOGIN", tu.Branch.Id))
                            {
                                modInitForms.fLogin.Hide();
                                //Show AMCS Time Card
                                if (modInitForms.fTimeCard == null)
                                {
                                    modInitForms.fTimeCard = new frmTimeCard(tu.Branch.Id);
                                    modInitForms.fTimeCard.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "Invalid username and password or you don't have access to this Branch, please try again");
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "Invalid username and password, Please try again");
                        }
                    }
                }
                catch (Exception ex)
                {
                    return;
                }
            }
        }
Example #2
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            int output;

            output = 0;

            if (employee.CanAccess("AM_INSERT_ROSTER", terminalUser.Branch.Id))
            {
                if (employee.CanAccess("AM_INSERT_TODAYROSTER", terminalUser.Branch.Id) == true && System.Convert.ToDateTime(dtDate.EditValue) <= DateTime.Today)
                {
                    if (employee.Id == ConvertToInt(cbEmployee.EditValue))
                    {
                        MessageBox.Show("You can't edit your own today roster");
                        return;
                    }
                }
                else if (employee.CanAccess("AM_INSERT_TODAYROSTER", terminalUser.Branch.Id) == true && System.Convert.ToDateTime(dtDate.EditValue) <= DateTime.Today)
                {
                    MessageBox.Show("You cannot insert today roster.");
                    return;
                }

                try
                {
                    if (dtStartTime.EditValue == null || dtEndTime.EditValue == null)
                    {
                        MessageBox.Show("Must Key in Start Time and End Time");
                    }
                    else
                    {
                        if (TimeRangeValidation())
                        {
                            int yy, mm, dd, hh, min, ss;
                            yy = Convert.ToDateTime(dtDate.EditValue).Year;
                            mm = Convert.ToDateTime(dtDate.EditValue).Month;
                            dd = Convert.ToDateTime(dtDate.EditValue).Day;

                            hh  = Convert.ToDateTime(dtStartTime.EditValue).Hour;
                            min = Convert.ToDateTime(dtStartTime.EditValue).Minute;
                            ss  = Convert.ToDateTime(dtStartTime.EditValue).Second;

                            DateTime dt1 = new DateTime(yy, mm, dd, hh, min, ss);

                            hh  = Convert.ToDateTime(dtEndTime.EditValue).Hour;
                            min = Convert.ToDateTime(dtEndTime.EditValue).Minute;
                            ss  = Convert.ToDateTime(dtEndTime.EditValue).Second;
                            DateTime dt2 = new DateTime(yy, mm, dd, hh, min, ss);
                            try
                            {
                                SqlHelper.ExecuteNonQuery(connection, "In_tblRoster",
                                                          new SqlParameter("@retval", output),
                                                          new SqlParameter("@cmd", "I"),
                                                          new SqlParameter("@nRosterID", 1),
                                                          new SqlParameter("@dtDate", ConvertToDateTime(dtDate.EditValue)),
                                                          new SqlParameter("@dtStartTime", dt1),
                                                          new SqlParameter("@dtEndTime", dt2),
                                                          new SqlParameter("@strBranchCode", cbBranch.EditValue.ToString()),
                                                          new SqlParameter("@nEmployeeID", ConvertToInt(cbEmployee.EditValue)),
                                                          new SqlParameter("@strRemarks", txtRemarks.EditValue.ToString()));
                            }
                            catch (Exception)
                            {
                                return;
                            }

                            MessageBox.Show("Record Inserted");
                            //modInitForms.fManager.RefreshRoster();
                            this.Activate();
                        }
                        else
                        {
                            MessageBox.Show("Time Range was overlapped with others record");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("You don't have sufficient right to insert new roster for this staff");
            }

            //this.ParentForm.Refresh();
        }
Example #3
0
        private void btnLogin_Click(System.Object sender, System.EventArgs e)
        {
            #region Disable Code
            //Check login information from database
            //			ACMSLogic.User oUser = new User();
            //			bool chkUserLogin = false;
            //
            //			chkUserLogin = System.Convert.ToBoolean(oUser.Login(txtUsername.Text, txtPassword.Text));
            //
            //			if (chkUserLogin)
            //			{
            //				if (cmbModule.Text == "ACMS Branch")
            //				{
            //					//Show AMCS Branch
            //					if (modInitForms.fBranch == null)
            //					{
            //						modInitForms.fBranch = new frmBranch();
            //						modInitForms.fBranch.initData(oUser);
            //						modInitForms.fBranch.Show();
            //					}
            //
            //					modInitForms.fLogin.Hide();
            //				}
            //
            //				if (cmbModule.Text == "ACMS POS")
            //				{
            //					//Show AMCS POS
            //					if (modInitForms.fPOS == null)
            //					{
            //						modInitForms.fPOS = new frmPOS();
            //						modInitForms.fPOS.Show();
            //					}
            //
            //					modInitForms.fLogin.Hide();
            //				}
            //
            //				if (cmbModule.Text == "ACMS Staff")
            //				{
            //					//Show AMCS POS
            //					if (modInitForms.fStaff == null)
            //					{
            //						modInitForms.fStaff = new frmStaff();
            //						modInitForms.fStaff.Show();
            //					}
            //
            //					modInitForms.fLogin.Hide();
            //				}
            //			}
            //			else
            //			{
            //				MessageBox.Show(this, "Incorrect username and password, please try again");
            //			}
            #endregion
            //DateTime start = DateTime.Now;
            if (this.txtUsername.Text == "" | this.txtPassword.Text == "")
            {
                ACMS.Utils.UI.ShowErrorMessage(this, "Empty Username & Password!", "Error");
            }

            else
            {
                try
                {
                    ACMSLogic.Login.Login login = new ACMSLogic.Login.Login();
                    //Do.Employee emplogin = login.GetEmployeeByIdAndPassword(this.txtUsername.Text, this.txtPassword.Text);

                    //MessageBox.Show(this, emplogin.Id.ToString()+" "+emplogin.Department.Id+" "+emplogin.RightsLevel.RightsLevelEntrys.Count.ToString());

                    //Rp.EmployeeRepository er = new Rp.EmployeeRepository();
                    Do.Employee emp = login.GetEmployeeByIdAndPassword(this.txtUsername.Text, this.txtPassword.Text);                    //er.GetEmployeeByIdAndPassword(this.txtUsername.Text, this.txtPassword.Text);

                    System.Security.Principal.WindowsIdentity userLogin = System.Security.Principal.WindowsIdentity.GetCurrent();

                    if (login.Check_Concurrent() == false)
                    {
                        ACMS.Utils.UI.ShowErrorMessage(this, "Number of Login Exceed Users Limit!", "Authorisation");
                    }
                    else
                    {
                        //Rp.TerminalUserRepository tup = new Rp.TerminalUserRepository();
                        if (emp != null)
                        {
                            Acms.Core.Domain.TerminalUser tu = login.GetTerminalUserByUserId(userLogin.Name) as Acms.Core.Domain.TerminalUser;                            //tup.GetTerminalUserByUserId(userLogin.Name) as Acms.Core.Domain.TerminalUser;

                            //Show AMCS Branch
                            bool Valid = numberUser();
                            //bool Valid = true;
                            if (emp.CanAccess("AB_LOGIN", tu.Branch.Id) && Valid)
                            {
                                //smell tandas code
                                ACMSDAL.TblTerminalUser UserLog = new TblTerminalUser();
                                UserLog.StrTerminalUserCode = userLogin.Name;
                                UserLog.UpdateSession(true, DateTime.Now);

                                modInitForms.fLogin.Hide();
                                ACMSLogic.User.BranchCode = tu.Branch.Id;
                                ACMSLogic.User.EmployeeID = emp.Id;
                                if (emp.Department != null)
                                {
                                    ACMSLogic.User.DepartmentID = emp.Department.Id;
                                }
                                if (emp.StrEmployeeName != null)
                                {
                                    ACMSLogic.User.EmployeeName = emp.StrEmployeeName;
                                }
                                if (emp.JobPosition.Id != null)
                                {
                                    ACMSLogic.User.JobPositionCode = emp.JobPosition.Id;
                                }
                                if (emp.RightsLevel != null)
                                {
                                    ACMSLogic.User.RightsLevelID = emp.RightsLevel.Id;
                                }
                                try
                                {
                                    ClassAttendance.CreateClassInstance();
                                    PackageCode.CreateUnLinkPackage();
                                }
                                catch (Exception ex)
                                {
                                    return;
                                }
                                ACMSLogic.User oUser = new User();

                                if (modInitForms.fBranch != null)
                                {
                                    modInitForms.fBranch.IsLogin = true;
                                    modInitForms.fBranch.Close();
                                    modInitForms.fBranch.Dispose();
                                    if (modInitForms.fStaff != null)
                                    {
                                        modInitForms.fStaff.Close();
                                        modInitForms.fStaff.Dispose();
                                    }
                                    if (modInitForms.fManager != null)
                                    {
                                        modInitForms.fManager.Close();
                                        modInitForms.fManager.Dispose();
                                    }
                                }
                                modInitForms.fBranch = new frmBranch(cmbLanguage.EditValue.ToString());
                                modInitForms.fBranch.SetEmployeeRecord(emp);
                                modInitForms.fBranch.SetTerminalUser(tu);
                                modInitForms.fBranch.OpenDayShift();

                                //						if (UnclosedShift == true)
                                //							MessageBox.Show("There is unclosed shift. Please close the shift.");

                                modInitForms.fBranch.initData(oUser);
                                modInitForms.fBranch.Show();

                                //DateTime end = DateTime.Now;
                                //TimeSpan diff = end.Subtract(start);
                                //MessageBox.Show(diff.TotalSeconds.ToString(),"Time");
                            }
                            else if (emp.CanAccess("AB_TIMECARD_LOGIN", tu.Branch.Id))
                            {
                                modInitForms.fLogin.Hide();
                                //Show AMCS Time Card
                                if (modInitForms.fTimeCard == null)
                                {
                                    modInitForms.fTimeCard = new frmTimeCard(tu.Branch.Id);
                                    modInitForms.fTimeCard.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "Invalid username and password or you don't have access to this Branch, please try again");
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "Invalid username and password, Please try again");
                        }
                    }
                }
                catch (Exception ex)
                {
                    return;
                }
            }
        }