예제 #1
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            txtUserName.Text = "";
            txtPassword.Text = "";

            #region loadserverside

            try
            {
                Utils.DbCon dbcon = Utils.Helper.ReadConDb("DBCON");

                if (string.IsNullOrEmpty(dbcon.DataSource))
                {
                    return;
                }
                else
                {
                    Utils.Helper.constr = dbcon.ToString();
                }
            }
            catch (Exception ex)
            {
            }
            #endregion
        }
예제 #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string err = DataValidate();


            Utils.DbCon dbcon    = Utils.Helper.ReadConDb("DBCON");
            Utils.DbCon empdbcon = Utils.Helper.ReadConDb("EMPDBCON");

            if (string.IsNullOrEmpty(dbcon.DataSource))
            {
                var b = new FrmConnection();
                b.typeofcon = "DBCON";
                b.ShowDialog();
                return;
            }
            else
            {
                Utils.Helper.constr = dbcon.ToString();
            }


            if (string.IsNullOrEmpty(empdbcon.DataSource))
            {
                var b = new FrmConnection();
                b.typeofcon = "EMPDBCON";
                b.ShowDialog();
                return;
            }
            else
            {
                Utils.Helper.Empconstr = empdbcon.ToString();
            }


            if (string.IsNullOrEmpty(err))
            {
                string  sql = "Select * from MastUser Where UserID = '{0}' and Pass = '******' and Active = 'Y'";
                DataSet ds  = Utils.Helper.GetData(string.Format(sql, txtUserName.Text, txtPassword.Text), dbcon.ToString());

                bool hasrows = ds.Tables.Cast <DataTable>().Any(table => table.Rows.Count != 0);

                if (hasrows)
                {
                    Utils.User.GUserID   = txtUserName.Text.Trim();
                    Utils.User.GUserPass = txtPassword.Text.Trim();
                    Utils.User.IsAdmin   = (Convert.ToBoolean(ds.Tables[0].Rows[0]["IsAdmin"])) ? true : false;
                    Utils.User.GUserName = ds.Tables[0].Rows[0]["UserName"].ToString();

                    this.Hide();
                    Program.OpenMDIFormOnClose = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Invalid login id or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #3
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            string err = datavalidate();

            if (!string.IsNullOrEmpty(err))
            {
                MessageBox.Show(err);
                lblStatus.Text = "";
                return;
            }

            dbcon.DataSource            = txtDataSource.Text.Trim();
            dbcon.DbName                = txtDataBaseName.Text.Trim();
            dbcon.WindowsAuthentication = (cmbAuth.Text == "Windows Authentication") ? true : false;

            if (!dbcon.WindowsAuthentication)
            {
                dbcon.DbUser   = txtUserID.Text.Trim();
                dbcon.Password = txtPassword.Text.Trim();
            }

            using (SqlConnection cn = new SqlConnection(dbcon.ToString()))
            {
                try
                {
                    cn.Open();
                    cn.Close();
                    Sqlconnsts     = true;
                    lblStatus.Text = "Connection sucessfully established";
                }catch (SqlException ex)
                {
                    Sqlconnsts     = false;
                    lblStatus.Text = ex.ToString();
                }
            }
        }
예제 #4
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            txtUserName.Text = "";
            txtPassword.Text = "";

            #region loadserverside

            try
            {
                Utils.DbCon dbcon = Utils.Helper.ReadConDb("DBCON");

                if (string.IsNullOrEmpty(dbcon.DataSource))
                {
                    return;
                }
                else
                {
                    Utils.Helper.constr = dbcon.ToString();
                }

                DataSet ds      = Utils.Helper.GetData("Select Top 1 * From MastNetWork", Utils.Helper.constr);
                bool    hasrows = ds.Tables.Cast <DataTable>().Any(table => table.Rows.Count != 0);
                if (hasrows)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        Attendance.Classes.Globals.G_ServerWorkerIP = row["ServerWorkerIP"].ToString();
                    }
                }

                string        hostName = Dns.GetHostName(); // Retrive the Name of HOST
                List <string> localip  = Utils.Helper.GetLocalIPAddress();
                if (localip.Count > 0)
                {
                    bool found = false;

                    foreach (string ip in localip)
                    {
                        if (ip == Attendance.Classes.Globals.G_ServerWorkerIP)
                        {
                            Utils.User.GUserID   = "SERVER";
                            Utils.User.GUserPass = string.Empty;
                            Utils.User.IsAdmin   = false;
                            Utils.User.GUserName = "******";
                            found = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        this.Hide();
                        Program.OpenMDIFormOnClose = true;
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            #endregion
        }