예제 #1
0
        private void btnBack_Click(object sender, EventArgs e)
        {
            frmCompany frmComp = new frmCompany();

            frmComp.Show();
            this.Close();
        }
예제 #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsername.Text) || txtUsername.Text == "Username")
            {
                MessageBox.Show("Enter Username ,please.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (String.IsNullOrEmpty(txtPassword.Text) || txtPassword.Text == "Password")
            {
                MessageBox.Show("Enter password ,please.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //// Login

            try
            {
                using (OleDbCommand cmd = new OleDbCommand("SELECT count(*) FROM users where [USERNAME]=@UserName and [PASSWORD]=@Password", conn))
                {
                    cmd.Parameters.AddWithValue("@UserName", txtUsername.Text);
                    cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
                    cmd.Connection.Open();
                    if ((int)cmd.ExecuteScalar() > 0)
                    {
                        // MessageBox.Show("You have successfully Logged In");
                        setUserId();
                        frmCompany frmCom = new frmCompany();
                        frmCom.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Login Failed");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error" + ex);
            }
            finally
            {
                conn.Close();
            }
        }
        public frmCompany_frmAddEdit(frmCompany frmCom, String companyID)
        {
            // load company data
            InitializeComponent();
            isEdit   = true;
            compID   = companyID;
            FromComp = frmCom;

            //// connect database
            try
            {
                conn = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["General_Journal.Properties.Settings.General_JournalConnectionString"].ConnectionString);
                using (OleDbCommand cmd = new OleDbCommand("select * from company where [COMPANY_ID]=@compID", conn))
                {
                    cmd.Parameters.AddWithValue("@compID", companyID);
                    cmd.Connection.Open();
                    OleDbDataReader reader = null;
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        txtCompanyName.Text  = reader["COMPANY_NAME"].ToString();
                        txtAddress.Text      = reader["COMPANY_ADDRESS"].ToString();
                        txtPhone.Text        = reader["COMPANY_PHONE"].ToString();
                        txtTradeRegisNo.Text = reader["COMPANY_TRADE_REGIS"].ToString();
                        txtTaxIdNo.Text      = reader["COMPANY_TAX_ID"].ToString();
                    }
                }
            }
            catch (Exception Ex)
            {
                conn.Dispose();
            }
            finally
            {
                conn.Close();
            }
        }
 public frmCompany_frmAddEdit(frmCompany frmCom)
 {
     InitializeComponent();
     isAdd    = true;
     FromComp = frmCom;
 }