本文整理汇总了C#中Client.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Save方法的具体用法?C# Client.Save怎么用?C# Client.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.Save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public void Save()
{
Client client = new Client();
client.IsNew = true;
client.ClientName = txtClientName.Text;
client.ClientDescription = txtDescription.Text;
client.ClientAddress = txtAddress.Text;
client.ClientContactPerson = txtContactPerson.Text;
client.ClientContactNo = txtContactNo.Text;
client.ClientURL = txtClientURL.Text;
client.Save();
//Now Save Picture As Well..
string result = UploadPrintableFile(client);
if (result.Equals(""))
{
divStatusError.Visible = false;
divStatusSuccess.Visible = true;
lblStatusSuccess.Text = Global.SuccessLabelStatus;
//lblStatusSuccess.ForeColor = System.Drawing.Color.Green;
}
else
{
divStatusSuccess.Visible = false;
divStatusError.Visible = true;
labelStatusError.Text = Global.ErrorLabelStatus + result;
//labelStatusError.ForeColor = System.Drawing.Color.Red;
}
ClearForm();
}
示例2: Save
public void Save(Client client)
{
try
{
client.Save();
// Redirect("Main","List");
Tabs.Instance.Close(Tabs.Instance.Current);
}
catch (Exception e)
{
RoLog.Instance.WriteToLog(e.Message,TracedAttribute.ERROR);
Flash flash =new Flash(e.Message);
PropertyBag["client"] = client;
PropertyBag["flash"] = flash;
RenderView("Main/Edit");
}
}
示例3: GenerateData
public void GenerateData()
{
User u=new User(){Username = "admin",Password = "admin"};
u.Save();
//generate 100 users
for(int i=0;i<100;i++)
{
Client c=new Client(){Name = "client "+i,Network = "Orange",Phone = "0745961116"};
c.Save();
}
ModemSettings modemSettings = new ModemSettings()
{
Port = "COM1",
BitPerSec = 115200,
DataBits = 8,
Parity =Parity.None,
StopBits =StopBits.One,
FlowControl = "NONE"
};
modemSettings.Save();
var clients = Client.FindAll();
for(int i=0;i<5;i++)
{
for(int j=0;j<6;j++)
{
var date = DateTime.Now.AddDays(j);
SmsHistory h = new SmsHistory()
{
// Client = clients[i],
Date = date.ToString(),
Message = "Mesajul Nr " + j,
Status = "Send ok",
ClientName = clients[i].Name,
ClientPhone = clients[i].Phone
};
h.Save();
}
}
}
示例4: Start
/// <summary>
/// Starts the websocket server. Generates a new Client object for each opened socket
/// and disposes that Client when the connection is closed.
/// </summary>
public void Start()
{
_server.Start(socket => {
socket.OnOpen = () => {
var client = new Client();
client.Save();
_clients[socket] = client;
Log("Client connected: " + socket.ConnectionInfo.ClientIpAddress.ToString());
};
socket.OnClose = () => {
this.RemoveClient(socket);
};
socket.OnError = (e) => {
this.RemoveClient(socket);
};
socket.OnMessage = (message) => {
if (_clients.ContainsKey(socket)) {
var client = _clients[socket];
this.OnMessage(client, message);
}
};
});
}
示例5: HomeModule
public HomeModule()
{
Get["/"] =_=> {
List<Stylist> allStylists = Stylist.GetAll();
return View["index.cshtml", allStylists];
};
Get["/stylist/new"] =_=> {
List<Stylist> allStylists = Stylist.GetAll();
return View["stylist_form.cshtml", allStylists];
};
Post["/stylist/added"] =_=> {
Stylist newStylist = new Stylist(Request.Form["newName"]);
newStylist.Save();
List<Stylist> allStylists = Stylist.GetAll();
return View["index.cshtml", allStylists];
};
Get["/clients/{id}"] = parameters => {
Stylist currentStylist = Stylist.Find(parameters.id);
return View["stylist.cshtml", currentStylist];
};
Post["/client/new/{id}"] = parameters => {
Client newClient = new Client(Request.Form["newClient"], parameters.id);
newClient.Save();
Stylist currentStylist = Stylist.Find(parameters.id);
return View["stylist.cshtml", currentStylist];
};
Get["/stylist/edit/{id}"] = parameters => {
Stylist currentStylist = Stylist.Find(parameters.id);
return View["stylist_edit.cshtml", currentStylist];
};
Patch["/stylist/edit/{id}"] = parameters => {
Stylist currentStylist = Stylist.Find(parameters.id);
currentStylist.Update(Request.Form["newName"]);
List<Stylist> allStylists = Stylist.GetAll();
return View["index.cshtml", allStylists];
};
Get["/stylist/delete/{id}"] = parameters => {
Stylist currentStylist = Stylist.Find(parameters.id);
return View["stylist_delete.cshtml", currentStylist];
};
Delete["/stylist/delete/{id}"] = parameters => {
Stylist currentStylist = Stylist.Find(parameters.id);
currentStylist.Delete();
List<Stylist> allStylists = Stylist.GetAll();
return View["index.cshtml", allStylists];
};
Get["/client/edit/{id}"] = parameters => {
Client currentClient = Client.Find(parameters.id);
return View["client_edit.cshtml", currentClient];
};
Patch["/client/edit/{id}"] = parameters => {
Client currentClient = Client.Find(parameters.id);
Stylist currentStylist = Stylist.Find(currentClient.GetStylistId());
currentClient.Update(Request.Form["newName"], currentStylist.GetId());
return View["stylist.cshtml", currentStylist];
};
Get["/client/delete/{id}"] = parameters => {
Client currentClient = Client.Find(parameters.id);
return View["client_delete.cshtml", currentClient];
};
Delete["/client/delete/{id}"] = parameters => {
Client currentClient = Client.Find(parameters.id);
currentClient.Delete();
Stylist currentStylist = Stylist.Find(currentClient.GetStylistId());
return View["stylist.cshtml", currentStylist];
};
}
示例6: ImportClient
public void ImportClient()
{
string[] strings = lines[currentLine].Split(new[] {','}, StringSplitOptions.None);
Client c = new Client();
if (strings.Length > 0) c.Name = strings[0];
if (strings.Length > 1) c.Phone = strings[1];
if (strings.Length > 2)
{
string network = "Unknow";
if (strings[2].ToLower() == "o")
network = "Orange";
if (strings[2].ToLower() == "v")
network = "Vodafone";
if (strings[2].ToLower() == "c")
network = "Cosmote";
c.Network = network;
}
if (strings.Length > 3) c.Email = strings[3];
try
{
c.Save();
imported++;
}
catch (ActiveRecordValidationException exception)
{
string message = "";
foreach (string s in exception.ValidationErrorMessages)
{
message += s + Environment.NewLine;
}
c.Message = message;
RoLog.Instance.WriteToLog(exception.ToString(), TracedAttribute.ERROR);
}
finally
{
list.Add(c);
grdClients.Items.Refresh();
source.DeferRefresh();
currentLine++;
txtStatus.Text = "Line "+currentLine+"/"+lines.Count;
}
if (currentLine>= lines.Count)
{
ShowVRAlertBox("Import ready" + Environment.NewLine + "Imported " + imported + " from " + lines.Count);
return;
}
btnFileBrowse.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
new ImportClientsDelegate(ImportClient));
}
示例7: HomeModule
public HomeModule()
{
Get["/"]=_=> View["index.cshtml"];
Delete["/"]=_=>{
Client.DeleteAll();
Stylist.DeleteAll();
return View["index.cshtml"];
};
Get["/stylists"]=_=>{
List<Stylist> allStylists = Stylist.GetAll();
return View["stylists.cshtml", allStylists];
};
Delete["/stylists"]=_=>{
Stylist currentStylist = Stylist.Find(Request.Form["stylist-id"]);
currentStylist.Delete();
List<Stylist> allStylists = Stylist.GetAll();
return View["stylists.cshtml", allStylists];
};
Get["/stylist/new"]=_=>View["stylist_new.cshtml"];
Post["/stylist/new/success"]=_=>{
Stylist newStylist = new Stylist(
Request.Form["stylist-name"],
Request.Form["price"]
);
newStylist.Save();
List<Stylist> allStylists = Stylist.GetAll();
return View["stylists.cshtml", allStylists];
};
Get["/stylist/{id}"]=parameters=>{
Dictionary<string, object> model = new Dictionary<string, object>{};
Stylist currentStylist = Stylist.Find(parameters.id);
List<Client> currentClients = currentStylist.GetClients();
model.Add("stylist", currentStylist);
model.Add("clients", currentClients);
return View["clients.cshtml", model];
};
Get["/stylist/edit/{id}"]=parameters=>{
Stylist currentStylist = Stylist.Find(parameters.id);
return View["stylist_edit.cshtml", currentStylist];
};
Patch["/stylist/edit/success"]=_=>{
Stylist currentStylist = Stylist.Find(Request.Form["stylist-id"]);
currentStylist.SetPrice(Request.Form["price"]);
List<Stylist> allStylists = Stylist.GetAll();
return View["stylists.cshtml", allStylists];
};
Delete["/clients"]=_=>{
Client currentClient = Client.Find(Request.Form["client-id"]);
currentClient.Delete();
Dictionary<string, object> model = new Dictionary<string, object>{};
List<Client> allClients = Client.GetAll();
string currentStylist = "All";
model.Add("stylist", currentStylist);
model.Add("clients", allClients);
return View["clients.cshtml", model];
};
Get["/clients"]=_=>{
Dictionary<string, object> model = new Dictionary<string, object>{};
List<Client> allClients = Client.GetAll();
string currentStylist = "All";
model.Add("stylist", currentStylist);
model.Add("clients", allClients);
return View["clients.cshtml", model];
};
Get["/client/new"]=_=>{
List<Stylist> allStylists = Stylist.GetAll();
return View["client_new.cshtml", allStylists];
};
Post["/client/new/success"]=_=>{
Client newClient = new Client(
Request.Form["client-name"],
Request.Form["hair-color"],
Request.Form["stylist-id"]
);
newClient.Save();
Dictionary<string, object> model = new Dictionary<string, object>{};
List<Client> allClients = Client.GetAll();
string currentStylist = "All";
model.Add("stylist", currentStylist);
model.Add("clients", allClients);
return View["clients.cshtml", model];
};
Get["/client/{id}"]=parameters=>{
Dictionary<string, object> model = new Dictionary<string, object>{};
Client currentClient = Client.Find(parameters.id);
Stylist currentStylist = Stylist.Find(currentClient.GetStylistId());
model.Add("stylist", currentStylist);
//.........这里部分代码省略.........
示例8: btnAddClient_Click
protected void btnAddClient_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
if (clientId > 0)
{
Client client = new Client(clientId);
client.IsNew = false;
client.ClientName = txtClientName.Text;
client.ClientDescription = txtDescription.Text;
client.ClientAddress = txtAddress.Text;
client.ClientContactPerson = txtContactPerson.Text;
client.ClientContactNo = txtContactNo.Text;
client.ClientURL = txtClientURL.Text;
try
{
client.Save();
UploadPrintableFile(client);
divStatusError.Visible = false;
divStatusSuccess.Visible = true;
lblStatusSuccess.Text = Global.UpdatedLabelStatus;
//lblStatusSuccess.ForeColor = System.Drawing.Color.Green;
}
catch (Exception ex)
{
divStatusSuccess.Visible = false;
divStatusError.Visible = true;
labelStatusError.Text = Global.ErrorLabelStatus + ex.ToString();
//labelStatusError.ForeColor = System.Drawing.Color.Red;
}
}
else
{
try
{
Save();
}
catch (Exception ex)
{
divStatusSuccess.Visible = false;
divStatusError.Visible = true;
labelStatusError.Text = Global.ErrorLabelStatus + ex.ToString();
}
}
}
}
示例9: UploadPrintableFile
string UploadPrintableFile(Client client)
{
string NewFileName = client.ClientId + "-" + Path.GetFileName(fuLogo.PostedFile.FileName);
string FileNameWithoutExt = client.ClientId + "-" + Path.GetFileNameWithoutExtension(fuLogo.PostedFile.FileName);
string error;
if (fuLogo.PostedFile.FileName == null || fuLogo.PostedFile.FileName.Equals("") && clientId == 0)
{
client = new Client(Client.Columns.ClientId, client.ClientId);
client.IsNew = false;
client.ClientLogo = "NoImage.jpg";
client.Save(Guid.NewGuid());
return string.Empty;
}
if (fuLogo.PostedFile.ContentLength > 1)
{
Utility.DeleteFile(Global.NewsImages + client.ClientLogo);
if (Utility.UploadFile(fuLogo, FileNameWithoutExt, Global.ClientLogos, out error))
{
client = new Client(Client.Columns.ClientId, client.ClientId);
client.IsNew = false;
client.ClientLogo = NewFileName;
client.Save(Guid.NewGuid());
}
else
{
Client.Destroy(client.ClientId);
return error.ToString();
}
}
return String.Empty;
}
示例10: Update
public void Update(int ClientId,string ClientName,string ClientDescription,string ClientAddress,string ClientContactPerson,string ClientContactNo,string ClientURL,string ClientLogo)
{
Client item = new Client();
item.MarkOld();
item.IsLoaded = true;
item.ClientId = ClientId;
item.ClientName = ClientName;
item.ClientDescription = ClientDescription;
item.ClientAddress = ClientAddress;
item.ClientContactPerson = ClientContactPerson;
item.ClientContactNo = ClientContactNo;
item.ClientURL = ClientURL;
item.ClientLogo = ClientLogo;
item.Save(UserName);
}
示例11: Insert
public void Insert(string ClientName,string ClientDescription,string ClientAddress,string ClientContactPerson,string ClientContactNo,string ClientURL,string ClientLogo)
{
Client item = new Client();
item.ClientName = ClientName;
item.ClientDescription = ClientDescription;
item.ClientAddress = ClientAddress;
item.ClientContactPerson = ClientContactPerson;
item.ClientContactNo = ClientContactNo;
item.ClientURL = ClientURL;
item.ClientLogo = ClientLogo;
item.Save(UserName);
}
示例12: SaveToDb
//数据持久化
internal static void SaveToDb(ClientInfo pClientInfo, Client pClient,bool pIsNew)
{
pClient.ClientId = pClientInfo.clientId;
pClient.ClientName = pClientInfo.clientName;
pClient.ClientLevelId = pClientInfo.clientLevelId;
pClient.Address = pClientInfo.address;
pClient.Telephone = pClientInfo.telephone;
pClient.MailNo = pClientInfo.mailNo;
pClient.Fax = pClientInfo.fax;
pClient.EmployeeId = pClientInfo.employeeId;
pClient.ClientTypeId = pClientInfo.clientTypeId;
pClient.SheetNum = pClientInfo.sheetNum;
pClient.IsNew=pIsNew;
string UserName = SubsonicHelper.GetUserName();
try
{
pClient.Save(UserName);
}
catch(Exception ex)
{
LogManager.getInstance().getLogger(typeof(ClientInfo)).Error(ex);
if(ex.Message.Contains("插入重复键"))//违反了唯一键
{
throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
}
throw new AppException("保存失败");
}
pClientInfo.clientId = pClient.ClientId;
//如果缓存存在,更新缓存
if (CachedEntityCommander.IsTypeRegistered(typeof(ClientInfo)))
{
ResetCache();
}
}