private void OnSave(ComposeNewContactModel args) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); if (args.ID == null) { string id = GenerateID(); db.Execute("InsertContact", new { ID = id, Name = args.Name, PhoneNumber = args.PhoneNumber }); } else { db.Execute("UpdateContact", new { ID = args.ID, Name = args.Name, PhoneNumber = args.PhoneNumber }); } db.Close(); }
private void OnDelete(string source) { if (source == null) { throw new ArgumentNullException("Source"); } Task.Factory.StartNew(() => { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); IsBusy = true; string number; foreach (BaseDataRow message in SelectableRow.ToList()) { BaseMessageModel model; if (source == "O") // source from Outbox { model = (BaseMessageModel)message; number = ((Outbox)message).Receiver; db.Execute("UpdateMessageStatus", new { Status = "D", SeqNbr = model.SeqNbr, Sender = number, Source = source.ToUpper() }); } else if (source == "I") // source from Inbox { model = (BaseMessageModel)message; number = model.Sender; db.Execute("UpdateMessageStatus", new { Status = "D", SeqNbr = model.SeqNbr, Sender = number, Source = source.ToUpper() }); } else if (source == "D") // source from Draft { ComposeMessageModel compose = (ComposeMessageModel)message; db.Execute("DeleteQueue", new { SeqNbr = compose.SeqNbr }); } message.IsSelected = false; } MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>(); mcsm.ForceSyncronizing(); SelectableRow.Clear(); CheckedHeader = false; db.Close(); IsBusy = false; }); }
/// <inheritdoc/> public override bool Execute(bool previousTaskState) { GitHubClient client = new GitHubClient(new ProductHeaderValue(repositoryOwner)); Task <IReadOnlyList <Release> > releaseTask; try { releaseTask = client.Repository.Release.GetAll(repositoryOwner, RepositoryName); releaseTask.Wait(4000); } catch (Exception ex) { warningPopup?.Execute(Properties.Resources.Dialog_GetRemoteVersionError.Replace("{exception}", ex.Message)); return(false); } if (!releaseTask.IsCompleted && filter != null) { warningPopup?.Execute(Properties.Resources.Dialog_GetRemoteTimeout); return(false); } IReadOnlyList <Release> releases = releaseTask.Result; releases = releases.Where(obj => { return(filter.IsMatch(obj.TagName)); }).ToList(); if (releases.Count == 0) { warningPopup?.Execute(Properties.Resources.Dialog_GetRemoteNoBuildsFound); return(false); } List <ArtifactRelease> artifactReleases = new List <ArtifactRelease>(); foreach (Release release in releases) { artifactReleases.Add(new ArtifactRelease(release, filter)); } artifactReleases.Sort((release1, release2) => release2.Version.CompareTo(release1.Version)); ArtifactRelease newestArtifact = artifactReleases.First(); AddSetting("RemoteVersion", newestArtifact.Version); AddSetting("LatestArtifact", newestArtifact); return(true); }
private void MarkReadUnread(int read) { Task.Factory.StartNew(() => { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); IsBusy = true; foreach (Inbox message in SelectableRow.ToList()) { message.IsRead = read; db.Execute("UpdateMessageRead", new { IsRead = read, SeqNbr = message.SeqNbr }); message.IsSelected = false; if (read == (int)MessageRead.Read) { Unread -= 1; } } MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>(); mcsm.ForceSyncronizing(); SelectableRow.Clear(); CheckedHeader = false; db.Close(); IsBusy = false; }); }
public void Write(object value) { if (value == null) { return; } System.Reflection.PropertyInfo pi = value.GetType().GetProperty("ID"); if (pi != null) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); string propValue = (string)pi.GetValue(value, null); if (!string.IsNullOrEmpty(propValue)) { StringBuilder responseJson = new StringBuilder(Newtonsoft.Json.JsonConvert.SerializeObject(value, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore })); db.Execute("InsertResultWorkItem", new { SeqNbr = propValue, Response = responseJson.ToString() }); db.Close(); } } }
public override void OnEdit(object arg) { if (arg != null) { Supplier model = (Supplier)arg; IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); if (dialog.ShowDialog <Views.Dialogs.Supplier>(model).Value == true) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); try { db.Execute("UpdateSupplier", new { SupplierId = model.Id, Name = model.Name, Address = model.Address, Telp = model.Telp, Active = model.Active }); } catch { } db.Close(); OnSourceChanged(this); } } }
public override void OnDelete(object arg) { WarningModel message = new WarningModel() { Message = "Are you sure want to delete data?" }; IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); bool? result = dialog.ShowDialog <YesNo>(message); if (result.HasValue && result.Value) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); foreach (Supplier item in Source) { if (item.IsSelected) { try { db.Execute("DeleteSupplier", new { SupplierId = item.Id }); } catch { } } } db.Close(); CheckedHeader = false; OnSourceChanged(this); } }
private void OnDeleteDetail(dynamic obj) { System.Collections.IList items = (System.Collections.IList)obj; var collection = items.Cast <CreateOrderDetailModel>(); if (!NewOrder) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); foreach (CreateOrderDetailModel item in collection.ToList()) { db.Execute("DeleteOrderDetail", new { OrderId = item.OrderId, SeqNbr = item.SeqNbr }); } db.Close(); } foreach (CreateOrderDetailModel item in collection.ToList()) { if (item.IsSelected) { Details.Source.Remove(item); } } CalculatingTotalPayment(); CalculatingTotalPaymentByDiscount(); Details.CheckedHeader = false; }
public void OnDataReceived(string data) { try { if (data != "[]") { if (data.StartsWith("[") && data.EndsWith("]") && data.Contains("SMSReadResult")) { ConfigurationSettings configuration = ObjectPool.Instance.Resolve <ConfigurationSettings>(); List <BaseResult <SMSReadResult> > list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <BaseResult <SMSReadResult> > >(data); IDbManager dbManager = ObjectPool.Instance.Resolve <PetapocoDbManager>(); IDataCommand db = dbManager.GetDatabase("SMSGW"); foreach (BaseResult <SMSReadResult> read in list) { db.Execute("Obstruction", null); } db.Close(); } } } catch (Exception) { throw; } }
private void OnUpdateDetailStatus(object status) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); foreach (CreateOrderDetailModel detail in this.details.Source) { if (detail.IsSelected) { db.Execute("UpdateOrderDetailStatus", new { Queue = status, OrderId = this.poNumber, SeqNbr = detail.SeqNbr }); detail.Queue = Convert.ToInt32(status); detail.QueueStatus = "Just Trigger"; detail.IsSelected = false; } } db.Close(); bool completed = this.details.Source.Where(x => x.Queue == 2).Count() == this.details.Source.Count; if (completed) { OnStatusCompleted(); } this.Details.CheckedHeader = false; }
public override void OnEdit(object arg) { if (arg != null) { KeyValueOption model = (KeyValueOption)arg; model.IsReadOnly = true; IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); if (dialog.ShowDialog <Size>(model).Value == true) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); try { db.Execute("UpdateSize", new { Id = model.Id, Description = model.Description }); } catch { } db.Close(); OnSourceChanged(this); } } }
public override void OnCreate() { KeyValueOption model = new KeyValueOption(); model.Id = GenerateId(3, "SE"); IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); if (dialog.ShowDialog <Size>(model).Value == true) { if (model.Description == null) { return; } this.Source.Add(model); IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); try { db.Execute("InsertSize", new { Id = model.Id, Description = model.Description }); } catch { } db.Close(); OnSourceChanged(this); } }
public override void OnDelete(object arg) { if (arg != null) { TransactionStock model = (TransactionStock)arg; IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); if (dialog.ShowDialog <Koala.Views.Dialogs.Stock>(model).Value == true) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); UserModel user = ObjectPool.Instance.Resolve <UserModel>(); try { db.Execute("DeleteStock", new { MaterialId = model.MaterialId, QualityId = model.QualityId, SupplierId = model.SupplierId, Qty = model.Qty, CreatedBy = user.Username }); } catch { } db.Close(); OnSourceChanged(this); } } }
public override void OnDelete(object obj) { WarningModel message = new WarningModel() { Message = "Are you sure want to delete data?" }; IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); bool? result = dialog.ShowDialog <YesNo>(message); if (result.HasValue && result.Value) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); OrderCollaborator orderCollaborator = ObjectPool.Instance.Resolve <OrderCollaborator>(); foreach (CreateOrderModel order in Source.ToList()) { if (order.IsSelected) { db.Execute("DeletePrintOrder", new { OrderId = order.PoNumber, Status = "F" }); orderCollaborator.PaymentOrder.source.Remove(order); } } db.Close(); base.OnDelete(obj); } }
private void OnUpdateDetail(object arg) { if (UpdatingOrderDetail != null) { UpdatingOrderDetail(this, this); } Task.Run(() => { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); CreateOrderDetailModel detail = (CreateOrderDetailModel)arg; db.Execute("UpdateOrderDetail", new { MaterialTypeId = detail.SelectedMaterial.Id, QualityId = detail.SelectedQuality.Id, FinishingId = detail.SelectedFinishing.Id, Title = detail.title, Width = detail.width, Height = detail.height, Qty = detail.qty, Queue = detail.Queue, Deadline = detail.deadline, Description = detail.description, Total = detail.Price, OrderId = detail.orderId, SeqNbr = detail.SeqNbr }); db.Close(); }); }
private void OnDelete(object args) { Task.Factory.StartNew(() => { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); IsBusy = true; foreach (BaseContactModel item in SelectableRow) { db.Execute("DeleteContact", new { ID = item.ID }); } IDataSyncronize data = ObjectPool.Instance.Resolve <DatabaseCollectionViewSource>(); data.StartSyncronizing(); SelectableRow.Clear(); db.Close(); IsBusy = false; }); }
private void OnMarkAsSpam(string source) { if (source == null) { throw new ArgumentNullException("Source"); } Task.Factory.StartNew(() => { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); IsBusy = true; foreach (BaseMessageModel message in SelectableRow.ToList()) { db.Execute("UpdateMessageStatus", new { Status = "S", SeqNbr = message.SeqNbr, Sender = message.Sender, Source = source.ToUpper() }); message.IsSelected = false; } MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>(); mcsm.ForceSyncronizing(); SelectableRow.Clear(); CheckedHeader = false; db.Close(); IsBusy = false; }); }
public override void OnCreate() { TransactionStock model = new TransactionStock(); IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); if (dialog.ShowDialog <Koala.Views.Dialogs.Stock>(model).Value == true) { if (model.MaterialId == null || model.QualityId == null || model.SupplierId == null || model.Qty == 0) { return; } this.Source.Add(model); IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); try { db.Execute("InsertStock", new { }); } catch { } db.Close(); OnSourceChanged(this); } }
private void OnMessageOpen(object args) { ComposeMessageModel forward = new ComposeMessageModel(); if (args == null) { return; } else if (args.GetType() == typeof(ComposeMessageModel)) { DialogService.Instance.ShowDialog <Views.Dialogs.ComposeMessage>(args); return; } Type typeArgs = args.GetType(); if (typeArgs == typeof(Inbox) || typeArgs == typeof(Spam) || typeArgs == typeof(Trash)) { BaseMessageModel inbox = (BaseMessageModel)args; if (typeArgs == typeof(Inbox)) { ((Inbox)inbox).IsRead = (int)MessageRead.Read; } else if (typeArgs == typeof(Trash)) { ((Trash)inbox).IsRead = (int)MessageRead.Read; } IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); db.Execute("UpdateMessageRead", new { IsRead = (int)MessageRead.Read, SeqNbr = inbox.SeqNbr }); db.Close(); forward.Message = inbox.Message; forward.Phonenumber = inbox.Sender; } Outbox outbox = new Outbox(); if (typeArgs == typeof(Outbox)) { outbox = (Outbox)args; forward.Message = outbox.Message; } else if (typeArgs.Name == "SelectedItemCollection") { outbox = (Outbox)((System.Collections.IList)args)[0]; forward.Message = outbox.Message; } DialogService.Instance.ShowDialog <Views.Dialogs.ComposeMessage>(forward); }
private void OnUpdateQueueOrder(string status) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); OrderCollaborator orderCollaborator = ObjectPool.Instance.Resolve <OrderCollaborator>(); UserModel user = ObjectPool.Instance.Resolve <UserModel>(); foreach (CreateOrderModel order in Source.ToList()) { if (order.IsSelected) { db.Execute("UpdatePrintOrder", new { OrderId = order.PoNumber, Status = status, Queue = 1 }); order.IsSelected = false; /// update list order.Status = "Q"; foreach (CreateOrderDetailModel detail in order.Details.Source) { db.Execute("InsertTransactionStock", new { MaterialId = detail.MaterialId, QualityId = detail.QualityId, Qty = detail.Qty, CreatedBy = user.Username, }); } orderCollaborator.PrintOrder.source.Remove(order); orderCollaborator.Queue.Source.Add(order); } } db.Close(); orderCollaborator.Queue.Source = orderCollaborator.Queue.Source.OrderBy(x => x.UpdateDate).Convert(); CheckedHeader = false; }
private void OnUpdate(MaterialType model) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); db.Execute("UpdateMaterial", new { Id = model.Id, Description = model.Description, QualityId = model.SelectedQuality.Id, Price = model.Price }); db.Close(); OnItemChanged(); }
private void OnRestore() { Task.Factory.StartNew(() => { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); IsBusy = true; string number; Type messageType; foreach (BaseMessageModel message in SelectableRow.ToList()) { messageType = message.GetType(); if (messageType == typeof(Trash)) { if (((Trash)message).Source.ToLower() == "inbox") { number = ((Trash)message).Sender; } else { number = ((Trash)message).Receiver; } } else { number = message.Sender; } db.Execute("UpdateMessageStatus", new { Status = "R", SeqNbr = message.SeqNbr, Sender = number, Source = "" }); message.IsSelected = false; } MessageCollaborator mcsm = ObjectPool.Instance.Resolve <MessageCollaborator>(); mcsm.ForceSyncronizing(); SelectableRow.Clear(); CheckedHeader = false; db.Close(); IsBusy = false; }); }
public void Send(GSMCommunication.Feature.BaseResult <GSMCommunication.Feature.SMSSendResult> arg) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); if (!string.IsNullOrEmpty(arg.Response.To)) { db.Execute("InsertSMSOutbox", new { Sequence = GUID.GenerateID("O"), Sender = arg.Response.From == null ? string.Empty : arg.Response.From, Receiver = arg.Response.To, Message = arg.Response.Message, Time = arg.Response.Sent, SenderOperator = arg.Response.Operator, NetworkStatus = arg.Response.NetworkStatus, Error = arg.Response.Error }); db.Close(); } }
private void OnUpdateQueueOrder(string status) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); //bool updated = false; OrderCollaborator orderCollaborator = ObjectPool.Instance.Resolve <OrderCollaborator>(); foreach (CreateOrderModel order in Source.ToList()) { if (order.IsSelected) { if (order.Remaining < 0) { IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); bool? dialogResult = dialog.ShowDialog <Warning>(new WarningModel() { Message = string.Format("Po Number {0} - ({1}) must be in complete payment.", order.PoNumber, order.CustomerName) }); } else { //updated = true; db.Execute("UpdatePrintOrder", new { OrderId = order.PoNumber, Status = status, Queue = 2 }); orderCollaborator.Queue.Source.Remove(order); orderCollaborator.PaymentOrder.Source.Add(order); } order.IsSelected = false; } } db.Close(); orderCollaborator.PaymentOrder.Source = orderCollaborator.PaymentOrder.Source.OrderByDescending(x => x.UpdateDate).Convert(); CheckedHeader = false; }
private void OnUpdate(object obj) { if (obj == null) { return; } IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); db.Execute("UpdateOrder", new { Status = this.Status, Total = this.totalPayment, Installment = this.installment, Remaining = this.remaining, Disc = this.discount, OrderId = this.poNumber, }); db.Close(); }
/// <inheritdoc/> public override bool Execute(bool previousTaskState) { bool returnState = true; Version remoteVersion = GetSetting <Version>("RemoteVersion"); Version localVersion = GetSetting <Version>("LocalVersion"); if (localVersion == null || remoteVersion == null) { warningPopup.Execute(Properties.Resources.Message_VersionUpdateWarning); return(false); } if (yesNoPopup != null) { yesNoPopup.Executed += (sender, content) => { object data = content.GetData(); if (data is YesNoEnum dialog) { returnState = dialog == YesNoEnum.Yes; } }; } if (showLocalIsNewer && localVersion >= remoteVersion) { infoPopup.Execute(Properties.Resources.Message_LocalVersionIsNewer); return(false); } if (localVersion < remoteVersion) { string text = Properties.Resources.Message_Update; text = text.Replace("{remoteVersion}", remoteVersion.ToString()); text = text.Replace("{localVersion}", localVersion.ToString()); yesNoPopup?.Execute(text); } return(returnState); }
public override void OnDelete(object arg) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); foreach (KeyValueOption item in Source) { if (item.IsSelected) { try { db.Execute("DeleteSize", new { Id = item.Id }); } catch { } } } db.Close(); CheckedHeader = false; OnSourceChanged(this); }
public void Read(List <GSMCommunication.Feature.BaseResult <GSMCommunication.Feature.SMSReadResult> > arg) { IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(DatabaseNames.SMSGW); string guid; foreach (BaseResult <SMSReadResult> read in arg) { guid = GUID.GenerateID("I"); db.Execute("InsertSMSInbox", new { Sequence = guid, Sender = read.Response.From, Message = read.Response.Message, Time = read.Response.Sent, ReceiverOperator = read.Response.Operator, Error = read.Response.Error, IsRead = 0 }); } db.Close(); }
public override void OnCreate() { Supplier model = new Supplier(); model.Id = GenerateId(3, "SP"); IDialogService dialog = ObjectPool.Instance.Resolve <IDialogService>(); if (dialog.ShowDialog <Views.Dialogs.Supplier>(model).Value == true) { if (model.Name == null || model.Address == null || model.Telp == null) { return; } this.Source.Add(model); IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); try { db.Execute("InsertSupplier", new { SupplierId = model.Id, Name = model.Name, Address = model.Address, Telp = model.Telp, }); } catch { } db.Close(); OnSourceChanged(this); } }
private async Task OnSave(object obj) { if (obj != null) { CreateOrderModel model = (CreateOrderModel)obj; if (string.IsNullOrEmpty(model.CustomerName)) { return; } await Task.Run(() => { IsBusy = true; IsEnabled = false; IDbManager dbManager = ObjectPool.Instance.Resolve <IDbManager>(); IDataCommand db = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name); Dictionary <string, string> scripts = new Dictionary <string, string>(); List <int> result = db.Query <int>("CheckExistsOrder", new { OrderId = model.PoNumber }); if (result.Any()) { scripts.Add("Order", "UpdateOrder"); scripts.Add("OrderDetail", "UpdateOrderDetail"); } else { scripts.Add("Order", "CreateOrder"); scripts.Add("OrderDetail", "CreateOrderDetail"); } IDbTransaction transaction = ((BaseDbCommand)db).BeginTransaction(); try { db.Execute(scripts["Order"], new { OrderId = model.PoNumber, CustomerName = model.CustomerName, CustomerPhone = model.CustomerPhone, Status = "I", Total = model.TotalPayment, Installment = model.Installment, Remaining = model.Remaining, Disc = model.discount }); CreateOrderDetailModel detail; for (int i = 0; i < model.Details.Source.Count; i++) { detail = model.Details.Source[i]; result = db.Query <int>("CheckExistsOrderDetail", new { OrderId = model.poNumber, SeqNbr = detail.SeqNbr }); if (!result.Any()) { scripts["OrderDetail"] = "CreateOrderDetail"; } db.Execute(scripts["OrderDetail"], new { OrderId = model.PoNumber, SeqNbr = i + 1, MaterialTypeId = detail.MaterialId, QualityId = detail.QualityId, FinishingId = detail.FinishingId, Title = detail.Title, Width = detail.Width, Height = detail.Height, Qty = detail.Qty, Filename = detail.Filename, Image = detail.Stream, Queue = 0, Deadline = detail.Deadline, Description = detail.Description, Total = detail.Price }); } transaction.Commit(); } catch (Exception x) { transaction.Rollback(); } db.Close(); IsBusy = false; IsEnabled = true; OnItemCreated(); }); } }