Tuesday, 18 November 2014

Extract source code (Java and XML) from Android APK File


Not getting any idea how to make good layout in Android activity or not getting how any application doing that things which you want in your project but you don’t know how to implement it in your APK File. So, I came here with new technology & new thinking which can make you crazy in android world.

Now time for backtracking…start your time to do hacking. Do you know you can get source code of Android APK file? Time to break the code..Let’s learn step by step.

In this tutorial we will learn how to convert android APK file into source code. Android .apk file is a compressed form of a file which contains Java classes (in .dex form), XML files and all necessary files. So first we will learn how to get Java source File from android apk using dex2jar and Java decompiler tools and then we will learn how to get XML source file using apktool and apkinstall tools.

To get the source code from APK file, we will need these tools:

1. dex2jar
2. java decompiler
3. apktool
4. apkinstall

Steps to get source:- 

Get Java files from APK:-

1. Rename the .apk file into .zip file (example SharedPr.apk into SharedPr.zip).
2. Extract SharedPr.zip file and copy classes.dex file from extracted folder.
3. Extract dex2jar.zip and paste classes.dex into dex2jar folder.
3. Open command prompt and change directory to the dex2jar folder. Then write dex2jar classes.dex and press enter. Now you will get classes.dex.dex2jar file in the same folder.

How To Get JAVA Code And XML Code From APK
Convert classes.dex to classes.dex.dex2jar
4. Now double click on jd-gui(Java decompiler) and click on open file. Then open classes.dex.dex2jar file from that folder. Now you will get class files and save all these class files (click on file then click “save all sources” in jd-gui) by src name.

How To Get JAVA Code And XML Code From APK
classes.dex.dex2jar will be in dex2jar folder


How To Get JAVA Code And XML Code From APK
Save All Java Files

Get XML files from APK:-

1. Extract apktool and apkinstall in a folder(Example : New Folder).
2. Put SharedPr.apk(your apk file) in same folder(i.e New Folder).

How To Get JAVA Code And XML Code From APK
Keep Android Apk File with apktool and apkinstall

3. Open the command prompt and go to the root directory(i.e New Folder).
4. Type command on command prompt: apktool d SharedPr.apk

How To Get JAVA Code And XML Code From APK
Get All XML Files In Resource Folder

5. This will generate a folder of name SharePr in current directory (here New Folder) and all XML files will be in res->layout folder.

How To Get JAVA Code And XML Code From APK
See All XML Files in new created Folder

Now you have source code. If you have any doubts please comment. Share and help others.

Saturday, 15 November 2014

how to set ten digit Seecrate code in c#

 private void seeCode()
        {
            label1.Text = "";
            DateTime dAdt = DateTime.Parse(dateTimePicker1.Text);
            Int32 fdd = dAdt.Day;//.ToString();
            Int32 fmm = dAdt.Month;//.ToString();
            int adm1 = Convert.ToInt32(fmm);
            Int32 fyyyy = dAdt.Year;//.ToString();
            string adm = fdd .ToString ()+ adm1.ToString() + fyyyy.ToString();

            MessageBox.Show(adm.ToString());
            textBox1.Text = adm.ToString();
            char[] chararray = this.textBox1.Text.ToCharArray();
            Array.Reverse(chararray);
            textBox2.Text = "";
            for (int i = 0; i <= chararray.Length - 1; i++)
            {
                textBox2.Text += chararray.GetValue(i);
            }
           // textBox2.Text = "";

            string sam = textBox2.Text;
           

            int num =Convert .ToInt32 (sam); //Convert.ToInt32(Math.Truncate(sma));//Convert.ToInt32(sma);
           
            string code;

            while (num != 0)
            {
                int r = num % 10;


                switch (r)
                {
                    case 1:
                        code = "One";
                        break;
                    case 2:
                        code = "Two";
                        break;
                    case 3:
                        code = "Three";
                        break;
                    case 4:
                        code = "Four";
                        break;
                    case 5:
                        code = "Five";
                        break;
                    case 6:
                        code = "Six";
                        break;
                    case 7:
                        code = "Seven";
                        break;
                    case 8:
                        code = "Eight";
                        break;
                    case 9:
                        code = "Nine";
                        break;
                 
                    default:
                        code = "Zero";
                        break;

                }

               
                label1.Text = label1.Text + code;
                int q = num / 10;

                num = q;

               
            }

        }

