コード例 #1
0
ファイル: MainService.svc.cs プロジェクト: Montka/WCFServer
        public bool AddOrder(OrderType composite)
        {
            var tables = new LinqWorkerDataContext();

            if (tables.Orders.All(x => x.Date != composite.Date ))
            {
                string type = "user", message = string.Empty;

                var order = new Orders
                    {
                        UserId = composite.UserId,
                        Article = composite.Article,
                        Date =  composite.Date,
                        Comment = composite.Comment,
                        ItemCount =  composite.ItemCount,
                        ItemId = composite.ItemId
                    };

                try
                {
                    String command =
                        String.Format(
                            "INSERT INTO dbo.Orders(Article,UserId,Date,Comment,Itemid,ItemCount) VALUES(\'{0}\',\'{1}\',\'{2}\',\'{3}\',\'{4}\',\'{5}\')",
                            order.Article,
                            order.UserId,
                            order.Date,
                            order.Comment,
                            order.ItemId,
                             order.ItemCount
                            );

                    tables.ExecuteCommand(command);

                    message = "Добавлена новая заявка : " + order.Article;
                    //tables.Orders.Context.SubmitChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    message = "Ошибка при добавление заявки : " + order.Article;
                    type = "system";
                    Console.WriteLine(ex.Message);
                    return false;
                }
                finally
                {
                    AddLog(type, message, DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                }
            }
            return false;
        }
コード例 #2
0
ファイル: MainService.svc.cs プロジェクト: Montka/WCFServer
        public bool UptadeOrder(OrderType composite)
        {
            var tables = new LinqWorkerDataContext();
            string type = "user", message = string.Empty;
            try
            {
                var order = tables.Orders.Single(c => c.Id == composite.Id);

                order.Article = composite.Article;
                order.Date = composite.Date;
                order.UserId = composite.UserId;
                order.Comment = composite.Comment;
                order.ItemId = composite.ItemId;
                order.ItemCount = composite.ItemCount;

                tables.Orders.Context.SubmitChanges();

                message = "Обновление заявки : " + composite.Article;
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                message = "Ошибка при обновлении заявки : " + composite.Article;
                type = "system";
                return false;
            }
            finally
            {
                AddLog(type, message, DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
            }
            /*
                        return false;
            */
        }
コード例 #3
0
ファイル: MainService.svc.cs プロジェクト: Montka/WCFServer
        public bool DeleteOrder(OrderType composite)
        {
            var tables = new LinqWorkerDataContext();
            string type = "user", message = string.Empty;
            try
            {
                var order = tables.Orders.Single(c => c.Id == composite.Id);
                tables.Orders.DeleteOnSubmit(order);
                tables.Orders.Context.SubmitChanges();

                message = "Заявка удалена : " + composite.Article;
                return true;
            }
            catch (Exception ex)
            {
                message = "Ошибка при удалении заявки : " + composite.Article;
                type = "system";
                return false;
            }
            finally
            {
                AddLog(type, message, DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
            }

            /*
                        return false;
            */
        }