Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
C#
[WebMethod]
    public string AddUser(Int64 UID,String Uname,String Password ,String Role,String LastUpdate,String Fname,String Lname,String Company,String City,String State,String Phone,String Email,String Jtype)
    {
        if (UID == 0)
        {
            if (!_obj.SUserMasters.Any(u => u.Username == Uname.Trim()))
            {
                SUserMaster _Utb = new SUserMaster
                {
                    Username = Uname.Trim(),
                    Password = Password.Trim(),
                    Role = Role.Trim(),
                    Lastupdate = LastUpdate,
                    IsActive = true
                };
                _obj.SUserMasters.InsertOnSubmit(_Utb);
                try
                {
                    _obj.SubmitChanges();
                    Int64 _UserID = _Utb.UserID;
                    if (Role == "J")
                    {
                        AddJ(_UserID, Fname, Lname, Company, City, State, Phone, Email, Jtype, "I");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);

                }
            }
            //else { // user exists }
            
        }
        else
        {
            var query = from SUser in _obj.SUserMasters where SUser.UserID == UID select SUser;
            // Execute the query, and change the column values
            // you want to change.
            foreach (var _itme in query)
            {
             //   _itme.Username = Uname.Trim();
                _itme.Password = Password.Trim();
                _itme.Role = Role.Trim();
                _itme.Lastupdate = LastUpdate.Trim();
                
                // Insert any additional changes to column values.
            }
            try
            {
                _obj.SubmitChanges();
                AddJ(UID, Fname, Lname, Company, City, State, Phone, Email, Jtype,"U");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                // Provide for exceptions.
            }

        }
        // Submit the changes to the database.
       
        //
        return "Thanks !";
    }
    [WebMethod]
    public string AddJ(Int64 UID, String Fname, String Lname, String Company, String City, String State, String Phone, String Email, String type, String flag)
    {
        if (flag == "I")
        {
            SJudgeInfo _jtb = new SJudgeInfo
            {
                First_Name = Fname.Trim(),
                Last_Name = Lname.Trim(),
                Company = Company.Trim(),
                City = City,
                JState = State,
                Telephone=Phone,
                JEmail=Email,
                JType=type
            };
            _obj.SJudgeInfos.InsertOnSubmit(_jtb);
            try
            {
                _obj.SubmitChanges();
                //Int64 _UserID = _Utb.UserID;

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                // Provide for exceptions.
            }


        }
        else
        {
            var query = from SUser in _obj.SJudgeInfos where SUser.UserID == @UID select SUser;
            // Execute the query, and change the column values
            // you want to change.
            foreach (var _itme in query)
            {
               _itme.First_Name = Fname.Trim();
                _itme.Last_Name = Lname.Trim();
                _itme.Company = Company.Trim();
                _itme.City = City;
                _itme.JState = State;
                _itme.Telephone = Phone;
                _itme.JEmail = Email;
                _itme.JType = type;
                // Insert any additional changes to column values.
            }
            try
            {
                _obj.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                // Provide for exceptions.
            }

        }
        return "Thanks !";
    }
    [WebMethod]
    public string AddDivision(Int64 ID, String name)
    {
        if (ID == 0)
        {
            if (!_obj.SDivisions.Any(u => u.Division == name.Trim()))
            {
                SDivision _tb = new SDivision
                {
                    Division = name.Trim(),
                };
                _obj.SDivisions.InsertOnSubmit(_tb);
                try
                {
                    _obj.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);

                }
            }
        }
        else {
            if (!_obj.SDivisions.Any(u => u.Division == name.Trim()))
            {
                var query = from SUser in _obj.SDivisions where SUser.DivisionID == ID select SUser;
                // Execute the query, and change the column values
                // you want to change.
                foreach (var _itme in query)
                {
                 
                    _itme.Division = name.Trim();
                 
                }
                try
                {
                    _obj.SubmitChanges();
                 
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    // Provide for exceptions.
                }
            }
        }
        return "Thanks !";
    }
    [WebMethod]
    public string AddWeights(Int64 ID, String name)
    {
        if (ID == 0)
        {
            if (!_obj.SWeights.Any(u => u.Weight == name.Trim()))
            {
                SWeight _tb = new SWeight
                {
                    Weight = name.Trim(),
                };
                _obj.SWeights.InsertOnSubmit(_tb);
                try
                {
                    _obj.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);

                }
            }
        }
        else
        {
            if (!_obj.SWeights.Any(u => u.Weight == name.Trim()))
            {
                var query = from SUser in _obj.SWeights where SUser.WeightID == ID select SUser;
                // Execute the query, and change the column values
                // you want to change.
                foreach (var _itme in query)
                {

                    _itme.Weight = name.Trim();

                }
                try
                {
                    _obj.SubmitChanges();

                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    // Provide for exceptions.
                }
            }
        }
        return "Thanks !";
    }
Posted
Updated 9-Oct-12 23:05pm
v2
Comments
Legor 10-Oct-12 5:04am    
Any question related to that pile of code ?
MT_ 10-Oct-12 5:07am    
What is the problem Sir?

Wow you are giving out the whole code !!
If by any chance, your client sees this post, you will be in trouble man !
 
Share this answer
 
You can use SOAP UI to check webservices(The most famous one).

Also, Many browsers support checking webservices in built. Open the webservice URL using FireFox and it will provide a webform so that you can enter and validate the webservice.
 
Share this answer
 
 
Share this answer
 

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