Monday, 17 February 2014

.net code generator

How to generate the classes with .net code generator?
Working with .net code generator in some easy steps:
Then install the software

Run the software:
Click on the button MS access 2003.
Click on the select The Database Button.

Select the Database.
After selection the tables will come in the grid in this way
Now save to any folder .

Then Press OK.



Now your class will be generated and ready to work with your application.
NOW THE QUESTION IS HOW?

This is my application screen:
Now if you want your class to work just add existing Item in this manner.

YOUR CLASS IS NOW READY.
Please use pk_ for Primary key in all tables and try to make them integer or auto number.
Pk_  is mandatory to generate properly all classes and its related function.

The below class is auto generated.
And it will going to generate for all your tables.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
using System.Data.OleDb;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace GeneratedModuleClasses
{
    class tblClassDetails
    {
        public System.Int32 pk_intRecId { get; set; }
        public System.Int32 intRoll { get; set; }
        public System.String strClass { get; set; }
        public System.String strDesc { get; set; }
        public System.DateTime strDate { get; set; }
        public System.Byte[] Image { get; set; }
        public System.String hyperLink { get; set; }
        public Boolean Create(String Conn)
        {
            try
            {
                DataTable DT = new DataTable();
                DT.Clear();
                OleDbDataAdapter ADP = new OleDbDataAdapter("Select * from tblClassDetails", Conn);
                ADP.Fill(DT);
                DataRow Row = DT.NewRow();
                Row["pk_intRecId"] = pk_intRecId;
                Row["intRoll"] = intRoll;
                Row["strClass"] = strClass;
                Row["strDesc"] = strDesc;
                Row["strDate"] = strDate;
                Row["Image"] = Image;
                Row["hyperLink"] = hyperLink;
                DT.Rows.Add(Row);
                System.Data.OleDb.OleDbCommandBuilder Comb = new System.Data.OleDb.OleDbCommandBuilder(ADP);
                ADP.Update(DT);
            }
            catch (Exception Ex)
            {
                System.Windows.Forms.MessageBox.Show(Ex.ToString());
                return false;
            } return true;
        }
        public static Boolean Edit(Int32 Pk_value, tblClassDetails EditObject, String Conn)
        {
            try
            {
                DataTable DT = new DataTable();
                DT.Clear();
                OleDbDataAdapter ADP = new OleDbDataAdapter("Select * from tblClassDetails where pk_intRecId=pk_intRecId", Conn);
                ADP.Fill(DT);
                if (DT.Rows.Count > 0)
                {
                    DataRow Row = DT.Rows[0];
                    Row["intRoll"] = EditObject.intRoll;
                    Row["strClass"] = EditObject.strClass;
                    Row["strDesc"] = EditObject.strDesc;
                    Row["strDate"] = EditObject.strDate;
                    Row["Image"] = EditObject.Image;
                    Row["hyperLink"] = EditObject.hyperLink;

                    System.Data.OleDb.OleDbCommandBuilder Comb = new System.Data.OleDb.OleDbCommandBuilder(ADP);
                    ADP.Update(DT);
                }
                else
                {
                    return false;
                }
            }
            catch (Exception Ex)
            {
                System.Windows.Forms.MessageBox.Show(Ex.ToString());
                return false;
            } return true;
        }
        public static List<tblClassDetails> GetnerateList(String Conn)
        {
            List<tblClassDetails> tblClassDetails = new List<tblClassDetails>();
            DataTable DT = new DataTable();
            DT.Clear();
            OleDbDataAdapter ADP = new OleDbDataAdapter("Select * from tblClassDetails", Conn);
            ADP.Fill(DT);
            foreach (DataRow Row in DT.Rows)
            {
                tblClassDetails ob = new tblClassDetails(); try
                {
                    ob.pk_intRecId = (System.Int32)Row["pk_intRecId"];
                }
                catch (Exception Ex) { } try
                {
                    ob.intRoll = (System.Int32)Row["intRoll"];
                }
                catch (Exception Ex) { } try
                {
                    ob.strClass = (System.String)Row["strClass"];
                }
                catch (Exception Ex) { } try
                {
                    ob.strDesc = (System.String)Row["strDesc"];
                }
                catch (Exception Ex) { } try
                {
                    ob.strDate = (System.DateTime)Row["strDate"];
                }
                catch (Exception Ex) { } try
                {
                    ob.Image = (System.Byte[])Row["Image"];
                }
                catch (Exception Ex) { } try
                {
                    ob.hyperLink = (System.String)Row["hyperLink"];
                }
                catch (Exception Ex) { } tblClassDetails.Add(ob);
            }
            return tblClassDetails;
        }
    }
}


DOWNLOAD THE CODE FROM HERE : https://drive.google.com/folderview?id=0B3IxuTdeDTLTN1puUXZnVk9MT0U&usp=sharing

I am creating an automated tool step by step.
I need proper feed back. Then those people who really need this kind of tool could send me their feedback.








Thursday, 9 January 2014

Extension Method in .net C#

Extension Method:

[There is no hole in my piggy bank but the money is still being inserted]
Extension Method is that kind of feature. Suppose we have a base class Employee.
This class should not be modified but I need to insert some methods in the Employee class.
No need for deriving the Employee class.
Now what is the solution?
The solution is Extension Method. Extension methods enable you to add methods to existing types without creating new derived type, recompiling or modifying the original type. Extension Methods are a special kind of static method.
Example:-
I will add the following method to String class in my program without derivation or modifying the String Class.
public static String GetFirstThreeCharacters(this String str)
        {

            if (str.Length < 3)
            {
                return str;
            }
            else
            {
                return str.Substring(0, 3);
            }
        }
