當前位置: 首頁>>代碼示例>>C#>>正文


C# Database.AbortTransaction方法代碼示例

本文整理匯總了C#中PetaPoco.Database.AbortTransaction方法的典型用法代碼示例。如果您正苦於以下問題:C# Database.AbortTransaction方法的具體用法?C# Database.AbortTransaction怎麽用?C# Database.AbortTransaction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PetaPoco.Database的用法示例。


在下文中一共展示了Database.AbortTransaction方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: btnReView_ItemClick

 void btnReView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     var et = gcloginfail.GetFocusedDataSource<t_loginfail>();
     if (null == et)
         return;
     if (MsgBox.ShowYesNoMessage(null,
         string.Format("確定要將 {0} MAC:{1} 審核通過嗎?", et.UserName, et.LoginMAC)) == System.Windows.Forms.DialogResult.No)
         return;
     var usr = GetCurUser<t_user>();
     using (var db = new Database()) {
         try {
             db.BeginTransaction();
             db.Delete("t_loginfail", "Id", et, et.Id);
             db.Execute(sql_addmac, et.LoginMAC, usr.UserName, usr.Guid);
             db.CompleteTransaction();
         } catch (Exception) {
             db.AbortTransaction();
     #if DEBUG
             throw;
     #endif
         }
     }
     using (var db = new Database()) {
         var etfail = db.Fetch<t_loginfail>("select * from t_loginfail");
         gcloginfail.DataSource = etfail;
         gcloginfail.RefreshDataSource();
         var etmac = db.Fetch<t_loginfail>("select * from t_mac");
         gcMac.DataSource = etmac;
         gcMac.RefreshDataSource();
     }
 }
開發者ID:MasterGao,項目名稱:DevWinFormFrame,代碼行數:31,代碼來源:MainView.cs

示例2: btnOK_Click

 private void btnOK_Click(object sender, EventArgs e)
 {
     if (MsgBox.ShowYesNoMessage(null, string.Format("確定要保存對角色:{0} 的修改嗎?", roleGridEdit2.SelectedValue.Name))
         == System.Windows.Forms.DialogResult.No)
         return;
     var role = roleGridEdit2.SelectedValue;
     using (var db = new Database()) {
         try {
             db.BeginTransaction();
             db.Execute("delete from t_roleuser where [email protected]", role.Id);
             var ets = gridalloc.GetDataSource<t_user>();
             if (null != ets && ets.Count > 0)
                 foreach (var k in ets)//.ForEach(k =>
                 {
                     db.Insert(new t_roleuser {
                         Guid = Guid.NewGuid(),
                         RoleId = role.Id,
                         UserId = k.Id,
                         IsUsing = true,
                         Creator = this.CurUser,
                         CreateDate = TimeSync.Default.CurrentSyncTime
                     });
                 };
             db.CompleteTransaction();
         } catch (Exception ex) {
             db.AbortTransaction();
             throw;
         }
     }
     MsgBox.ShowMessage(null, "保存成功!");
 }
開發者ID:MasterGao,項目名稱:DevWinFormFrame,代碼行數:31,代碼來源:NewView.cs

示例3: btnOK_Click

 private void btnOK_Click(object sender, EventArgs e)
 {
     if (!dxValidationProvider1.Validate())
         return;
     var odrs = gcOrder.GetDataSource<t_retorder>();
     if (odrs == null || odrs.Count < 1) {
         MsgBox.ShowMessage("提示", "沒有退貨商品不能保存退貨單!");
         return;
     }
     if (odrs.Any(k=>string.IsNullOrEmpty(k.LocName))) {
         MsgBox.ShowMessage("提示", "所有商品都必須選擇庫位!");
         return;
     }
     if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
         var rettrd = this.Trade;
         rettrd.Guid = Guid.NewGuid();
         rettrd.Id = 0;
         rettrd.IsAudit = false;
         using (var db = new Database()) {
             try {
                 db.BeginTransaction();
                 db.Save(rettrd);
                 odrs.ForEach(k => {
                     k.Guid = Guid.NewGuid();
                     k.Id = 0;
                     k.TradeGuid = rettrd.Guid;
                     db.Save(k);
                 });
                 db.CompleteTransaction();
             } catch (Exception) {
                 db.AbortTransaction();
                 throw;
             }
         }
     } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
         using (var db = new Database()) {
             var trd = db.FirstOrDefault<t_rettrade>(" where [email protected]", GuidKey);
             trd.ReceiverName = Trade.ReceiverName;
             trd.ReceiverMobile = txtMobile.Text;
             trd.ReceiverAddress = txtReceiverAddress.Text;
             trd.MemberGuid = Trade.Guid;
             trd.DeliveryDate = TimeSync.Default.CurrentSyncTime;
             trd.DeliveryDate = dateDeliveryDate.DateTime;
             try {
                 db.BeginTransaction();
                 db.Save(trd);
                 db.Execute("delete t_retorder where [email protected]", trd.Guid);
                 odrs.ForEach(k => {
                     k.Id = 0;
                     db.Save(k);
                 });
                 db.CompleteTransaction();
             } catch (Exception) {
                 db.AbortTransaction();
                 throw;
             }
         }
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
開發者ID:ZixiangBoy,項目名稱:YongERP,代碼行數:61,代碼來源:NewView.cs

