예제 #1
1
 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();
     }
 }
예제 #2
0
파일: NewView.cs 프로젝트: flyeven/YongERP
        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 = memgcEdt.GetSelectedValue().ReceiverName,
                    ReceiverMobile = memgcEdt.GetSelectedValue().ReceiverMobile,
                    ReceiverAddress = memgcEdt.GetSelectedValue().ReceiverAddress,
                    MemberGuid = memgcEdt.GetSelectedValue().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 guid=@0", GuidKey);
                    trd.ReceiverName = memgcEdt.GetSelectedValue().ReceiverName;
                    trd.ReceiverMobile = txtMobile.Text;
                    trd.ReceiverAddress = txtReceiverAddress.Text;
                    trd.MemberGuid = memgcEdt.GetSelectedValue().Guid;
                    trd.DeliveryDate = TimeSync.Default.CurrentSyncTime;
                    trd.DeliveryDate = dateDeliveryDate.DateTime;
                    try {
                        db.BeginTransaction();
                        db.Save(trd);
                        db.Execute("delete t_order where tradeguid=@0", 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();
        }
        protected override void ResetDatabase()
        {
            using (var database = new Database("SQLiteTest"))
            {
                database.BeginTransaction();

                database.Execute(new Sql("DELETE FROM Entity"));
                database.Execute(new Sql("DELETE FROM sqlite_sequence WHERE name = @0", "Entity"));

                database.CompleteTransaction();
            }
        }
예제 #4
0
 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 RoleId=@0", 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, "保存成功!");
 }
예제 #5
0
 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 guid=@0", 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 tradeguid=@0", 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();
 }
예제 #6
0
        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 instockno=@0", 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();
        }
예제 #7
0
 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 guid=@0", trd.Guid);
             db.CompleteTransaction();
             gcUnAudit.RemoveSelected();
         } catch (Exception) {
             db.AbortTransaction();
             throw;
         }
     }
 }
예제 #8
0
 public void Complete()
 {
     _db.CompleteTransaction();
     _db = null;
 }
예제 #9
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnReView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var et = gcUnSub.GetFocusedDataSource<t_trade>();
            if (null == et)
                return;

            if (MsgBox.ShowYesNoMessage("", "确定要审核此出货单?") == DialogResult.Yes) {
                using (var db = new Database()) {
                    try {
                        var result = new SqlParameter() {
                            Direction = ParameterDirection.Output,
                            SqlDbType = SqlDbType.Bit,
                            ParameterName = "@result"
                        };
                        db.BeginTransaction();
                        db.Update<t_trade>(" set IsAudit=1 where guid=@0", et.Guid);
                        db.Execute("exec p_tradeupdateinvt @0,@1 output", et.Guid, result);

                        if (!(bool)result.Value) {
                            MsgBox.ShowMessage("", "库存不足!");
                            db.AbortTransaction();
                        } else {
                            db.CompleteTransaction();
                            gcUnSub.RemoveSelected();
                        }
                    } catch (Exception) {
                        db.AbortTransaction();
                        throw;
                    }
                }
            }
        }
예제 #10
0
 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 instockno=@0", et.InStockNo);
             //更新库存
             db.Execute("exec p_instockupdateinvt @0", et.InStockNo);
             db.CompleteTransaction();
             gcUnAudit.RemoveSelected();
         } catch (Exception) {
             db.AbortTransaction();
             throw;
         }
     }
 }