how to set back color in web form using c#.net windows applications

you can write this code on example.cs

initialize component

 Color color = ColorTranslator.FromHtml("#CFE0F7");
            this.BackColor = color;

Monday, 29 September 2014

Create a Windows Project in VS2008


Create a new project from File | New | Project. Provide a name instead of the default name (WindowsApplicaiton1). This is changed to ReportDesign for this tutorial as shown in the next figure. VS 2008 supports multi-version targeting. In the top right of the New Project window you can see that this report is targeted for the NET 2.0 Framework Version and can be published to a Net 2.0 web site.
Creating a Simple Report with Visual Studio 2008
Slightly enlarge the Form1. Drag and drop the Microsoft Report Viewer control shown in the next figure on to the form from the Toolbox.
Creating a Simple Report with Visual Studio 2008
This has the same functionality as the ReportViewer control in VS 2005 as shown in the next figure.
Creating a Simple Report with Visual Studio 2008
The control will be housed on the form as shown in the next figure. You can display the tasks needed to configure the Report Viewer by clicking on the Smart Task as shown in the same figure. The report will have all the functionalities like print, save to different formats, navigating through pages, etc.
Creating a Simple Report with Visual Studio 2008

Working with the Report Wizard

Now click on the Design a new report task. The opens the Report Wizard window as shown in the figure.
Creating a Simple Report with Visual Studio 2008
Read the instructions on this page carefully. Click on the Next Button. This displays the Data Source Configuration Wizard shown in the next figure.
Creating a Simple Report with Visual Studio 2008

Choosing a Data Source

The application can obtain data from these different resources. Click on the Database icon and then click on the Next button.
This displays the window where you need to select a connection to the data source. If there are existing connections you should be able to see them in the drop-down list box.
Creating a Simple Report with Visual Studio 2008

Making a Connection to Get Data

Click on the New Connection button. This brings up the Add Connection window showing a default connection to a Microsoft SQL Server Compact 3.5.NET Framework Data Provider. It also shows the location to be My Computer.
Creating a Simple Report with Visual Studio 2008
This source can be changed by clicking on the Change... button. This will bring up the Change Data Source window where you can choose.
Creating a Simple Report with Visual Studio 2008
As found in this version you have the following options:
  • Microsoft SQL Server option lets you connect to SQL 2000 or 2005 using the .NET Framework Data Provider for SQL Server.
  • Microsoft SQL Server Compact 3.5 lets you connect to a database file.
  • Microsoft SQL Server Database File lets you connect to a Local Microsoft SQL Server Instance including a SQL Express. Although it is not explicitly stated what these versions are.
For this tutorial the Compact 3.5 will be used (also uses a .NET Framework Data Provider of Compact 3.5).
Click on the OK button in the Change Data Source window.
VS 2008 installation also installs a database file on the computer for the SQL Server Compact 3.5.
Click on Browse button (you could also create one if you like, herein it will be browsed). This brings up theSelect SQL Server Compact 3.5 Database File window with the default location where the database file is parked as shown in the next figure.
Creating a Simple Report with Visual Studio 2008
Click on the Northwind icon in the window and click on the Open button. This updates the Add Connection window with this information as shown in the next figure.
You may test the connection by hitting the Test Connection button which should display a successful outcome as shown in the next figure. There is no need for a password as you are the owner.
Creating a Simple Report with Visual Studio 2008
Click OK twice and this will take you back to the Data Source Configuration Wizard updating the connection information which you may review as shown in the next figure.
Creating a Simple Report with Visual Studio 2008
Click on the Next button. This brings up the Microsoft Visual Studio message window giving you the option to bring this data source to your project.
Creating a Simple Report with Visual Studio 2008