示例4: btnOK_Click

        private void btnOK_Click(object sender, EventArgs e)
        {
            var items = gcItem.GetDataSource<t_instockitem>();
            if (items == null || items.Count < 1) {
                MsgBox.ShowMessage("", "沒有商品信息,不能保存!");
                return;
            }
            if (items.Any(K => string.IsNullOrEmpty(K.ItemNo))) {
                MsgBox.ShowMessage("", "商品信息不完整!");
                return;
            }

            if (EditMode == Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    try {
                        db.BeginTransaction();
                        db.Execute("delete t_instockitem where [email protected]", InStockNo);
                        InStock.Remark = txtRemark.Text;
                        InStock.Num = items.Sum(k => k.Num);
                        InStock.OuterNo = txtOuterNo.Text;
                        db.Save(InStock);
                        items.ForEach(k => { k.Id = 0; db.Save(k); });

                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            } else {

                InStock = new t_instock();
                InStock.Remark = txtRemark.Text;
                InStock.Guid = GuidKey;
                InStock.InStockNo = InStockNo;
                InStock.OuterNo = txtOuterNo.Text;
                InStock.Creator = this.CurUser;
                InStock.AuditDate = InStock.CreateDate = TimeSync.Default.CurrentSyncTime;
                InStock.Num = items.Sum(k => k.Num);

                using (var db = new Database()) {
                    try {
                        db.BeginTransaction();
                        db.Save(InStock);
                        items.ForEach(k => db.Save(k));

                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }

            }

            DialogResult = DialogResult.OK;
            Close();
        }
開發者ID:ZixiangBoy,項目名稱:YongERP,代碼行數:58,代碼來源:InStockEditView.cs

示例5: btnReView_ItemClick

 void btnReView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     var trd = gcUnAudit.GetFocusedDataSource<t_rettrade>();
     if (trd == null)
         return;
     using (var db = new Database()) {
         try {
             db.BeginTransaction();
             //入庫更新庫存
             db.Execute("exec p_retgoodsupdateinvt @0", trd.Guid);
             db.Execute("update t_rettrade set isaudit=1 where [email protected]", trd.Guid);
             db.CompleteTransaction();
             gcUnAudit.RemoveSelected();
         } catch (Exception) {
             db.AbortTransaction();
             throw;
         }
     }
 }
開發者ID:ZixiangBoy,項目名稱:YongERP,代碼行數:19,代碼來源:MainView.cs

示例6: btnReView_ItemClick

 void btnReView_ItemClick(object sender, ItemClickEventArgs e)
 {
     var et=gcUnAudit.GetFocusedDataSource<t_instock>();
     if (et == null)
         return;
     using (var db = new Database()) {
         try {
             db.BeginTransaction();
             db.Execute(" update t_instock set isaudit=1,auditdate=getdate() where [email protected]", et.InStockNo);
             //更新庫存
             db.Execute("exec p_instockupdateinvt @0", et.InStockNo);
             db.CompleteTransaction();
             gcUnAudit.RemoveSelected();
         } catch (Exception) {
             db.AbortTransaction();
             throw;
         }
     }
 }
開發者ID:ZixiangBoy,項目名稱:YongERP,代碼行數:19,代碼來源:InStockView.cs

示例7: btnOK_Click

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
                return;
            var odrs = gcOrder.GetDataSource<t_order>();
            if (odrs == null || odrs.Count < 1) {
                MsgBox.ShowMessage("提示", "沒有添加商品不能保存!");
                return;
            }
            if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.New) {
                var trdnew = new t_trade() {
                    Guid = GuidKey,
                    ReceiverName = Trade.ReceiverName,
                    ReceiverMobile = Trade.ReceiverMobile,
                    ReceiverAddress = Trade.ReceiverAddress,
                    MemberGuid = Trade.Guid,
                    DeliveryDate = dateDeliveryDate.DateTime,
                    CreateDate = TimeSync.Default.CurrentSyncTime,
                    Creator = this.CurUser,
                };

                using (var db = new Database()) {
                    try {
                        db.BeginTransaction();
                        db.Save(trdnew);
                        odrs.ForEach(k => db.Save(k));
                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            } else if (EditMode == Ultra.Web.Core.Enums.EnViewEditMode.Edit) {
                using (var db = new Database()) {
                    var trd = db.FirstOrDefault<t_trade>(" where [email protected]", GuidKey);
                    trd.ReceiverName = Trade.ReceiverName;
                    trd.ReceiverMobile = txtMobile.Text;
                    trd.ReceiverAddress = txtReceiverAddress.Text;
                    trd.MemberGuid = Trade.Guid;
                    trd.DeliveryDate = TimeSync.Default.CurrentSyncTime;
                    trd.DeliveryDate = dateDeliveryDate.DateTime;
                    try {
                        db.BeginTransaction();
                        db.Save(trd);
                        db.Execute("delete t_order where [email protected]", trd.Guid);
                        odrs.ForEach(k => {
                            k.Id = 0;
                            db.Save(k);
                        });
                        db.CompleteTransaction();
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
開發者ID:flyeven,項目名稱:YongERP,代碼行數:59,代碼來源:NewView.cs


注:本文中的PetaPoco.Database.AbortTransaction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。