コード例 #1
0
ファイル: frmMain.cs プロジェクト: anand1606/Safety
        private void mnuDBConn_Click(object sender, EventArgs e)
        {
            Form t = Application.OpenForms["FrmConnection"];

            if (t == null)
            {
                FrmConnection m = new FrmConnection();
                m.MdiParent = this;
                m.typeofcon = "DBCON";
                m.Show();
            }
        }
コード例 #2
0
ファイル: frmLogin.cs プロジェクト: anand1606/Safety
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string err = DataValidate();


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

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

            if (string.IsNullOrEmpty(err))
            {
                string  sql = "Select * from MastUser Where UserID = '{0}' and Pass = '******' and Active = 1";
                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);
                }
            }
        }