Beispiel #1
0
        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 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_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();
        }
Beispiel #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     Trade = gc.GetFocusedDataSource<t_trade>();
     if (Trade == null)
         return;
     DialogResult = System.Windows.Forms.DialogResult.OK;
     Close();
 }
Beispiel #3
0
        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,
                    TradeNo         = Ultra.Trade.Common.GetSerialNo("销售单"),
                    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 => { k.Guid = Guid.NewGuid(); 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();
        }
Beispiel #4
0
        private void txtMemberName_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var vw = new SendedTradeView();
            if (vw.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                this.Trade = vw.Trade;

                dateDeliveryDate.DateTime = this.Trade.DeliveryDate ?? DateTime.Now;
                txtMobile.Text = this.Trade.ReceiverMobile;
                txtReceiverAddress.Text = this.Trade.ReceiverAddress;

                using (var db = new Database()) {
                    gcOrder.DataSource = db.Fetch<t_order>("select * from t_order");
                }
            }
        }