(For more resources on Microsoft, see here.)
Click on the Yes button. This adds the Data Source to your project and it will now appear in the ReportDesign project folder as Northwind.sdf. The Save the Connection String to the Application Configuration File section of the wizard also pops-up as shown.
Creating a Simple Report with Visual Studio 2008
Accept the default and click on the Next button. The window retrieves the database objects as shown in the next figure where the Tables object is shown expanded.
Creating a Simple Report with Visual Studio 2008
To keep matters simple the Customers table data will be used in fashioning this report. Place a check mark for the Customers and expand the Customers table node as shown. Also choose the columns that should appear in the report by choosing them with check marks as shown.
Creating a Simple Report with Visual Studio 2008

Designing the Report

When you click on the Finish button you will add a NorthwindDataSet to the Project. Click on the Finish button. This adds a NorthwindDataSet.xsd file to the Project and a new wizard, Report Wizard pops-up requiring you to select the data source. It will display the columns you selected in the earlier step.
Creating a Simple Report with Visual Studio 2008
You get a chance to add another data source at this point should you choose to do so. Here only the data chosen earlier will be used. Click on the Next button.

Choosing a Report Type

This opens the window where you may choose the type of report. Tabular is appropriate for the selected data.
Creating a Simple Report with Visual Studio 2008

Grouping the Data

Click on the Next button. In the window that opens you may choose to group the data in any fashion you think appropriate. In this tutorial it will be grouped under 'City' field. For designing meaningful reports it will be necessary to know the data well. The grouping is as shown in the next figure although this may not be the best.
Creating a Simple Report with Visual Studio 2008

(For more resources on Microsoft, see here.)

Choosing Layout of Data

Click on the Next button to display the window where you may choose a table layout. A stepped layout is chosen as shown.
Creating a Simple Report with Visual Studio 2008

Choosing a Report Style

Click on the Next button to display the style for the report one may choose. Here the 'Corporate' style is chosen as shown.
Creating a Simple Report with Visual Studio 2008
Clicking on the Next button brings up the summary page for the report as shown.
Creating a Simple Report with Visual Studio 2008
Click on the Finish button. After a while the the report design shows up as Report1.rdlc[Design] as shown in the next figure.
Creating a Simple Report with Visual Studio 2008
The Report title is Report1 which can be changed by clicking in this field and typing it over (in the last figure you see this has been changed). It may also be suitably positioned and formatted. The Page level is shown by =Fileds!Customer ID.Value and the grouping by city by =Fields!City.Value under each page.
Now the Project should contain the items shown in the next figure.
Creating a Simple Report with Visual Studio 2008
Further design changes can be made to the report as needed.

Displaying the Report

Build the project, ReportDesign and you can see the report by clicking on the green arrow in the toolbar menu. Presently you will see an empty report. The design of the report and the Data Source were independently designed although it appeared like a continuous process. You still need to add a data source to the report.

Adding the Data Source to the Report

Click on the ReportViewer's Smart task and choose the default displayed.
Creating a Simple Report with Visual Studio 2008
Click on Choose Data Sources which displays the next window shown.
Creating a Simple Report with Visual Studio 2008
Click the OK button on this screen. Now build the project and run the form with the green arrow menu item.
This brings up the form and after a little processing the report gets displayed.
Creating a Simple Report with Visual Studio 2008

Date selections Max in C#

dtpFrTotsale.MaxDate = DateTime.Today;
 dtpToTotsale.MaxDate = DateTime.Today;

Thursday, 18 September 2014

how to show hiden files in Pendrive using Cmd prompt


please chose your pen drive path

ex: G:

Write this code


G:\> attrib -h -s -r /s /d *.*     then press enter

Friday, 5 September 2014

how to print page footer last page only using CrystalReport

Step 1:
Select page footer item  (Right Click)
step 2:
Select format object or Format Multiple Object 
now to open the screen
Please tick Suppress Check box and click X+2  ( marked column )






Step 3:
Put this code in X+2 
 PageNumber <> TotalPageCount
and click Save and Close





thanks 





Saturday, 30 August 2014

how to change password in C#

