For smart Primates & ROBOTS (oh and ALIENS ).

Saturday, July 05, 2014

selected check box record from DataGridView c# winform

Suppose you have a DataGridView with the check box. Data are showing and you want to store only those data that's check boxes is selected, so what you will do? In simple you will use the loop which will retrieve all data from DataGridView from first row to last row and in that loop check the condition is which rows’s check box is selected.

It is a good way but not a smart way, imagine that there are 99999999 rows in the DataGridview and only 100 rows are selected.

Smart way is only create a loop which iterate only 100 times not for 99999999 times.

The Smart way is listed below:
1) Assume that we have the DataGridView with records and also have the check box and its name is "selectMe".

2) use listed below code to retrieve only selected checkboxes.

List<DataGridViewRow> list = dataGridView1.Rows.Cast<DataGridViewRow>().Where(eachrow => Convert.ToBoolean(eachrow.Cells["selectMe"].Value) == true).ToList();
foreach (var row in list) {
    MessageBox.Show(row.Cells["emp_id"].Value.ToString());
}
Share:

Thursday, May 22, 2014

Child form open and close problem in MDIForm C#

Child form open and close problem in MDIForm C#

===================================================================================
You have a menu item in MDIForm, after clicking on that a child form will be shown.
If you close the child form by clicking in cross "X" button which is on
right top corner, the child form will be closed.
And if you again click on MDIForm's menu item then the child form will not show.
This is because child form is disposed but that's variable is not null.
Listed below the code is the good example of that problem:
-----------------------------------------------------------------------------------
namespace MyProject
{
    public partial class AdminMDIParent : Form
    {
        Synopsis synopsis=null;
    }

    private void ShowNewForm(object sender, EventArgs e)
        {
            if (synopsis == null)
                {
                    synopsis = new Synopsis();
                    synopsis.MdiParent = this;

        }
              synopsis.Show();
              synopsis.Focus();
        }

}
-----------------------------------------------------------------------------------
The above code will not show the form in second time and rest. This is because the "synopsis"
is the object of "Synopsis" Form class. and this is the local variable of AdminMDIParent" class.
Only first time that code will work. So how to overcome this problem?
by the way, You will just use this code:
private void ShowNewForm(object sender, EventArgs e)
{
    synopsis = new Synopsis();
        synopsis.MdiParent = this;
    synopsis.Show();
        synopsis.Focus();
}
But the problem is when you use the above code and click again and again MDIForm's menu item without
closing child form; the multiple child form will be shown.
-----------------------------------------------------------------------------------

So to overcome this problem; we check its "visible" property as listed below.  Listed below code work fine.
private void ShowNewForm(object sender, EventArgs e)
{
    if (synopsis == null || synopsis.Visible==false)
    {
        synopsis = new Synopsis();
        synopsis.MdiParent = this;
    }
        synopsis.Show();
        synopsis.Focus();
}
-----------------------------------------------------------------------------------
Share:

bottom to top scroll in html

bottom to top scroll in html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
#back-to-top {
     position: fixed;
     bottom: 30px;
     top: 350px;
}
#back-to-top img{
    cursor:pointer;
}
</style>
<script language="javascript" src="jquery-1.10.2.js" type="text/javascript"></script>
</head>
<body>
<h1>Back To Top</h1>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<div style="height:1000px"></div>
<span id="back-to-top"><img id="bus" src='bus.gif'/></span>
</body>
<script type="text/javascript">
        $(document).ready(function () {
            $("#back-to-top").hide();
            $(window).scroll(function () {
                if ($(window).scrollTop() > 200) {
                    $('#back-to-top').fadeIn();
                } else {
                    $('#back-to-top').fadeOut();
                }
            });
              $('#back-to-top img').click(function () {   
               var body = $("body, html");
               body.animate({scrollTop :0}, '1500',function(){ });
            });
        });
    </script>
</html>
Share:

Page not found error 404 message customize in php


Page not found error 404 message customize in php.


1) if you have the local server "http://localhost" and you site root folder is "/test/myht/" then your url will be as:
"http://localhost:90/test/myht/"
create a file "404.html" or any other name. and paste the message as :
<h1> My custome error message for file not found.. file not found </h1>


2)Create ".htaccess" file and make the listed below entry

RewriteEngine on
ErrorDocument 404 /test/myht/404.html

if WAMP or LAMP is alreay "ON" the restart it.
open browser and try to url as:
http://localhost/test/myht/1.html

you will found your customization message as:

"My custome error message for file not found.. file not found".
Share:

Wednesday, May 07, 2014

Mouse Pointer info in java

Mouse Pointer info in java


Suppose you move your mouse pointer in entire desktop area and want to know the exact position of the mouse. then use listed below code. by this code you can get the real mouse position X and Y .



import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
class ShowMyMouse extends Thread {
    public ShowMyMouse(String str) {
        super(str);
    }
    public void run() {
        while(true){
        PointerInfo info = MouseInfo.getPointerInfo();
        Point pp=info.getLocation();
        System.out.println(pp);
            try {
                sleep((int)(Math.random() * 1000));
            } catch (InterruptedException e) {}
        }
       
    }
}
public class MyMouse{
    public static void main(String[] ss) {
        new ShowMyMouse("Mouse Pointer info").start();
    }
}
Share:

Zoom in out in html5 Canvas


This is the part of HTML5 Animation. if you want to ZOOM IN and ZOOM OUT in some intervals continuously. then you can use HTML5 canvas. Listed below the code that will ZOOM IN and ZOOM OUT to any image which you want.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="js/jquery-2.1.1.js"></script>
</head>
<body onLoad="drawCanvas();">
    <div>
        <canvas id="myCanvas" width="634" height="378">
            <p>Your browser doesn't support canvas.</p>
        </canvas>
    </div>
</body>
<script>
var surface; var happy; var x = 50; var y = 50; var scale = 0; var scaleDirection = 0.2;
function drawCanvas() {
    surface = document.getElementById("myCanvas");
    if (surface.getContext) {
        happy = new Image();
        happy.onload = loadingComplete;
        happy.src = "Voayger_voyageofdiscovery.jpg";
    }
}
function loadingComplete(e) {
    setInterval(loop, 125);
}
function loop() {
    var surfaceContext = surface.getContext('2d');
    surfaceContext.fillStyle = "rgb(255,255,255)";
    surfaceContext.fillRect(0, 0, surface.width, surface.height);
    // Save the current context
    surfaceContext.save();
    // Translate to the center point of our image
    surfaceContext.translate(x + happy.width * 0.5, y + happy.height * 0.5);
    // Perform the scale
    surfaceContext.scale(scale, scale);
    // Translate back to the top left of our image
    surfaceContext.translate(-happy.width * 0.5, -happy.height * 0.5);
    // Finally we draw the image
    surfaceContext.drawImage(happy, 0, 0);
    // And restore the context ready for the next loop
    surfaceContext.restore();
    // Animate our scale value
    scale += scaleDirection;
    if (scale < 0.2 || scale > 2) {
        scaleDirection = -scaleDirection;
    }
}
</script>
</body>
</html>
 



Share:

Fill and Empty SELECT box in jquery

Fill and Empty SELECT box in jquery




If you fill combobox from database in html and ajax jquery.
 ajax jquery transfer datas from database and you needed to put those datas into select box. Before this you need to clear existing datas from select combo box then you will use “empty()” and “apped()” to use fill the data. Use listed below codes to achieve that.
====================================================
<script src="jquery-1.6.3.min.js" language="javascript" type="text/javascript"></script>
<select name="myNum" Id="myNum" >
    <option value="0"><-- Select --></option>
</select>
<br/>
<input type="button" id="myadd" name="myadd" value="Add"/>
<script>
$(function(){
$("#myadd").click(function() {
        $('#myNum').empty();
        var i;
        for(i=0;i<=10;i++) {
               $('#myNum').append('<option value="' + i + '">' +i + '</option>');  
        }
    });
});
</script>
Share:

Incompatible type required: org.hibernate.Session found: javax.mail.Session Java mail struts and hibernate at the same time



      Incompatible type required: org.hibernate.Session found: javax.mail.Session Java mail struts and hibernate at the same time.



When you work with hibernate in java and want to use java email then you will face
the error, incompatible type required: org.hibernate.Session found: javax.mail.Session
This is because Session is in both package, so you needed to explicit declaration.
Use the listed below email code in java hibernate and you will not face the above error.
------------------------------------------------------

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import org.hibernate.Query;
public void sendEmailToAll(String toEmail){
        String ffrom = "POP@mail.com";
        String tto = toEmail;
        String ssubject = "My subject" + new Date();
        String msgText = "My text message ";
        Properties properties = new Properties();
        properties.put("mail.smtp.host", "my email ip");
        javax.mail.Session ss = javax.mail.Session.getDefaultInstance(properties,null);
        try {
            MimeMessage message = new MimeMessage(ss);
            message.setFrom(new InternetAddress(ffrom));
            message.setRecipient(Message.RecipientType.TO, new InternetAddress(tto));
            message.setSubject(ssubject);
            message.setSentDate(new Date());
            MimeBodyPart messagePart = new MimeBodyPart();
            messagePart.setText(msgText);
            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(messagePart);
            message.setContent(multipart);
            Transport.send(message);
        } catch (MessagingException e) {
            System.out.println(e.toString());
        }
    }
 





