Beispiel #1
0
 public static void SetInstance(Order_Type anInstance)
 {
     if (anInstance != null)
     {
         instance = anInstance;
     }
 }
 private void AddButton_Click(object sender, RoutedEventArgs e)
 {
     using (MyDBContext db = new MyDBContext())
     {
         if (!String.IsNullOrWhiteSpace(NameBox.Text) &&
             !String.IsNullOrWhiteSpace(DescrBox.Text) &&
             !String.IsNullOrWhiteSpace(StatusBox.Text))
         {
             Order_Type order_Type = new Order_Type
             {
                 ID          = db.Order_Types.Count() + 1,
                 Name        = NameBox.Text,
                 Description = DescrBox.Text,
                 Status      = StatusBox.Text
             };
             if (EditID == -1)
             {
                 db.Order_Types.Add(order_Type);
             }
             else
             {
                 var result = db.Order_Types.Find(EditID);
                 result.Name        = NameBox.Text;
                 result.Status      = StatusBox.Text;
                 result.Description = DescrBox.Text;
             }
         }
         else
         {
             MessageBox.Show("Заполнены не все поля");
         }
         db.SaveChanges();
         this.Close();
     }
 }
Beispiel #3
0
        public IHttpActionResult PutOrder_Type(int id, Order_Type order_Type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != order_Type.Order_Type_ID)
            {
                return(BadRequest());
            }

            db.Entry(order_Type).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Order_TypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #4
0
        public IHttpActionResult GetOrder_Type(int id)
        {
            Order_Type order_Type = db.Order_Type.Find(id);

            if (order_Type == null)
            {
                return(NotFound());
            }

            return(Ok(order_Type));
        }
Beispiel #5
0
        public IHttpActionResult PostOrder_Type(Order_Type order_Type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Order_Type.Add(order_Type);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = order_Type.Order_Type_ID }, order_Type));
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     using (MyDBContext db = new MyDBContext())
     {
         Order_Type EditOrder_Type = db.Order_Types.Find(EditID);
         if (EditID != -1)
         {
             AddButton.Content = "Сохранить";
             NameBox.Text      = EditOrder_Type.Name;
             StatusBox.Text    = EditOrder_Type.Status;
             DescrBox.Text     = EditOrder_Type.Description;
         }
     }
 }
Beispiel #7
0
 public static Order_Type GetOrderType()
 {
     if (instance == null)
     {
         lock (lockHelper)
         {
             if (instance == null)
             {
                 instance = new Order_Type();
             }
         }
     }
     return(instance);
 }
Beispiel #8
0
        public IHttpActionResult DeleteOrder_Type(int id)
        {
            Order_Type order_Type = db.Order_Type.Find(id);

            if (order_Type == null)
            {
                return(NotFound());
            }

            db.Order_Type.Remove(order_Type);
            db.SaveChanges();

            return(Ok(order_Type));
        }
Beispiel #9
0
        /// <summary>
        /// 单据类型为DataTable
        /// </summary>
        public static DataTable GetOrder_Type()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("ID", typeof(string));
            dt.Columns.Add("InOut", typeof(string));
            dt.Columns.Add("Other", typeof(string));

            foreach (Order_Type.Rewrite OrderType in Order_Type.GetOrderType().OrderType)
            {
                DataRow dr = dt.NewRow();
                dr["Name"]  = OrderType.Name;
                dr["ID"]    = OrderType.ID;
                dr["InOut"] = OrderType.InOut;
                dr["Other"] = OrderType.Other;

                dt.Rows.Add(dr);
            }
            dt.AcceptChanges();
            return(dt);
        }
Beispiel #10
0
        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="ip"></param>
        /// <param name="payMoney"></param>
        /// <param name="price"></param>
        /// <param name="description"></param>
        /// <param name="orderType"></param>
        /// <param name="payType"></param>
        /// <returns></returns>
        public Order AddOrder(int activityId, string ip, decimal payMoney, decimal price, string description,
                              Order_Type orderType, Order_PayType payType = Order_PayType.微信支付)
        {
            var order = new Order()
            {
                OrderNumber  = this.GetAvalibleOrderNumber(),
                AddTime      = DateTime.Now,
                CompleteTime = DateTime.Now,
                //AccountId = accountId,
                ActivityId  = activityId,
                AddIp       = ip,
                PayMoney    = payMoney,
                Price       = price,
                Description = description ?? "",
                Status      = (int)Order_Status.未支付,
                PayType     = (int)payType,
                TotalPrice  = payMoney,
                OrderType   = (int)orderType,
            };

            SaveObject(order);
            return(order);
        }