本文介绍了如何使用网络服务,请检查其确定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[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 !";
}
推荐答案
这篇关于如何使用网络服务,请检查其确定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!