Tuesday, 19 February 2013

andriod tutorial with eclipse

Installation andriod

Features of andriod




 Features of Andriod 4.0


Features of Andriod 4.2 and techniques to develop Software .
Platform Version
API Level
VERSION_CODE
Notes
9
8
7
6
5
4
3
2
Android 1.0
1






Executing Andriod App in Visual Studio 2010

Sunday, 17 February 2013

CSV File Upload

//Here txtCSVFilePath is the textbox

//Checking the wheather given path is correct or not
            if (txtCSVFilePath.TextLength == 0 || File.Exists(txtCSVFilePath.Text) == false)
            {
                MessageBox.Show("Please browse valid file");
                return;
            }
            FileInfo fiCSVFile = new FileInfo(txtCSVFilePath.Text);
         
//checking given file is csv file or not
            if (fiCSVFile.Extension.ToLower() != ".csv")
            {
                MessageBox.Show("Please browse valid CSV file");
                return;
            }
//DGAData is a class that contain some variables
            DGAData objDGAData;
            int intLine = 0;
            StringBuilder sbLineMessage = new StringBuilder();
            using (StreamReader sr = new StreamReader(fiCSVFile.FullName))
            {
//Checking given file consists records or not
                while (sr.Peek() > 0)
                {
                    intLine++;
                    objDGAData = new DGAData();
                    try
                    {
//Storing one line of csv file in strArrLine String Array
                        String[] strArrLine = sr.ReadLine().Split(',');
                        objDGAData.dateAdded = Convert.ToDateTime(strArrLine[0]);
                        objDGAData.H2 = int.Parse(strArrLine[1]);
                        objDGAData.CH4 = int.Parse(strArrLine[2]);
                        objDGAData.C2H2 = int.Parse(strArrLine[3]);
                        objDGAData.C2H4 = int.Parse(strArrLine[4]);
                        objDGAData.C2H6 = int.Parse(strArrLine[5]);
                        objDGAData.CO = int.Parse(strArrLine[6]);
                        objDGAData.CO2 = int.Parse(strArrLine[7]);
                        objDGAData.O2 = int.Parse(strArrLine[8]);
                        objDGAData.N2 = int.Parse(strArrLine[9]);
                        objDGAData.TDCG = objDGAData.H2 + objDGAData.CH4 + objDGAData.C2H6 + objDGAData.C2H4 + objDGAData.C2H2 + objDGAData.CO;
                        //objDGAData.TDCG = int.Parse(strArrLine[10]);
                        objDGAData.EquipID =Convert.ToInt32(cmbxCsvEquip.SelectedValue);          
}        
                       int id=DGADataServices.AddNew(objDGAData);

Wednesday, 23 January 2013

string array sorting along with diifernt values like l15,l17,l2,r3




//string array sorting along with diifernt values like l15,l17,l2,r3

//here xlabels contain the list of varibles

  Array.Sort(xlabels, new AlphanumComparatorFast());


public class AlphanumComparatorFast : IComparer
    {
        public int Compare(object x, object y)
        {
            string s1 = x as string;
            if (s1 == null)
            {
                return 0;
            }
            string s2 = y as string;
            if (s2 == null)
            {
                return 0;
            }

            int len1 = s1.Length;
            int len2 = s2.Length;
            int marker1 = 0;
            int marker2 = 0;

            // Walk through two the strings with two markers.
            while (marker1 < len1 && marker2 < len2)
            {
                char ch1 = s1[marker1];
                char ch2 = s2[marker2];

                // Some buffers we can build up characters in for each chunk.
                char[] space1 = new char[len1];
                int loc1 = 0;
                char[] space2 = new char[len2];
                int loc2 = 0;

                // Walk through all following characters that are digits or
                // characters in BOTH strings starting at the appropriate marker.
                // Collect char arrays.
                do
                {
                    space1[loc1++] = ch1;
                    marker1++;

                    if (marker1 < len1)
                    {
                        ch1 = s1[marker1];
                    }
                    else
                    {
                        break;
                    }
                } while (char.IsDigit(ch1) == char.IsDigit(space1[0]));

                do
                {
                    space2[loc2++] = ch2;
                    marker2++;

                    if (marker2 < len2)
                    {
                        ch2 = s2[marker2];
                    }
                    else
                    {
                        break;
                    }
                } while (char.IsDigit(ch2) == char.IsDigit(space2[0]));

                // If we have collected numbers, compare them numerically.
                // Otherwise, if we have strings, compare them alphabetically.
                string str1 = new string(space1);
                string str2 = new string(space2);

                int result;

                if (char.IsDigit(space1[0]) && char.IsDigit(space2[0]))
                {
                    int thisNumericChunk = int.Parse(str1);
                    int thatNumericChunk = int.Parse(str2);
                    result = thisNumericChunk.CompareTo(thatNumericChunk);
                }
                else
                {
                    result = str1.CompareTo(str2);
                }

                if (result != 0)
                {
                    return result;
                }
            }
            return len1 - len2;
        }
    }

Friday, 4 January 2013

list of products add once stored procedure

/*
list of products add once
ProductID = 106,107,109,210
*/

Create PROCEDURE [dbo].[Nop_Product](Procedure name)
@ProductID varchar(max),
@UserName varchar(max)
as
begin
declare @CustomerID int
select @CustomerID=CustomerID from [Nop_Customer] where Username=@UserName
declare @CsvIds varchar(max)
declare @index int=0
set @CsvIds=@ProductID
select @index=CHARINDEX(',',@CsvIds,0)
--While loop started
while (@index >0 )
begin
declare @CUR_ProductID int = CONVERT(INT,(SUBSTRING (@CsvIds,1,@index-1)))
if not exists (select * from [Nop_Product_Customer_Mapping] where [ProductId] =@CUR_ProductID)
begin
INSERT INTO [dbo].[Nop_Product_Customer_Mapping]
           ([ProductId]
           ,[CustomerID])
     VALUES
           (@CUR_ProductID ,
            @CustomerID)
         
            end
            else
            begin
            update [dbo].[Nop_Product_Customer_Mapping] set [CustomerID]=@CustomerID where [ProductId]=@CUR_ProductID
            end
--print SUBSTRING (@CsvIds,1,@index-1)
set @CsvIds=SUBSTRING (@CsvIds,@index+1,LEN (@CsvIds))
select @index=CHARINDEX(',',@CsvIds,1)
end

if not exists (select * from [Nop_Product_Customer_Mapping] where [ProductId] =@CsvIds)
begin
INSERT INTO [dbo].[Nop_Product_Customer_Mapping]
           ([ProductId]
           ,[CustomerID])
     VALUES
           (@CsvIds ,
            @CustomerID)
         
            end
            else
            begin
            update [dbo].[Nop_Product_Customer_Mapping] set [CustomerID]=@CustomerID where [ProductId]=@CsvIds
            end
END