Share:

Convert English Words to Hindi Words


Convert English Words to Hindi Words



Some time you have make a code that will convert the English words to Hindi words. This is called 
transliteration as you seen in many news paper web sites. They provide a form to send comments in Hindi or English. Listed below the code that will transliterate English word to Hindi words.
I have used Google transliteration.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://www.google.com/jsapi"> </script>
<script type="text/javascript">
// Load the Google Transliteration API
google.load("elements", "1", {
            packages: "transliteration"
          });
function onLoad() {
    var options = {
        sourceLanguage:
                google.elements.transliteration.LanguageCode.ENGLISH,
            destinationLanguage:
                [google.elements.transliteration.LanguageCode.HINDI],
            shortcutKey: 'ctrl+g',
            transliterationEnabled: true
    };
    // Create an instance on TransliterationControl with the required options.
    var control =new google.elements.transliteration.TransliterationControl(options);
    // Enable transliteration in the textbox with id 'transliterateTextarea'.
        control.makeTransliteratable(['firstName']);
        control.makeTransliteratable(['lastName']);
      }
      google.setOnLoadCallback(onLoad);
      </script>
</head>
<body>
<input type="text" autocomplete="OFF" class="tb4" id="firstName" name="firstName">
<input type="text" autocomplete="OFF" class="tb4" id="lastName" name="lastName">
</body>
</html>
 










Share:

Saturday, February 01, 2014

About

I am Website Speed Optimization (also without speed plugins), Bug hunter, SEO, Malware, Virus remover specialist & Web Developer/ Desktop Software Developer.

MY SERVICES:
//▬// Website Speed Loading Optimization:
Shopify, LightSpeed, Magento, WordPress, Bigcommerce, Amazon AWS, Joomla,  WooCommerce, Neto E-Commerce, vBulletin, ModX, Adobe Muse, ASP.NET, ROR, JAVA, AMP.

***Get maximum Speed score of Shopify and BigCommerce site in Google Pagespeed Insights, when you hire me. Shopify and Bigcommerce site does not allow Leverage browser caching and Enable compression but I can reduce these issues as much as possible.

I do special care about below issues for home page(with little extra charges, because  it takes lot of time) if your theme/server support:
1- Eliminate render-blocking JavaScript and CSS in above-the-fold content
2- Enable compression.
3- Leverage browser caching.

***Also I am the person from among few peoples that know how to verify account for Orbital Chase Paymentech Payment Gateway.
Payment Gateway:
(Orbital Chase Paymentech, Authorize .Net, Stripe, Optimal Payment, PayPal, CCBill, CCAvenu, ConnectnPay, PayFlowPro, FastTransact, DHD Media.

==> SEO:
I do only WHITE HAT and Organic SEO with the latest changes in Google, Bing, Yahoo and Other search engines because I am not looking to get your website blacklisted in Google or any other search engine.

On Page optimization - Keywords analysis, Meta Tag Optimization, Meta Title/Description/keyword, Heading tags, Image Optimization, Alt, Title, Missing files, Xml Sitemap and many other possible things.

Off Page optimization - Directory Submission, Social Bookmarking, Blog/forum marketing, Link Building, Video marketing, Provide you emails so you can shoot emails and many other possible things.

Fix feed issues of Google Merchant.

==> Bug hunter, Malware and Virus Remover:
Bug hunter, Malware and viruses remover from any site.

==> Programming:
Core PHP with OOPs / Procedures / PDO, CakePHP, CodeIgniter.
JS, AJAX, jQuery, JSON, XML, XSLT ,MySql, MSSQL, MSAccess, Excel, CSV.
Android, QR/Bar code reader app, Torch app, ,Java, JSP, Servlet, Awt, Swing.
Classic ASP, ASP Dot Net MVC 5, WebForm, C# ,Winform, VB6.
Verified Person API, Facebook API, Google custom search API, Google News API.
Images to Video, Video Cutter, Video Watermark Remover, Video Watermark, Video fast loading, Image combiner, Images cropper, HTML/HTML5 to PDF converter, Keylogger.
Share:

Ads Inside Post

Powered by Blogger.

Archive