private void cmdOk_Click(object sender, EventArgs e)
        {
            string  strSql          = null;
            dynamic intRowsAffected = null;

            try
            {
                using (OleDbConnection cnOle = new OleDbConnection(MyModules.MSAccessCn))
                {
                    cnOle.Open();
                    strSql = "UPDATE SvrParam SET [ServerName] = '" + cboServerName.Text.Trim() + "', [UserID] = '" + txtUserID.Text.Trim() + "' ,[Password] = '" + txtPassword.Text.Trim() + "' ,[AttachName] = '" + txtAttachName.Text.Trim() + "',[IntegratedSecurity] = " + chkWinAuthen.Checked + " ,[Owner] = '" + txtOwner.Text.Trim() + "'";

                    OleDbCommand cmOle = new OleDbCommand(strSql, cnOle);
                    intRowsAffected = cmOle.ExecuteNonQuery();
                    cnOle.Close();
                    cmOle.Dispose();
                    cnOle.Dispose();
                    MyModules.InitialiseEntireSystem();
                    MessageBox.Show("Update Successfull" + char.ConvertFromUtf32(13) + "Pls. Restart", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //InitialiseEntireSystem()
                    System.Environment.Exit(0);
                    //Me.Close()
                }

                if (intRowsAffected != 1)
                {
                    MessageBox.Show("Update Failed.", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #2
0
        private void cmdOk_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection cnSQL = new SqlConnection(MyModules.strConnect);
                SqlCommand    cmSQL = new SqlCommand("FetchUserAccessByPwd", cnSQL);
                // SqlDataReader drSQL;

                cnSQL.Open();


                byte[] arrayLogo = { 0 };
                //byte[] arrayLogo = null;

                if ((OwnerLogo.Image == null) == false)
                {
                    using (MemoryStream m = new MemoryStream())
                    {
                        OwnerLogo.Image.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);
                        //image.Save(m, image.RawFormat);

                        arrayLogo = m.ToArray();
                    }
                }

                cmSQL.CommandText = "UpdateSysParam4CoySetup";
                cmSQL.CommandType = CommandType.StoredProcedure;
                cmSQL.Parameters.AddWithValue("@NName", tName.Text);
                cmSQL.Parameters.AddWithValue("@Address", tAddress.Text);
                cmSQL.Parameters.AddWithValue("@Phone", tPhone.Text);
                cmSQL.Parameters.AddWithValue("@Email", temail.Text);
                cmSQL.Parameters.AddWithValue("@wwweb", tWebsite.Text);
                cmSQL.Parameters.AddWithValue("@logo", arrayLogo);
                cmSQL.Parameters.AddWithValue("@eDocPath", tDocFile.Text);
                cmSQL.Parameters.AddWithValue("@BackupPath", tBackupPath.Text);


                cmSQL.ExecuteNonQuery();
                //cmSQL.Connection.Close()
                cmSQL.Dispose();
                // cnSQL.Close()
                //cnSQL.Dispose()

                MyModules.InitialiseEntireSystem();

                MessageBox.Show("Pls. restart...", MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);

                System.Environment.Exit(1);

                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ooops! ERROR :" + char.ConvertFromUtf32(13) + ex, MyModules.strApptitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }