public IActionResult AddObjectInstance(string clientID, string definitionID) { IActionResult result; Guid definitionIDGuid, clientIDGuid; if (StringUtils.GuidTryDecode(definitionID, out definitionIDGuid) && StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); int organisationID = User.GetOrganisationID(); Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(organisationID, definitionIDGuid); if (definition != null) { // TODO: add error handling around deserialisation. // TODO: could lwm2mObject.instanceID be an optional parameter, allowing a web client to specify? Model.Object lwm2mObject = new ServiceModels.ObjectInstance(definition, Request).Resource; BusinessLogicFactory.Clients.SaveObject(client, lwm2mObject, Model.TObjectState.Add); ServiceModels.ResourceCreated response = new ServiceModels.ResourceCreated(); response.ID = lwm2mObject.InstanceID; string rootUrl = Request.GetRootUrl(); response.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", definitionID, "/instances/", response.ID), true, true); result = Request.GetObjectResult(response, System.Net.HttpStatusCode.Created); } else { result = new BadRequestResult(); } } else { result = new BadRequestResult(); } return(result); }
public IActionResult GetObjectType(string clientID, string definitionID) { IActionResult result = new NotFoundResult(); Guid clientIDGuid; Guid definitionIDGuid; if (StringUtils.GuidTryDecode(clientID, out clientIDGuid) && StringUtils.GuidTryDecode(definitionID, out definitionIDGuid)) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); if ((client != null) && (client.SupportedTypes != null)) { Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(User.GetOrganisationID(), definitionIDGuid); if (definition != null) { Model.ObjectType objectType = client.SupportedTypes.GetObjectType(int.Parse(definition.ObjectID)); if (objectType != null) { ServiceModels.ObjectType response = new ServiceModels.ObjectType(objectType); string rootUrl = Request.GetRootUrl(); response.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", definitionID), false, false); response.AddLink <ObjectDefinition>(Request, "definition", string.Concat(rootUrl, "/objecttypes/definitions/", definitionID)); response.AddLink("instances", string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", definitionID, "/instances"), Request.GetContentType(definition.MIMEType)); result = Request.GetObjectResult(response); } } } } else { result = new BadRequestResult(); } return(result); }
public IActionResult GetMetrics(string clientID) { IActionResult result; Guid clientIDGuid; if (StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); if (client != null) { ServiceModels.Metrics response = new ServiceModels.Metrics(); List <Model.ClientMetric> metrics = BusinessLogicFactory.Metrics.GetMetrics(client.ClientID); AddPageInfo(Request, response, string.Concat(Request.GetRootUrl(), "/clients/", clientID, "/metrics/"), metrics); result = Request.GetObjectResult(response); } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } return(result); }
public static Model.Client From(IClientTemplate c) { var client = new Model.Client() { Name = c.Name, Properties = new ClientProperties() { Description = c.Properties.Description, IsEnabled = c.IsEnabled, }, Schedule = new ClientSchedule() { IsRunContinuously = c.Schedule.IsRunContinuously, RunEverySeconds = c.Schedule.RunEverySeconds }, Plugin = new Plugin() { DLLName = c.PluginTemplate.DLLName, FullClassName = c.PluginTemplate.FullClassName, }, Runtime = new ClientRuntime() { LastRun = c.Status.LastRun, LastLifeSign = c.Status.LastLifeSign, NextRun = c.Status.NextRun } }; return(client); }
/// <summary> /// 定时更新数据 /// </summary> private void InitUpdateTheard() { if (updateTimer == null) { updateSpan = TimeSpan.FromSeconds(2); updateTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) => { if (wanInfo == null) { wanInfo = await RouterAPI.GetWANinfo(); } netRate = await RouterAPI.GetNetRate(); cpuMemInfo = await RouterAPI.GetCpuMemInfo(); clients = await RouterAPI.GetClients(); devRate = await RouterAPI.GetDeviceRate(); banList = await RouterAPI.FireWall.GetBanList(); if (wlanInfo == null) { wlanInfo = await RouterAPI.GetWLANInfo(); } await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { UpdateUI(); }); }, updateSpan); } }
private void DeleteClient_Click(object sender, EventArgs e) { try { Model.Client client = new Model.Client(); client = (Model.Client)Clients.SelectedItem; IEnumerable <Model.Booking> bok = Manipulation.db.Bookings.ToList <Model.Booking>(); Model.Booking one = bok .Where(b => b.Client_code == client.Client_code) .FirstOrDefault(); if (one != null) { throw new Exception("Сначала удалите все брони клиента, затем самого клиента!"); } foreach (Model.Pay p in client.Pays.ToList <Model.Pay>()) { Manipulation.Delete <Model.Pay>(p); } Manipulation.Delete <Model.Client>(client); UpdateDataGrid(); MessageBox.Show("Запись удалена!"); } catch (NullReferenceException ex) { MessageBox.Show("Выберите клиента, чтобы удалить его!"); } catch (ArgumentNullException ex) { MessageBox.Show("Выберите клиента, чтобы удалить его!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Disconnect(Model.Client client) { shutdown(client.Socket, 2); //We shutdown the socket, both ways send/recv. closesocket(client.Socket); //We close the socket and free it. WSACleanup(); //Terminates winsockets on all threads. OutputMessage(this, "Disconnected!"); }
public IActionResult GetClient(string clientID) { IActionResult result; Guid clientIDGuid; if (StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); if (client != null) { ServiceModels.Client response = new ServiceModels.Client(client); string clientUrl = string.Concat(Request.GetRootUrl(), "/clients/", StringUtils.GuidEncode(client.ClientID)); response.AddSelfLink(clientUrl, false, true); response.AddLink <ObjectTypes>(Request, "objecttypes", string.Concat(clientUrl, "/objecttypes")); response.AddLink <ServiceModels.Subscriptions>(Request, "subscriptions", string.Concat(clientUrl, "/subscriptions")); response.AddLink <ServiceModels.Metrics>(Request, "metrics", string.Concat(clientUrl, "/metrics")); result = Request.GetObjectResult(response); } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } return(result); }
private static void Check(Model.Client item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } }
//public int Add(Model.IntegralManage Model) //{ // StringBuilder strSql = new StringBuilder(); // strSql.Append(" insert Client(UniqueID,ClientAccount,ClientName,Phone,Email,ClientAddress,CreateTime,State,Remark)"); // strSql.Append(" values ("); // strSql.Append("@UniqueID,@ClientAccount,@ClientName,@Phone,@Email,@ClientAddress,@CreateTime,@State,@Remark)"); // SqlParameter[] parameters = { // new SqlParameter("@UniqueID", SqlDbType.UniqueIdentifier), // new SqlParameter("@ClientAccount", SqlDbType.NVarChar,100), // new SqlParameter("@ClientName", SqlDbType.NVarChar,150), // new SqlParameter("@Phone", SqlDbType.VarChar,20), // new SqlParameter("@Email", SqlDbType.VarChar,100), // new SqlParameter("@ClientAddress", SqlDbType.NVarChar,150), // new SqlParameter("@CreateTime", SqlDbType.DateTime), // new SqlParameter("@State", SqlDbType.Int,8), // new SqlParameter("@Remark", SqlDbType.NText)}; // parameters[0].Value = Model.UniqueID; // parameters[1].Value = Model.ClientAccount; // parameters[2].Value = Model.ClientName; // parameters[3].Value = Model.Phone; // parameters[4].Value = Model.Email; // parameters[5].Value = Model.ClientAddress; // parameters[6].Value = Model.CreateTime; // parameters[7].Value = Model.State; // parameters[8].Value = Model.Remark; // object obj = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); // if (obj == null) // { // return 0; // } // else // { // return Convert.ToInt32(obj); // } //} public int Edit(Model.Client Model) { StringBuilder strSql = new StringBuilder(); strSql.Append(" update Client set ClientName=@ClientName,Phone=@Phone,Email=@Email,ClientAddress=@ClientAddress,CreateTime=@CreateTime,State=@State,Remark=@Remark where ClientID=@ClientID"); SqlParameter[] parameters = { new SqlParameter("@ClientName", SqlDbType.NVarChar, 150), new SqlParameter("@Phone", SqlDbType.VarChar, 20), new SqlParameter("@Email", SqlDbType.VarChar, 100), new SqlParameter("@ClientAddress", SqlDbType.NVarChar, 150), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@State", SqlDbType.Int, 8), new SqlParameter("@Remark", SqlDbType.NText), new SqlParameter("@ClientID", SqlDbType.Int, 8) }; parameters[0].Value = Model.ClientName; parameters[1].Value = Model.Phone; parameters[2].Value = Model.Email; parameters[3].Value = Model.ClientAddress; parameters[4].Value = Model.CreateTime; parameters[5].Value = Model.State; parameters[6].Value = Model.Remark; parameters[7].Value = Model.ClientID; object obj = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public ClientLogin() { User = App.Client; userSettings = config.LoadConfig(userSettings); loginNotyfi = userSettings.loginEmailNotyfication; //load config value getMessageFromServer.ClientSendActivCodeFromEmail += OnSendActivateCodeFromEmail; getMessageFromServer.ClientLogin += OnClientLogin; }
public void StaffValidationTest() { var cvm = new Model.Client { FirstName = "Doug", LastName = "Patty", Phone = "0456757463", Email = "*****@*****.**" }; Assert.IsFalse(cvm.Validation(), "Should return true as Validation is correct."); }
public void UpdateClient(int clientId, string clientName) { Model.Client client = GetClient(clientId); if (client != null) { client.clientname = clientName; DataContext.SaveChanges(); } }
public static ClientPub ToPublicModel(Model.Client client) { return(new ClientPub() { FirstName = client.FirstName, LastName = client.LastName, DriverLicense = client.DriverLicense }); }
public void Send(string managerLastName, SaleInfoRecord item) { lock (_lockObj) { using (_unitOfWork = new UnitOfWork()) { using (var transaction = _unitOfWork.BeginTransaction()) { try { DAL.Models.Manager newManager = new DAL.Models.Manager { LastName = managerLastName }; Model.Manager manager = _unitOfWork.ManagerRepository.FindBy(m => m.LastName == newManager.LastName); if (manager == null) { _unitOfWork.ManagerRepository.Create(newManager); _unitOfWork.Save(); manager = _unitOfWork.ManagerRepository.FindBy(m => m.LastName == newManager.LastName); } DAL.Models.Product newProduct = new DAL.Models.Product { Name = item.Product, Price = item.Price }; _unitOfWork.ProductRepository.Create(newProduct); DAL.Models.Client newClient = new DAL.Models.Client { Name = item.Client }; _unitOfWork.ClientRepository.Create(newClient); _unitOfWork.Save(); Model.Product product = _unitOfWork.ProductRepository.FindBy(p => p.Name == newProduct.Name); Model.Client client = _unitOfWork.ClientRepository.FindBy(c => c.Name == newClient.Name); DAL.Models.SaleInfo newSaleInfo = new DAL.Models.SaleInfo { ProductId = product.ProductId, ClientId = client.ClientId, ManagerId = manager.ManagerId, DateOfSale = item.DateOfSale }; _unitOfWork.SaleInfoRepository.Create(newSaleInfo); _unitOfWork.Save(); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new Exception(e.Source + " : Crash in sender from " + managerLastName); } } } } }
public IActionResult GetObjectInstances(string clientID, string definitionID) { IActionResult result; Guid definitionIDGuid, clientIDGuid; if (StringUtils.GuidTryDecode(definitionID, out definitionIDGuid) && StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { int organisationID = User.GetOrganisationID(); Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(organisationID, definitionIDGuid); if (definition != null) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); if (client != null) { List <Model.Object> instances = BusinessLogicFactory.Clients.GetObjects(client, definition.ObjectDefinitionID); if (instances != null) { ObjectInstances response = new ObjectInstances(definition); string rootUrl = Request.GetRootUrl(); string instancesUrl = string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID), "/instances"); response.AddLink("add", instancesUrl, ""); response.PageInfo = Request.GetPageInfo(instances.Count); int endIndex = response.PageInfo.StartIndex + response.PageInfo.ItemsCount; for (int index = response.PageInfo.StartIndex; index < endIndex; index++) { ObjectInstance instance = new ObjectInstance(definition, instances[index]); string instanceUrl = string.Concat(instancesUrl, "/", instances[index].InstanceID); AddObjectInstanceLinks(Request, definition, instance, instanceUrl); response.Add(instance); } result = response.GetAction(); } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } } else { result = new BadRequestResult(); } return(result); }
public LastFormForClient(Model.Autorization auto) { try { autorization = auto; InitializeComponent(); DataContext = new Model.Client(); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
public NewClient(Model.Client cl) { try { client1 = cl; InitializeComponent(); DataContext = new Model.Client(); } catch (Exception exp) { MessageBox.Show(exp.Message + "/" + exp.InnerException); } }
public Model.Client CreateClient(string clientName) { var newClient = new Model.Client { clientname = clientName }; DataContext.Clients.Add(newClient); DataContext.SaveChanges(); return(newClient); }
public void ProcessData(Socket socket, NatPackageInfo packageInfo) { try { switch (packageInfo.Body.Action) { case (int)NatAction.Connect: { //注册包回复 Client = packageInfo.Body.Data.FromJson <Model.Client>(); if (Client.MapList == null) { Client.MapList = new List <Map>(); } HandleLog.WriteLine($"【{Client.user_name},{Client.name}】主机密钥验证成功!"); if (Client.MapList.Any()) { foreach (var item in Client.MapList) { HandleLog.WriteLine($"【{item.name}】映射成功:{item.local_endpoint} --> {item.remote_endpoint}"); } } else { HandleLog.WriteLine($"端口映射列表为空,请到管理后台创建映射!"); } } break; case (int)NatAction.MapChange: { //Map变动 var map = packageInfo.Body.Data.FromJson <Map>(); ChangeMap(map); } break; case (int)NatAction.ServerMessage: { //服务端消息 var msg = packageInfo.Body.Data.FromJson <ServerMessage>(); ClientHandler.IsReConnect = msg.ReConnect; HandleLog.WriteLine(msg.Message); } break; } } catch (Exception ex) { HandleLog.WriteLine($"客户端处理穿透业务异常,{ex}"); } }
public IActionResult UpdateObjectInstance(string clientID, string definitionID, string instanceID) { IActionResult result; Guid definitionIDGuid, clientIDGuid; if (StringUtils.GuidTryDecode(definitionID, out definitionIDGuid) && StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); int organisationID = User.GetOrganisationID(); Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(organisationID, definitionIDGuid); if (definition != null) { // TODO: add error handling around deserialisation. List <Model.Property> executeProperties = new List <Model.Property>(); Model.Object lwm2mObject = new ServiceModels.ObjectInstance(definition, Request).Resource; lwm2mObject.InstanceID = instanceID; int index = 0; while (index < lwm2mObject.Properties.Count) { Model.PropertyDefinition propertyDefinition = definition.GetProperty(lwm2mObject.Properties[index].PropertyDefinitionID); if (propertyDefinition.Access == Model.TAccessRight.Execute) { executeProperties.Add(lwm2mObject.Properties[index]); lwm2mObject.Properties.RemoveAt(index); } else { index++; } } if (lwm2mObject.Properties.Count > 0) { BusinessLogicFactory.Clients.SaveObject(client, lwm2mObject, Model.TObjectState.Update); } if (executeProperties.Count > 0) { BusinessLogicFactory.Clients.Execute(client, lwm2mObject, executeProperties); } result = new NoContentResult(); } else { result = new BadRequestResult(); } } else { result = new BadRequestResult(); } return(result); }
public Model.Client GetModel(string id) { Model.Client model = null; StringBuilder strSql = new StringBuilder(); strSql.Append(" select * from Client where ClientID=" + id); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds != null && ds.Tables.Count > 0) { model = Common.DataTableToList.List <Model.Client>(ds.Tables[0])[0]; } return(model); }
public DetailView(IServerListener listener, Model.Client client) { InitializeComponent(); _listener = listener; _client = client; if (_client.LogPath != null) { RichTextBoxLogs.AppendText(File.ReadAllText(Path.GetFullPath(_client.LogPath))); } _client.TextReceived += new ReceivedText(ReceivedText); }
public IActionResult GetObjectTypes(string clientID) { IActionResult result; Guid clientIDGuid; if (StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); if (client != null) { ServiceModels.ObjectTypes response = new ServiceModels.ObjectTypes(); string rootUrl = Request.GetRootUrl(); if (client.SupportedTypes != null) { Model.ObjectDefinitionLookups definitions = BusinessLogicFactory.ObjectDefinitions.GetLookups(); response.PageInfo = Request.GetPageInfo(client.SupportedTypes.Count); int endIndex = response.PageInfo.StartIndex + response.PageInfo.ItemsCount; for (int index = response.PageInfo.StartIndex; index < endIndex; index++) { ServiceModels.ObjectType objectType = new ServiceModels.ObjectType(client.SupportedTypes[index]); if (definitions != null) { Model.ObjectDefinition definition = definitions.GetObjectDefinition(User.GetOrganisationID(), objectType.ObjectTypeID); if (definition != null) { objectType.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID)), false, false); objectType.AddLink <ObjectDefinition>(Request, "definition", string.Concat(rootUrl, "/objecttypes/definitions/", StringUtils.GuidEncode(definition.ObjectDefinitionID))); objectType.AddLink("instances", string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID), "/instances"), Request.GetContentType(definition.MIMEType)); } } response.Add(objectType); } } result = Request.GetObjectResult(response); } else { result = new NotFoundResult(); } } else { result = new BadRequestResult(); } return(result); }
public IActionResult GetObjectInstance(string clientID, string definitionID, string instanceID) { IActionResult result; Guid definitionIDGuid, clientIDGuid; if (StringUtils.GuidTryDecode(definitionID, out definitionIDGuid) && StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { int organisationID = User.GetOrganisationID(); Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(organisationID, definitionIDGuid); if (definition != null) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); if (client != null) { Model.Object instance = BusinessLogicFactory.Clients.GetObject(client, definition.ObjectDefinitionID, instanceID); if (instance != null) { ServiceModels.ObjectInstance response = new ServiceModels.ObjectInstance(definition, instance); string rootUrl = Request.GetRootUrl(); string instanceUrl = string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID), "/instances/", instanceID); AddObjectInstanceLinks(Request, definition, response, instanceUrl); result = response.GetAction(); } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } } else { result = new BadRequestResult(); } return(result); }
private void Add() { BLL.Client bll = new BLL.Client(); Model.Client model = new Model.Client(); model.UniqueID = Guid.NewGuid(); model.ClientAccount = txtClientAccount.Text; model.ClientName = txtClientName.Text; model.Phone = txtPhone.Text; model.Email = txtEmail.Text; model.ClientAddress = txtClientAddress.Text; model.CreateTime = DateTime.Now; model.State = 1; model.Remark = txtRemark.Text; if (bll.Add(model) > 0) { Response.Redirect("/admin/client/ClientList.aspx"); } }
public IActionResult RemoveObjectInstance(string clientID, string definitionID, string instanceID) { IActionResult result; Guid definitionIDGuid, clientIDGuid; if (StringUtils.GuidTryDecode(definitionID, out definitionIDGuid) && StringUtils.GuidTryDecode(clientID, out clientIDGuid)) { int organisationID = User.GetOrganisationID(); Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(organisationID, definitionIDGuid); if (definition != null) { Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid); if (client != null) { Model.Object instance = BusinessLogicFactory.Clients.GetObject(client, definition.ObjectDefinitionID, instanceID); if (instance != null) { BusinessLogicFactory.Clients.SaveObject(client, instance, Model.TObjectState.Delete); result = new NoContentResult(); } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } } else { result = new NotFoundResult(); } } else { result = new BadRequestResult(); } return(result); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["ClientID"] != null) { txtClientAccount.ReadOnly = true; BLL.Client bll = new BLL.Client(); Model.Client model = new Model.Client(); model = bll.GetModel(Request.QueryString["ClientID"]); txtClientAccount.Text = model.ClientAccount; txtClientName.Text = model.ClientName; txtPhone.Text = model.Phone; txtClientAddress.Text = model.ClientAddress; txtEmail.Text = model.Email; txtRemark.Text = model.Remark; txtClientAccount.Attributes.Remove("ajaxurl"); } } }
private void Exit_Click(object sender, RoutedEventArgs e) { try { BindingExpression b = Phone.GetBindingExpression(TextBoxWatermarked.TextProperty); BindingExpression f = Full_Name.GetBindingExpression(TextBoxWatermarked.TextProperty); BindingExpression p = Email.GetBindingExpression(TextBoxWatermarked.TextProperty); if (b.HasValidationError || p.HasValidationError || f.HasValidationError) { throw new Exception("Исправьте неправильно введенные данные!"); } Random rand = new Random(); int code_client = Randomizer(rand, 1000, 100000); Model.Client cl = Manipulation.db.Clients.Find(code_client); if (cl != null) { code_client = Randomizer(rand, 1000, 100000); } Model.Client client = new Model.Client { Client_code = code_client, Full_name = Full_Name.Text, Phone = Phone.Text, Email = Email.Text, Passport_number = autorization.Userr, Birthdate = DateTime.Parse(DateBornC.Text) }; Manipulation.Insert <Model.Client>(client); Pages.NewClient Client = new Pages.NewClient(client); Client.Show(); Close(); } catch (ArgumentNullException ex) { MessageBox.Show("Зaполните все данные!"); } catch (NullReferenceException ex) { MessageBox.Show("Зaполните все данные!"); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { MessageBox.Show("Зaполните все данные!"); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
public int Add(Model.Client Model) { StringBuilder strSql = new StringBuilder(); strSql.Append(" insert Client(UniqueID,ClientAccount,ClientName,Phone,Email,ClientAddress,CreateTime,State,Remark)"); strSql.Append(" values ("); strSql.Append("@UniqueID,@ClientAccount,@ClientName,@Phone,@Email,@ClientAddress,@CreateTime,@State,@Remark)"); SqlParameter[] parameters = { new SqlParameter("@UniqueID", SqlDbType.UniqueIdentifier), new SqlParameter("@ClientAccount", SqlDbType.NVarChar, 100), new SqlParameter("@ClientName", SqlDbType.NVarChar, 150), new SqlParameter("@Phone", SqlDbType.VarChar, 20), new SqlParameter("@Email", SqlDbType.VarChar, 100), new SqlParameter("@ClientAddress", SqlDbType.NVarChar, 150), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@State", SqlDbType.Int, 8), new SqlParameter("@Remark", SqlDbType.NText) }; parameters[0].Value = Model.UniqueID; parameters[1].Value = Model.ClientAccount; parameters[2].Value = Model.ClientName; parameters[3].Value = Model.Phone; parameters[4].Value = Model.Email; parameters[5].Value = Model.ClientAddress; parameters[6].Value = Model.CreateTime; parameters[7].Value = Model.State; parameters[8].Value = Model.Remark; object obj = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }