public WorkOrderStartEndRES WorkOrderEndService(WorkOrder_Start_EndREQ WOSE)
        {
            WorkOrderStartEndRES SM = new WorkOrderStartEndRES();

            try
            {
                if (WOSE.UserId == "" || WOSE.UserId == null)
                {
                    SM.Status  = "Failure";
                    SM.Message = "Invalid UserId";
                    return(SM);
                }
                if (WOSE.WorkOrderNo == "" || WOSE.WorkOrderNo == null)
                {
                    SM.Status  = "Failure";
                    SM.Message = "Invalid WorkOrderNo";
                    return(SM);
                }

                query     = "Sp_AxWebserviceIntegration";
                dbcommand = new SqlCommand(query, conn);
                //  dbcommand.Connection.Open();
                dbcommand.CommandType    = CommandType.StoredProcedure;
                dbcommand.CommandTimeout = 0;
                SqlDataAdapter da = new SqlDataAdapter(dbcommand);
                DataSet        ds = new DataSet();
                da.Fill(ds);

                //  DataSet ds = CommonManger.FillDatasetWithParam("Sp_AxWebserviceIntegration");
                AXWebServiceRef1.Iace_FinishedGoodServiceClient obj = new AXWebServiceRef1.Iace_FinishedGoodServiceClient();
                obj.ClientCredentials.Windows.ClientCredential.Domain   = Convert.ToString(ds.Tables[0].Rows[0]["Domain"]);
                obj.ClientCredentials.Windows.ClientCredential.UserName = Convert.ToString(ds.Tables[0].Rows[0]["Username"]);
                obj.ClientCredentials.Windows.ClientCredential.Password = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);

                AXWebServiceRef1.CallContext Cct = new AXWebServiceRef1.CallContext();
                Cct.Company  = Convert.ToString(ds.Tables[0].Rows[0]["Company"]);
                Cct.Language = Convert.ToString(ds.Tables[0].Rows[0]["Language"]);
                string value = obj.EndWorkOrder(Cct, WOSE.WorkOrderNo);



                query     = "Sp_WorkOrderWebApi";
                dbcommand = new SqlCommand(query, conn);
                dbcommand.Connection.Open();
                dbcommand.CommandType = CommandType.StoredProcedure;
                dbcommand.Parameters.AddWithValue("@QueryType", "WorkOrder_End");
                dbcommand.Parameters.AddWithValue("@WorkOrderNo", WOSE.WorkOrderNo);
                dbcommand.Parameters.AddWithValue("@UserId", WOSE.UserId);
                dbcommand.CommandTimeout = 0;
                da = new SqlDataAdapter(dbcommand);
                DataTable dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows[0]["value"].ToString() == "1")
                {
                    SM.Status  = "Success";
                    SM.Message = "WorkOrder Ended Successfully";
                }
                else
                {
                    SM.Status  = "Failure";
                    SM.Message = "Invalid WorkOrder No";
                }
            }
            catch (Exception Ex)
            {
                SM.Status  = "Failure";
                SM.Message = Ex.Message;
            }
            //finally
            //{
            //    //dbcommand.Connection.Close();
            //}
            return(SM);
        }