Click here to Skip to main content
15,887,910 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Collections;
using System .Collections.Generic ;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.OleDb;
using System.ComponentModel;

public partial class _Default : System.Web.UI.Page
{
    class Point  { double X, Y; }
    DataTable dt = new DataTable();
    int x, y;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string connectionString = "";
        if (FileUpload1.HasFile)
        {
            string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
            string fileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName);
            string fileLocation = Server.MapPath("~/App_Data/" + fileName);
            FileUpload1.SaveAs(fileLocation);
            if (fileExtension == ".xls")
            {
                connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
            }
            else if (fileExtension == ".xlsx")
            {
                connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
            }
            OleDbConnection con = new OleDbConnection(connectionString);
            OleDbCommand cmd = new OleDbCommand();
            ArrayList List = new ArrayList();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.Connection = con;
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(cmd);
            DataTable dtExcelRecords = new DataTable();
            con.Open();
            DataTable dtExcelSheetName = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            string getExcelSheetName = dtExcelSheetName.Rows[0]["Table_Name"].ToString();
            cmd.CommandText = "SELECT * FROM [" + getExcelSheetName + "]";
            dAdapter.SelectCommand = cmd;
            dAdapter.Fill(dtExcelRecords);
            if (Session["dtInSession"] != null)
            {
                dt = (DataTable)Session["dtInSession"];
            }
            for (int i = 0; i < dtExcelRecords.Rows.Count; i++)
            {
                //if you want to get the string
                DataRow thisRow = (DataRow)dtExcelRecords.Rows[i];
                x = Convert.ToInt32(thisRow["X"]);
                y = Convert.ToInt32(thisRow["Y"]);
                //double Length = Convert.ToDouble(Y);
                //double X1 = Convert.ToDouble(X);
                DataRow dr = dt.NewRow();
                polygonArea(x,y);
            }

        }
    }

    private Double polygonArea(int[] X,int[] Y)
    {
        Double area = 0.0;
        int j = X.Length - 1;
   for (int i=0; i < X.Length; i++) 
   {
    area=area+(X[j]+X[i]*(Y[j]-Y[i])); 
           j=i;    
   }
   area =area/ 2;
        if (area < 0)
        area = area * -1;
    return area;
}
    
}
Posted
Comments
Thanks7872 1-Oct-13 3:54am    
I recently provided you with some links. Refer that and try to understand how to work with function parameters. From your questions it is clear that you don't have idea about functions. You are just using code written by some one else. That won't help you much.
[no name] 1-Oct-13 3:57am    
k sir please give the links again
Thanks7872 1-Oct-13 3:59am    
http://www.codeproject.com/Questions/661418/No-overload-for-method-polygonArea-takes-0-argumen

And don't post unnecessary comments. Try comments only when necessary.
Thanks7872 1-Oct-13 4:03am    
Why you are posting comments over and over again? Don't you know how to surf internet? How to surf websites? I provided the link to your previous question,than also you are asking for links?
[no name] 1-Oct-13 3:56am    
please help me sir.,.

int is number but int[] is array of int logically you can not copy collection of integer to integer type.

then better you think any one solotion.
 
Share this answer
 
Hey there,

Its quite obvious that here:
C#
private Double polygonArea(int[] X,int[] Y)
expects both parameters as int[] (arrays of Int) but you supplied them as int, try passing int arrays to the function will solve your problem.

Azee...
 
Share this answer
 
Comments
[no name] 3-Oct-13 1:44am    
it infine array how to pass arrays of Int

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900