//public string JSONData(string id)
        //{
        //    return "You requested product " + id;
        //}
        public WorkOrder.Workorder JSONData(string ID)
        {
            DALDB dal = new DALDB(connStr);
            int id = int.Parse(ID);
            Workorder wo = dal.GetWorkorder(id);
            //string strEmp = emp.getEmployeeName(id);

            //MemoryStream stream1 = new MemoryStream();
            //DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Employee));
            //ser.WriteObject(stream1, emp);
            //string json = Encoding.Default.GetString(stream1.ToArray());

            return wo;
        }
        public int UpdateWorkorder(Stream stream)
        {
            DALDB dal = new DALDB(connStr);
            WorkOrder.Workorder wo = new Workorder();
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(WorkOrder.Workorder));
            wo = (WorkOrder.Workorder)ser.ReadObject(stream);

            if (wo != null)
            {
                if (dal.GetWorkorder(wo.wo_ID) != null)
                {
                    dal.UpdateWorkorder(wo);
                }
                return 1;
            }
            dal.AddWorkorder(wo);
            //string fileName = Server.MapPath("Output.txt");
            // write a text file
            FileStream fs = new FileStream(@"c:\xworkorders.txt", FileMode.Append);
            TextWriter tws = new StreamWriter(fs);

            // write the current datetime to the stream
            tws.WriteLine(DateTime.Now);

            // write test strings to the stream
            tws.WriteLine(wo.wo_ID);
            tws.WriteLine(wo.wo_Number);
            tws.WriteLine(wo.wo_Date);
            tws.WriteLine(wo.wo_Debtor);
            tws.WriteLine(wo.wo_Address);
            tws.WriteLine(wo.wo_StartTime);

            tws.Close();   // close the stream

            return 1;
        }