Just  I have to add a static class like this .
public static class Extension
    {
        public static String GetFirstThreeCharacters(this String str)
        {

            if (str.Length < 3)
            {
                return str;
            }
            else
            {
                return str.Substring(0, 3);
            }
        }
    }

Then I can use the  GetFirstThreeCharacters in this manner in my Form Load Event.
   private void Form1_Load(object sender, EventArgs e)
        {
            String st = "My Name is Arindam";
            MessageBox.Show(st.GetFirstThreeCharacters());
        }    



Saturday, 21 December 2013

Cute Download Manager

Cute Download Manager

A free tool to download your files very quickly .It is not only free it is very useful .You can give your list of downloads here and download them sequentially one by one serially. Please select the location where you want to save the files. Multiple files in the same name will be overwritten.
A best thing of this software is that it is very light weighted and simple. If you are working in an office and you boss will kick you if you download something from office then just use Cute Download Manager. If you press the cross button then the download will run in background.
So just download and enjoy.




Wednesday, 18 December 2013

Entity Framework In Some Simple Steps

Entity Framework: Entity Framework is the Hot-Cake of Today. This enables programmer a Bug free database operation using simple some commands. It is a Strong framework and easy to implement.

Definition : Entity framework is an Object Relational Mapper (ORM).It is basically generates business objects and entities according to database tables and provides the process for CRUD  (Create Operation, Read Operation , Update Operation  And Also  Delete Operation. )


Above diagram explain the structure of Entity Framework in the respect of .net Technology.
Then it is clear that Entity Framework resides on or above the ADO.net. That means we are using the Entity Framework as usual but the difference is that we are not handling the connection the command directly.
Process of adding an EDMX file: [Note: To use entity framework you must install the .net Entity Framework.]
Click the Finish button to Finish the operation.
Here I have Entered “Contact.edmx “ .
I have the following Field in My Table Contact.
To Add
A single Contact:
TestEntities DB = new TestEntities();
Contact Con = new Contact();[This is the object of Contact Model]
Con.lname = txtLname.Text.ToString();
Con.fname = txtFname.Text.ToString();
Con.phone = txtPhone.Text.ToString();
Con.Roll = txtRoll.Text.ToString();
TestEntities OB = new TestEntities();[TestEntities Object Will Handle The DataBase Operation And Will Generated Automatrically in The EDMX file]
OB.Contacts.AddObject(Con);[Adding a New Object For New Contact]
OB.SaveChanges();[This will affect the Real DataBase ]

Try your Self to Delete, and Update Data
If you made any changes in the database  then just :-
Click the Update Model from DataBase
Changes will be made automatically.








Friday, 13 December 2013

Datatable To XML string in .net Using Gridview

I have Used a data Gridview to make my own  edited xml string which I will use in SQL server stored procedure as argument .
Now the code is here :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        DataTable DT = new DataTable();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            DT.Columns.Add("Name", typeof(string));
            DT.Columns.Add("Phone", typeof(string));
            DT.Columns.Add("Address", typeof(string));
            dataGridView1.DataSource = DT;
        }

        private void btnXml_Click(object sender, EventArgs e)
        {
            DataSet DS = new DataSet();
            DS.Tables.Add(DT);
            MessageBox.Show(DS.GetXml());
        }
    }
}




The result will be in XML

After this how you will use this XML string in SQL server that you can find in my article Using XML string in Stored Procedure(SP) in Sql Server


Thursday, 12 December 2013

Using XML string in Stored Procedure(SP) in Sql Server

--EASY  UNDER STANDING FOR XML TO TABLE CONVERSION
DECLARE @XMLSTRING VARCHAR(1000)
DECLARE @idoc INT
SET  @XMLSTRING='<TABLE><TR><NAME>ARINDAM</NAME><PHONE>9432987305</PHONE><ADDRESS>BARASAT</ADDRESS></TR><TR><NAME>ARINDAM</NAME><PHONE>9432987305</PHONE><ADDRESS>BARASAT</ADDRESS></TR><TR><NAME>RAJA</NAME> <PHONE>9432987306</PHONE> <ADDRESS>KOLKATA</ADDRESS></TR><TR><NAME>BABU</NAME> <PHONE>9831920688</PHONE> <ADDRESS>MADHYAMGRAM</ADDRESS></TR></TABLE>'
--IN THE ABOVE SECTION THIS IS THE XML STRING THAT YOU WANT TO CONVERT INTO TABLE
EXEC sp_xml_preparedocument @idoc OUTPUT,@XMLSTRING
SELECT * FROM OPENXML(@idoc,'/TABLE/TR',2)
WITH(NAME VARCHAR(50),PHONE VARCHAR(50),[ADDRESS] VARCHAR(150))
--NOW IF YOU WANT TO USE THIS TABLE INTO YOUR STORED PROCEDURE
--THEN DECLARE A TABLE VARIABLE IN THE FOLLOWING PROCESS
DECLARE @RESULT_TABLE TABLE(NAME VARCHAR(50),PHONE VARCHAR(50),[ADDRESS] VARCHAR(150))

INSERT  INTO @RESULT_TABLE(NAME,PHONE,[ADDRESS])
SELECT * FROM OPENXML(@idoc,'/TABLE/TR',2)
WITH(NAME VARCHAR(50),PHONE VARCHAR(50),[ADDRESS] VARCHAR(150))

SELECT * FROM  @RESULT_TABLE

Software Download Page

Find The Even Numbers In a Given Range In C Language

Simple C language Program To Find The Even Numbers In a Given Range

#include <stdio.h>/*Header File To Enable Standard Input Output functionality*/
int n;/*For Given Number*/
n=10;
int i=2;
while(i<=n)
{
if((i%2)==0)
{
printf("%d",i);
}
i++;
}