public string UpdateWorkorderRouting(string workorderRoutingNo, string statusId, string stateId) { DataClassesDataContext ctx = new DataClassesDataContext("Data Source=AIP-SQLAIPL;Initial Catalog=Aipl;User ID=ambiflux;Password=ambiflux"); try { var wor = (from w in ctx.WorkOrderRouting where w.WorkOrderRoutingNo == workorderRoutingNo select w).SingleOrDefault(); if (wor != null) { wor.StateID = System.Convert.ToInt16(stateId); wor.WorkOrderRoutingStatusId = System.Convert.ToInt16(statusId); ctx.SubmitChanges(); return "OK"; } return "No record"; } catch (Exception e) { return (e.Message); } }
//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"; }
public ProductInventoryRecord SetProductInventory(string productId, string locationId, string quantity) { DataClassesDataContext ctx = new DataClassesDataContext("Data Source=AIP-SQLAIPL;Initial Catalog=Aipl;User ID=ambiflux;Password=ambiflux"); var productInventory = (from pi in ctx.ProductInventory where pi.LocationID == System.Convert.ToInt32(locationId) && pi.ProductID == System.Convert.ToInt32(productId) select pi).SingleOrDefault(); if (productInventory != null) { productInventory.Quantity = System.Convert.ToInt16(quantity); ctx.SubmitChanges(); } return (from pi in ctx.ProductInventory where (pi.LocationID == System.Convert.ToInt32(locationId) && pi.ProductID == System.Convert.ToInt32(productId)) select new ProductInventoryRecord { Location = new LocationRecord { LocationID = pi.Location.LocationID, LocationName = pi.Location.Name.TrimEnd() }, ProductID = System.Convert.ToInt32(productId), Shelf = pi.Shelf, Quantity = pi.Quantity, Capacity = pi.Capacity, DeliverThreshold = System.Convert.ToInt32(pi.DeliverThreshold), SupplyThreshold = System.Convert.ToInt32(pi.SupplyThreshold) }).SingleOrDefault(); }
public ResourceRecord LogSRMA() { DataClassesDataContext ctx = new DataClassesDataContext("Data Source=AIP-SQLAIPL;Initial Catalog=Aipl;User ID=ambiflux;Password=ambiflux"); var srma = (from c in ctx.Resource where c.ResourceID == 9 select c).SingleOrDefault(); if(srma!=null) { srma.DateModified = System.DateTime.Now; ctx.SubmitChanges(); } return (from c in ctx.Resource where c.ResourceID == 9 select new ResourceRecord { Name=c.Name.TrimEnd(), //DateModified=c.DateModified }).SingleOrDefault(); //return srma as ResourceRecord; }