private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtCurPass.Text != "")
            {
                if (Password() != txtCurPass.Text)
                {
                    MessageBox.Show("Incorrect Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtCurPass.Focus();
                    txtCurPass.SelectAll();
                    return;
                }
                if (txtNewPass.Text.Trim() != "")
                {
                    if (txtConPass.Text.Trim() != "")
                    {
                        if (txtNewPass.Text.Trim() == txtConPass.Text.Trim())
                        {
                            string str = "Update T_LoginMain Set pw='" + txtConPass.Text.Trim() + "' Where username=" + "'" + txtUsername.Text.Trim() + "'";
                            con = new OleDbConnection(dbCon());
                            OleDbCommand cmd = new OleDbCommand(str, con);
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                            MessageBox.Show("Password Changed", "Changed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            TextClear();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("New Password and Confirm Password must be same", "Same Password?", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtNewPass.Focus();
                            txtNewPass.SelectAll();
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Enter Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtConPass.Focus();
                        txtConPass.Focus();
                        txtConPass.SelectAll();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Enter Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNewPass.Focus();
                    txtNewPass.SelectAll();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Enter Current Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtCurPass.Focus();
                txtCurPass.SelectAll();
                return;

            }

        }

how to create new user account in C#

    if (txtUsername.Text.TrimStart () != "")
            {
                if (txtNewPass.Text.TrimStart () != "")
                {
                    if (txtConPass.Text.TrimStart () != "")
                    {
                        if (txtNewPass.Text.TrimStart () == txtConPass.Text.TrimStart ())
                        {
                            string str = "Insert into T_LoginMain(username,pw,usertype)Values('" + txtUsername.Text.TrimStart () + "','" + txtConPass.Text.TrimStart () + "','" + cbxUserType.Text.TrimStart () + "')";
                            con = new OleDbConnection(dbCon());
                            OleDbCommand cmd = new OleDbCommand(str, con);
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                            MessageBox.Show("User Created", "Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            TextClear();
                        }
                        else
                        {
                            MessageBox.Show("New Password and Confirm Password must be same", "Same Password?", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtNewPass.Focus();
                            txtNewPass.SelectAll();
                            return;
                        }

                    }
                    else
                    {
                        MessageBox.Show("Enter Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtConPass.Focus();
                        txtConPass.SelectAll();
                        return;
                    }

                }
                else
                {
                    MessageBox.Show("Enter Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNewPass.Focus();
                    txtNewPass.SelectAll();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Enter Username", "Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUsername.Focus();
                txtUsername.SelectAll();
                return;
            }

how to get mac address in C#.Net

  public static string GetMacAddress()
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            String sMacAddress = string.Empty;
            foreach (NetworkInterface adapter in nics)
            {
                if (sMacAddress == String.Empty)// only return MAC Address from first card
                {
                    IPInterfaceProperties properties = adapter.GetIPProperties();
                    sMacAddress = adapter.GetPhysicalAddress().ToString();
                }
            } return sMacAddress;

        }

Wednesday, 20 August 2014

How to select credit,Debit and Balance Code for Crystal report viewer using formula feild





write this code in formula feild and Select Basic Syntax



//// working ==================


Global Bal As number
if {T_Statement.Debit}=0 then
Bal={T_Statement.Credit}+Bal
else
Bal=Bal-{T_Statement.Debit}
end if
formula = Bal



Tuesday, 19 August 2014

Mdi forms in C#

 FrmRptStatement obRptStatement = new FrmRptStatement();
            obRptStatement.MdiParent = this;
            obRptStatement.Show();

how to hide a form in mdiparent in C#

form closing event write this


            e.Cancel = true;
            this.Hide();
  

Crystal Report show

    // Report Source
            ds.Clear();
            string str1 = "Select * from T_ReportTotal Where ID=1";
            OleDbDataAdapter ada = new OleDbDataAdapter(str1, con);
            ada.Fill(ds, "T_ReportTotal");
            cr1.Refresh();
            cr1.SetDataSource(ds);
            progressBar1.SendToBack();
            progressBar1.Visible = false;
            crystalReportViewer1.Visible = true;
            crystalReportViewer1.ReportSource = cr1;
            cr1.SetParameterValue("From", dtpFrTotsale.Text);
            cr1.SetParameterValue("To", dtpToTotsale.Text);
            Cursor.Current = Cursors.Default;
            crystalReportViewer1.Cursor = Cursors.Default;
            con.Close();

Thursday, 14 August 2014

how to restrict minimum char in C#

   private void txtInvoiceNo_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (txtInvoiceNo.Text.Length > 29 && e.KeyChar != 8)
            {
                LOCK(sender, e);
                MessageBox.Show("30 Charactors Allowed", "Exceeding 30 Charactors");
            }
        }

how to remove datagridview rows in C#

  private void dgvPurchase_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                int selRow = dgvPurchase.Rows.GetFirstRow(DataGridViewElementStates.Selected);
                {
                    if (selRow > -1)
                    {
                        cbxMname.Text = dgvPurchase[1, selRow].Value.ToString();
                        cbxItemName.Text = dgvPurchase[2, selRow].Value.ToString();
                        cbxBatchNo .Text = dgvPurchase[3, selRow].Value.ToString();
                        dtpExpdate.Text = dgvPurchase[4, selRow].Value.ToString();
                        txtNosPBox .Text = dgvPurchase[5, selRow].Value.ToString();
                        txtTotBox.Text = dgvPurchase[6, selRow].Value.ToString();
                        txtFreeQty.Text = dgvPurchase[7, selRow].Value.ToString();
                        txtNetQty.Text = dgvPurchase[8, selRow].Value.ToString();
                        txtMrp.Text = dgvPurchase[9, selRow].Value.ToString();
                        txtDiscoPers.Text = dgvPurchase[10, selRow].Value.ToString();
                     
                        txtShopMorgin .Text = dgvPurchase[17, selRow].Value.ToString();
                        txtNetRate .Text = dgvPurchase[16, selRow].Value.ToString();
                        txtMarginamt.Text = dgvPurchase[18, selRow].Value.ToString();
                        txtBasicRate .Text = dgvPurchase[12, selRow].Value.ToString();
                        txtVatPers .Text = dgvPurchase[13, selRow].Value.ToString();
                        //txtPurTotAmount.Text = dgvPurchase[11, selRow].Value.ToString();
                        txtnetwp.Text = dgvPurchase[22, selRow].Value.ToString();
                        txtmrpwpval.Text = dgvPurchase[21, selRow].Value.ToString();
                       
                        cbxUnits.Text = dgvPurchase[25, selRow].Value.ToString();
                        txtMaxQty.Text = dgvPurchase[23, selRow].Value.ToString();
                        txtMinQty.Text = dgvPurchase[24, selRow].Value.ToString();
                        txttotqty.Text = dgvPurchase[26, selRow].Value.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Uncommitted Row Selectin", "Invalid Selection", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                dgvPurchase.ClearSelection();
            }
        }

how to load DB datas to Datagridview in C#

 private void SeltoDG()
        {
            try
            {
                ClsBEPurDetails bedg = new ClsBEPurDetails();

                string str = "Select SlNo,Mname,ItemName,BatchNo,ExpDate,ItemsPbox,TotalBox,FreeQty,NetQty,MRP,DiscPers,DiscAmt,Basicrate,VatPers,VatAmt,TransPers,Netcost,SellPrice,SellingMargin,SellingAmt,DummyRate,MRPValue,WPValue,MaxQty,MinQty,Units,Strength,AgsSubNet,Claim from T_PurDetails Where ID=" + cbxID.Text;
                dgvPurchase.Rows.Clear();
                con = new OleDbConnection(dbCon());
                OleDbCommand cmd = new OleDbCommand(str, con);
                con.Open();
                OleDbDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    bedg.SlNo = dr.GetValue(0).ToString();
                    bedg.PrType = dr.GetValue(1).ToString();
                    bedg.ItemName = dr.GetValue(2).ToString();
                    bedg.BatchNo = dr.GetValue(3).ToString();
                    bedg.ExpDte = dr.GetValue(4).ToString();
                    bedg.Nounit = dr.GetValue(5).ToString();
                    bedg.TotUnit = dr.GetValue(6).ToString();
                    bedg.FreeQty = dr.GetValue(7).ToString();
                    bedg.NetQty = dr.GetValue(8).ToString();
                    bedg.Mrp = dr.GetValue(9).ToString();
                    bedg.DiscPers = dr.GetValue(10).ToString();
                    bedg.Discamt = dr.GetValue(11).ToString();

                    bedg.BasicRate = dr.GetValue(12).ToString();
                    bedg.VatPers = dr.GetValue(13).ToString();
                    bedg.VatAmt = dr.GetValue(14).ToString();
                    bedg.TransPers = dr.GetValue(15).ToString();
                    bedg.Netcost = dr.GetValue(16).ToString();
                    bedg.SellingPers = dr.GetValue(17).ToString();
                    bedg.SellingMargin = dr.GetValue(18).ToString();
                    bedg.SellingAmt = dr.GetValue(19).ToString();
                    bedg.DummyRate = dr.GetValue(20).ToString();
                    bedg.MrpValue = dr.GetValue(21).ToString();
                    bedg.WpValue = dr.GetValue(22).ToString();
                    bedg.Maxqty = dr.GetValue(23).ToString();
                    bedg.Minqty = dr.GetValue(24).ToString();
                    bedg.Units = dr.GetValue(25).ToString();
                    bedg.Tstrength = dr.GetValue(26).ToString();
                    //,bedg .Netcost ,bedg .DiscPers ,bedg .DiscAmtt ,bedg .TransPers
                    bedg.AgsSubNetTot = dr.GetValue(27).ToString();
                    bedg.ClaimAmount = dr.GetValue(28).ToString();
                    string[] strDg = new string[] { bedg.SlNo, bedg.PrType, bedg.ItemName, bedg.BatchNo, bedg.ExpDte, bedg.Nounit, bedg.TotUnit, bedg.FreeQty, bedg.NetQty, bedg.Mrp, bedg.DiscPers, bedg.Discamt, bedg.BasicRate, bedg.VatPers, bedg.VatAmt, bedg.TransPers, bedg.Netcost, bedg.SellingPers, bedg.SellingMargin, bedg.SellingAmt, bedg.DummyRate, bedg.MrpValue, bedg.WpValue, bedg.Maxqty, bedg.Minqty, bedg.Units, bedg.Tstrength,bedg.AgsSubNetTot ,bedg.ClaimAmount };
                    dgvPurchase.Rows.Add(strDg);
                }
                dr.Close();
                con.Close();
            }
            catch
            {

            }
        }

Combobox Styles in C#

 cbxID.DropDownStyle = ComboBoxStyle.Simple;
            cbxSupName.DropDownStyle = ComboBoxStyle.DropDown;
            cbxBatchNo.DropDownStyle = ComboBoxStyle.Simple;

how can i Load items in Combobox or textbox in C#.NET

private void UserLoad()
        {
            string str = "Select username from T_CurUserPass";
            con = new OleDbConnection(dbCon());
            OleDbCommand cmd = new OleDbCommand(str, con);
            con.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                txtEditby.Text = dr.GetValue(0).ToString();
            }
            dr.Close();
            con.Close();
        }

Default DB Path Connections

  private string dbCon()
        {
            StreamReader sr = File.OpenText("dbCon.txt");
            string conread = sr.ReadLine();
            return conread;
        }

3 tire



3 - tire code for Save

variable Declarations

  ClsBEPurDetails be = new ClsBEPurDetails();
                                clsBEPurEntryStockUpdate beStock = new clsBEPurEntryStockUpdate();
                                clsDAPurEntry da = new clsDAPurEntry();

                                rc = dgvPurchase.Rows.Count - 1;
                                be.PurNo = cbxID.Text;
                                be.SupName = cbxSupName.Text;
                                for (int i = 0; i < rc; i++)
                                {
                                    be.PurNo = cbxID.Text;
                                    be.SlNo = dgvPurchase[0, i].Value.ToString();
                                    be.PrType = dgvPurchase[1, i].Value.ToString();
                                    be.ItemName = dgvPurchase[2, i].Value.ToString();
                                    be.BatchNo = dgvPurchase[3, i].Value.ToString();
                                    be.ExpDte = dgvPurchase[4, i].Value.ToString();
                                    be.Nounit = dgvPurchase[5, i].Value.ToString();
                                    be.TotUnit = dgvPurchase[6, i].Value.ToString();
                                    be.FreeQty = dgvPurchase[7, i].Value.ToString();
                                    be.NetQty = dgvPurchase[8, i].Value.ToString();
                                    be.Mrp = dgvPurchase[9, i].Value.ToString();
                                    be.DiscPers = dgvPurchase[10, i].Value.ToString();
                                    be.Discamt = dgvPurchase[11, i].Value.ToString();
                                    be.BasicRate = dgvPurchase[12, i].Value.ToString();
                                    be.VatPers = dgvPurchase[13, i].Value.ToString();
                                    be.VatAmt = dgvPurchase[14, i].Value.ToString();
                                    be.TransPers = dgvPurchase[15, i].Value.ToString();
                                    be.Netcost = dgvPurchase[16, i].Value.ToString();
                                    be.SellingPers = dgvPurchase[17, i].Value.ToString();
                                    be.SellingMargin = dgvPurchase[18, i].Value.ToString();
                                    be.SellingAmt = dgvPurchase[19, i].Value.ToString();
                                    be.DummyRate = dgvPurchase[20, i].Value.ToString();
                                    be.MrpValue = dgvPurchase[21, i].Value.ToString();
                                    be.WpValue = dgvPurchase[22, i].Value.ToString();
                                    be.Maxqty = dgvPurchase[23, i].Value.ToString();
                                    be.Minqty = dgvPurchase[24, i].Value.ToString();
                                    be.Units = dgvPurchase[25, i].Value.ToString();
                                    be.Tstrength = dgvPurchase[26, i].Value.ToString();
                                    be.AgsSubNetTot = dgvPurchase[27, i].Value.ToString();
                                    be.ClaimAmount = dgvPurchase[28, i].Value.ToString();

BAL CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessEntities
{
    public class ClsBEPurDetails
    {
        private string _purNo;
        private string _supName;
        private string _SlNo;       
        private string _prType;      
        private string _itemName;
        private string _batchNo;       
        private string _expDte;
        private string _nounit;
        private string _totUnit;
        private string _freeQty;
        private string _netQty;
        private string _mrp;
        private string _discPers;
        private string _discamt;     
        private string _basicRate;    
        private string _VatPers;      
        private string _vatAmt;
        private string _TransPers;
        private string _netcost;       
        private string _sellingPers;       
        private string _sellingMargin;
        private string _sellingAmt;       
        private string _dummyRate;
        private string _mrpValue;
        private string _wpValue;       
        private string _Tstrength;       
        private string _Units;       
        private string _maxqty;        
        private string _minqty;
        private string _entryDate;
        private string _bV;
        private string _agsSubNetTot;
        private string _claimAmount;

        public string ClaimAmount
        {
            get { return _claimAmount; }
            set { _claimAmount = value; }
        }

        public string AgsSubNetTot
        {
            get { return _agsSubNetTot; }
            set { _agsSubNetTot = value; }
        }

        public string BV
        {
            get { return _bV; }
            set { _bV = value; }
        }

       

        public string PurNo
        {
            get { return _purNo; }
            set { _purNo = value; }
        }
        public string SupName
        {
            get { return _supName; }
            set { _supName = value; }
        }
        public string SlNo
        {
            get { return _SlNo; }
            set { _SlNo = value; }
        }
        public string PrType
        {
            get { return _prType; }
            set { _prType = value; }
        }
        public string ItemName
        {
            get { return _itemName; }
            set { _itemName = value; }
        }
        public string BatchNo
        {
            get { return _batchNo; }
            set { _batchNo = value; }
        }
        public string ExpDte
        {
            get { return _expDte; }
            set { _expDte = value; }
        }
        public string Nounit
        {
            get { return _nounit; }
            set { _nounit = value; }
        }
        public string TotUnit
        {
            get { return _totUnit; }
            set { _totUnit = value; }
        }
        public string FreeQty
        {
            get { return _freeQty; }
            set { _freeQty = value; }
        }
        public string NetQty
        {
            get { return _netQty; }
            set { _netQty = value; }
        }
        public string Mrp
        {
            get { return _mrp; }
            set { _mrp = value; }
        }

        public string DiscPers
        {
            get { return _discPers; }
            set { _discPers = value; }
        }
        public string Discamt
        {
            get { return _discamt; }
            set { _discamt = value; }
        }
        public string BasicRate
        {
            get { return _basicRate; }
            set { _basicRate = value; }
        }



        public string VatPers
        {
            get { return _VatPers; }
            set { _VatPers = value; }
        }
        public string VatAmt
        {
            get { return _vatAmt; }
            set { _vatAmt = value; }
        }
        public string TransPers
        {
            get { return _TransPers; }
            set { _TransPers = value; }
        }
        public string Netcost
        {
            get { return _netcost; }
            set { _netcost = value; }
        }
        public string SellingPers
        {
            get { return _sellingPers; }
            set { _sellingPers = value; }
        }
        public string SellingMargin
        {
            get { return _sellingMargin; }
            set { _sellingMargin = value; }
        }
        public string SellingAmt
        {
            get { return _sellingAmt; }
            set { _sellingAmt = value; }
        }
        public string DummyRate
        {
            get { return _dummyRate; }
            set { _dummyRate = value; }
        }
        public string MrpValue
        {
            get { return _mrpValue; }
            set { _mrpValue = value; }
        }
        public string WpValue
        {
            get { return _wpValue; }
            set { _wpValue = value; }
        }
        public string Tstrength
        {
            get { return _Tstrength; }
            set { _Tstrength = value; }
        }
        public string Units
        {
            get { return _Units; }
            set { _Units = value; }
        }
        public string Maxqty
        {
            get { return _maxqty; }
            set { _maxqty = value; }
        }
        public string Minqty
        {
            get { return _minqty; }
            set { _minqty = value; }
        }
        public string EntryDate
        {
            get { return _entryDate; }
            set { _entryDate = value; }
        }

    }
}

DAL : CODE   

   public void DAPurDatagridIntoDB(ClsBEPurDetails be)
    {
        string str = "Insert into T_PurDetails(ID,IDs,SupName,SlNo,Mname,ItemName,BatchNo,ExpDate,ItemsPbox,TotalBox,FreeQty,NetQty,MRP,DiscPers,DiscAmt,Basicrate,VatPers,VatAmt,TransPers,Netcost,SellPrice,SellingMargin,SellingAmt,DummyRate,MRPValue,WPValue,MaxQty,MinQty,Units,Strength,AgsSubNet,Claim)values('" + be.PurNo + "','" + be.PurNo + "','" + be.SupName + "','" + be.SlNo + "','" + be.PrType + "','" + be.ItemName + "','" + be.BatchNo + "','" + be.ExpDte + "','" + be.Nounit + "','" + be.TotUnit + "','" + be.FreeQty + "','" + be.NetQty + "','" + be.Mrp + "','" + be.DiscPers + "','" + be.Discamt + "','" + be.BasicRate + "','" + be.VatPers + "','" + be.VatAmt + "','" + be.TransPers + "','" + be.Netcost + "','" + be.SellingPers + "','" + be.SellingMargin + "','" + be.SellingAmt + "','" + be.DummyRate + "','" + be.MrpValue + "','" + be.WpValue + "','" + be.Maxqty + "','" + be.Minqty + "','" + be.Units + "','" + be.Tstrength + "','"+be.AgsSubNetTot +"','"+be.ClaimAmount+"')";
         con = new OleDbConnection(dbCon());
            OleDbCommand cmd = new OleDbCommand(str, con);
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
        }

// save 
                                        da.DAPurDatagridIntoDB(be);//Purchase item insert