partial void DeleteWorkOrder(WorkOrder instance);
		private void detach_WorkOrder(WorkOrder entity)
		{
			this.SendPropertyChanging();
			entity.WorkOrderStatus = null;
		}
 partial void UpdateWorkOrder(WorkOrder instance);
 partial void InsertWorkOrder(WorkOrder instance);
		private void detach_WorkOrder(WorkOrder entity)
		{
			this.SendPropertyChanging();
			entity.OrderHeader = null;
		}
		private void attach_WorkOrder(WorkOrder entity)
		{
			this.SendPropertyChanging();
			entity.OrderHeader = this;
		}
Esempio n. 7
0
        //public string NewSRMARequest()
        public string NewSRMARequest(string phoneNumber, string locationId)
        {
            if (phoneNumber == "") phoneNumber = "0000000000";

                //1- on regarde s'il existe un contact avec le numéro de tél

                DataClassesDataContext ctx = new DataClassesDataContext("Data Source=AIP-SQLAIPL;Initial Catalog=Aipl;User ID=ambiflux;Password=ambiflux");

                var contact = (from c in ctx.Contact where c.Phone == phoneNumber select c).SingleOrDefault();
                if (contact != null)
                //on recherche le customer correspondant
                {
                    var customer = (from c in ctx.Customer where c.Contact == contact select c).SingleOrDefault();
                    //normalement on passe par là!
                    if (customer != null)
                    {
                        //Création d'un nouvel orderHeader
                        OrderHeader o = new OrderHeader();
                        o.Customer = customer;

                        var loc = (from l in ctx.Location where l.LocationID == System.Convert.ToInt32(locationId) select l).SingleOrDefault();
                        o.Location = loc;
                        //o.DeliveryLocationID = System.Convert.ToInt32(locationId);
                        o.OrderType = 'C';
                        o.Comment = "Demande effectuee par tél";
                        o.OrderStatusID = 1;
                        o.OrderDate = System.DateTime.Now;

                        ctx.OrderHeader.InsertOnSubmit(o);
                        ctx.SubmitChanges();

                        WorkOrder wo = new WorkOrder();
                        wo.OrderHeader = o;
                        wo.Type = "CAL";
                        wo.WorkOrderStatusID = 1;

                        wo.OrderHeader = o;

                        ctx.WorkOrder.InsertOnSubmit(wo);
                        //ctx.SubmitChanges();

                        //Wor Transport vers demandeur
                        WorkOrderRouting worT = new WorkOrderRouting();
                        worT.Location = loc;
                        worT.Type = 'T';
                        worT.OperationSequence = 10;
                        worT.StateID = 1;
                        worT.WorkOrderRoutingStatusId = 1;

                        worT.WorkOrder = wo;

                        ctx.WorkOrderRouting.InsertOnSubmit(worT);
                        //wor chargement/dialogue avec demandeur
                        WorkOrderRouting worA = new WorkOrderRouting();
                        worA.Location = loc;
                        worA.Type = 'A';
                        worA.OperationSequence = 20;
                        worA.StateID = 1;
                        worA.WorkOrderRoutingStatusId = 1;

                        worA.WorkOrder = wo;

                        ctx.WorkOrderRouting.InsertOnSubmit(worA);

                        ctx.SubmitChanges();

                        return "ok";
                    }

                }

               /* return (from w in ctx.V_Order
                        where w.OrderID == System.Convert.ToInt32(orderHeaderId)
                        select new OrderHeaderRecord
                        {
                            OrderId = w.OrderID,
                            OrderNo = w.OrderNo,
                            ObjetDemandeExpress = w.ObjetDemandeExpress,
                            CustomerFirstName = w.CustomerFirstName,
                            CustomerLastName = w.CustomerLastName,
                            OrderDate = w.OrderDate.ToString()
                        }).SingleOrDefault();
               */

            /*

                SqlCommand cmd = new SqlCommand("insert into Workorder(Type) values(@Type)", conn);

                cmd.Parameters.AddWithValue("@Type", 'T');
                int result = cmd.ExecuteNonQuery();
                string Message;
                if (result == 1)
                {
                    Message = " Details inserted successfully";
                }
                else
                {
                    Message = " Details not inserted successfully";
                }

                //conn.Close();

                return Message;

            //}*/
                return "Pas OK";
        }