Example #1
0
        //   public HttpResponseMessage Post(string SelectedTests)
        public HttpResponseMessage Get(string SelectedTests, string WorkStudyID)
        {
            AdoHelper ado = new AdoHelper();
            //SqlDataReader reader = null;

            List <RNDTesting>   lstTests        = new List <RNDTesting>();
            List <SqlParameter> lstSqlParameter = new List <SqlParameter>();

            //if (SelectedTests == null)
            //    SelectedTests = "ALL";

            SqlParameter param0 = new SqlParameter("@TestingNos", SelectedTests);
            SqlParameter param1 = new SqlParameter("@WorkStudyID", @WorkStudyID);

            using (SqlDataReader reader = ado.ExecDataReaderProc("RNDPrintTesting", "RND", param0, param1))
            {
                if (reader.HasRows)
                {
                    RNDTesting TM = null;
                    while (reader.Read())
                    {
                        TM               = new RNDTesting();
                        TM.total         = Convert.ToInt32(reader["total"]);
                        TM.TestingNo     = Convert.ToInt32(reader["TestingNo"]);
                        TM.Alloy         = Convert.ToString(reader["Alloy"]);
                        TM.GageThickness = Convert.ToString(reader["GageThickness"]);
                        TM.Hole          = Convert.ToString(reader["Hole"]);
                        TM.Location1     = Convert.ToString(reader["Location1"]);
                        TM.Location2     = Convert.ToString(reader["Location2"]);
                        TM.Location3     = Convert.ToString(reader["Location3"]);
                        TM.LotID         = Convert.ToString(reader["LotID"]);
                        TM.Orientation   = Convert.ToString(reader["Orientation"]);
                        TM.PieceNo       = Convert.ToString(reader["PieceNo"]);
                        TM.SpeciComment  = Convert.ToString(reader["SpeciComment"]);
                        TM.TestType      = Convert.ToString(reader["TestType"]);
                        TM.SubTestType   = Convert.ToString(reader["SubTestType"]);
                        TM.Temper        = Convert.ToString(reader["Temper"]);
                        TM.TestLab       = Convert.ToString(reader["TestLab"]);
                        TM.UACPart       = Convert.ToInt32(reader["UACPart"]);
                        TM.WorkStudyID   = Convert.ToString(reader["WorkStudyID"]);
                        TM.Printed       = Convert.ToChar(reader["Printed"]);
                        lstTests.Add(TM);
                    }
                }
                if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                {
                    ado._conn.Close(); ado._conn.Dispose();
                }
            }
            DataSearch <RNDTesting> ds = new DataSearch <RNDTesting>
            {
                items = lstTests,
                total = (lstTests != null && lstTests.Count > 0) ? lstTests[0].total : 0
            };

            return(Serializer.ReturnContent(ds, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
        }
Example #2
0
        /// <summary>
        /// send TestType as parameter and return SubTestype - list - for dropdown
        /// </summary>
        /// <param name="TestType"></param>
        /// <returns></returns>
        public HttpResponseMessage Get(int flag, int recID, string TestType)
        {
            _logger.Debug("Testing Get with TestType Called");
            //SqlDataReader reader = null;
            RNDTesting TM = null;

            CurrentUser user = ApiUser;

            TM = new RNDTesting();
            AdoHelper ado = new AdoHelper();

            TM.ddSubTestType = new List <SelectListItem>()
            {
                GetInitialSelectItem()
            };
            try
            {
                if (!string.IsNullOrEmpty(TestType))
                {
                    SqlParameter param0 = new SqlParameter("@TestType", TestType);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDSubTestType_READ", "RND", param0))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddSubTestType.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["SubTestType"]),
                                    Text     = Convert.ToString(reader["SubTestType"]),
                                    Selected = (TM.SubTestType == Convert.ToString(reader["SubTestType"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                }

                return(Serializer.ReturnContent(TM, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
        public ActionResult SaveTestingMaterial(RNDTesting model)
        {
            var client = GetHttpClient();
            //  var task = client.PostAsJsonAsync(Api + "api/TestingMaterial", model).ContinueWith((res) =>
            var task = client.PostAsJsonAsync(Api + "api/Testing", model).ContinueWith((res) =>
            {
                if (res.Result.IsSuccessStatusCode)
                {
                    RNDTesting rndTesting = JsonConvert.DeserializeObject <RNDTesting>(res.Result.Content.ReadAsStringAsync().Result);
                    if (rndTesting != null)
                    {
                    }
                }
            });

            task.Wait();
            return(RedirectToAction("TestingMaterialList", new { RecID = model.TestingNo, workStudyID = model.WorkStudyID }));
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Loc2"></param>
        /// <param name="LotId"></param>
        /// <returns></returns>
        public HttpResponseMessage Get(string Loc2, string LotId, string WorkStudyID)
        {
            _logger.Debug("Testing Get with WorkStudy and Loc2");
            // SqlDataReader reader = null;
            RNDTesting TM = null;

            CurrentUser user = ApiUser;

            TM = new RNDTesting();
            AdoHelper ado = new AdoHelper();

            try
            {
                if (!string.IsNullOrEmpty(LotId))
                {
                    int MillLotNo = findMillLotNo(LotId);

                    SqlParameter param0 = new SqlParameter("@MillLotNo", MillLotNo);
                    SqlParameter param1 = new SqlParameter("@Loc2", Loc2);
                    SqlParameter param2 = new SqlParameter("@WorkStudyID", WorkStudyID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGageThickness_READ", "RND", param2, param0, param1))
                    {
                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                TM.GageThickness = Convert.ToString(reader["GageThickness"]);
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                }
                return(Serializer.ReturnContent(TM, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
        public ActionResult TestingMaterialList(int RecID, string workStudyID)
        {
            _logger.Debug("TestingMaterialList");

            List <SelectListItem> ddlTestType = null;
            List <SelectListItem> ddlLotID    = null;

            RNDTesting testing = null;

            try
            {
                ddlTestType = new List <SelectListItem>();
                var client = GetHttpClient();
                var task   = client.GetAsync(Api + "api/Testing?RecID=0").ContinueWith((res) =>
                {
                    if (res.Result.IsSuccessStatusCode)
                    {
                        RNDTesting rndTesting = JsonConvert.DeserializeObject <RNDTesting>(res.Result.Content.ReadAsStringAsync().Result);
                        if (rndTesting != null)
                        {
                            ddlTestType = rndTesting.ddTestType;
                            ddlLotID    = rndTesting.ddLotID;
                        }
                    }
                });
                task.Wait();
                testing = new RNDTesting
                {
                    WorkStudyID = workStudyID
                };
                ViewBag.ddlTestType    = ddlTestType;
                ViewBag.ddlAvailableTT = ddlTestType;

                ViewBag.ddlLotID = ddlLotID;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(View(testing));
        }
Example #6
0
        public HttpResponseMessage Post(RNDTesting TestingMaterial)
        {
            // SqlDataReader reader = null;
            try
            {
                CurrentUser user = ApiUser;
                AdoHelper   ado  = new AdoHelper();

                int MillLotNo = findMillLotNo(TestingMaterial.LotID);

                SqlParameter param31 = new SqlParameter("@MillLotNo", MillLotNo);
                using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetAlloyPartTemper", "RND", param31))
                {
                    if (reader.HasRows)
                    {
                        if (reader.Read())
                        {
                            TestingMaterial.UACPart  = Convert.ToDecimal(reader["UACPart"]);
                            TestingMaterial.CustPart = Convert.ToString(reader["CustPart"]);
                            TestingMaterial.Alloy    = Convert.ToString(reader["Alloy"]);
                            TestingMaterial.Temper   = Convert.ToString(reader["Temper"]);
                        }
                    }
                    if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                    {
                        ado._conn.Close(); ado._conn.Dispose();
                    }
                }

                SqlParameter param32 = new SqlParameter("@ProcessID", TestingMaterial.LotID);
                using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetSoNumByProcessID", "RND", param32))
                {
                    if (reader.HasRows)
                    {
                        if (reader.Read())
                        {
                            TestingMaterial.SoNum = Convert.ToString(reader["Sonum"]);
                        }
                    }
                    if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                    {
                        ado._conn.Close(); ado._conn.Dispose();
                    }
                }

                if (TestingMaterial.Location2 != null)
                {
                    if (TestingMaterial.Location2.Trim() == "-1")
                    {
                        TestingMaterial.Location2 = "";
                    }
                }
                else
                {
                    TestingMaterial.Location2 = "";
                }

                if (TestingMaterial.GageThickness == null)
                {
                    TestingMaterial.GageThickness = "";
                }

                if (TestingMaterial.SpeciComment == null)
                {
                    TestingMaterial.SpeciComment = "";
                }
                string PieceNo = TestingMaterial.PieceNo;
                if ((PieceNo.Trim()) == "-1")
                {
                    TestingMaterial.PieceNo = "";
                }
                string Hole = TestingMaterial.Hole;
                if ((Hole.Trim()) == "-1")
                {
                    TestingMaterial.Hole = "";
                }
                if (TestingMaterial.TestLab == null)
                {
                    TestingMaterial.TestLab = "Canton";
                }
                if (TestingMaterial.Location3 == null)
                {
                    TestingMaterial.Location3 = "";
                }
                SqlParameter param1  = new SqlParameter("@WorkStudyID", TestingMaterial.WorkStudyID);
                SqlParameter param2  = new SqlParameter("@LotID", TestingMaterial.LotID);
                SqlParameter param3  = new SqlParameter("@MillLotNo", MillLotNo);
                SqlParameter param4  = new SqlParameter("@SoNum", TestingMaterial.SoNum);
                SqlParameter param5  = new SqlParameter("@Hole", TestingMaterial.Hole);
                SqlParameter param6  = new SqlParameter("@PieceNo", TestingMaterial.PieceNo);
                SqlParameter param7  = new SqlParameter("@Alloy", TestingMaterial.Alloy);
                SqlParameter param8  = new SqlParameter("@Temper", TestingMaterial.Temper);
                SqlParameter param9  = new SqlParameter("@CustPart", TestingMaterial.CustPart);
                SqlParameter param10 = new SqlParameter("@UACPart", TestingMaterial.UACPart);
                SqlParameter param11 = new SqlParameter("@GageThickness", TestingMaterial.GageThickness);
                SqlParameter param12 = new SqlParameter("@Orientation", TestingMaterial.Orientation);
                SqlParameter param13 = new SqlParameter("@Location1", TestingMaterial.Location1);
                SqlParameter param14 = new SqlParameter("@Location2", TestingMaterial.Location2);
                SqlParameter param15 = new SqlParameter("@Location3", TestingMaterial.Location3);
                SqlParameter param16 = new SqlParameter("@SpeciComment", TestingMaterial.SpeciComment);
                SqlParameter param17 = new SqlParameter("@TestType", TestingMaterial.TestType);
                SqlParameter param18 = new SqlParameter("@SubTestType", TestingMaterial.SubTestType);
                SqlParameter param19 = new SqlParameter("@Status", TestingMaterial.Status);
                SqlParameter param20 = new SqlParameter("@Selected", TestingMaterial.Selected);
                SqlParameter param21 = new SqlParameter("@EntryDate", DateTime.Now);
                // SqlParameter param22 = new SqlParameter("@EntryBy", user.UserId);
                SqlParameter param22 = new SqlParameter("@EntryBy", user.UserName);
                SqlParameter param23 = new SqlParameter("@TestLab", TestingMaterial.TestLab);
                SqlParameter param24 = new SqlParameter("@Printed", TestingMaterial.Printed);
                SqlParameter param25 = new SqlParameter("@Replica", TestingMaterial.Replica);
                //SqlParameter param26 = new SqlParameter("@RCS", TestingMaterial.RCS);

                int ReplicaCount = 1;
                if (TestingMaterial.Replica != null)
                {
                    ReplicaCount = Convert.ToInt32(TestingMaterial.Replica);
                }


                SqlParameter param27 = new SqlParameter("@ReplicaCount", ReplicaCount);
                if (TestingMaterial.TestingNo > 0)
                {
                    SqlParameter param30 = new SqlParameter("TestingNo", TestingMaterial.TestingNo);

                    ado.ExecScalarProc("RNDTestingMaterial_Update", "RND", new object[] { param1, param2, param3,
                                                                                          param4, param5, param6, param7, param8, param9, param10, param11, param12,
                                                                                          param13, param14, param15, param16, param17, param18, param19, param20,
                                                                                          param21, param22, param23, param24, param30 });
                }
                else
                {
                    ado.ExecScalarProc("RNDTestingMaterial_Insert", "RND", new object[] { param1, param2, param3,
                                                                                          param4, param5, param6, param7, param8, param9, param10, param11, param12,
                                                                                          param13, param14, param15, param16, param17, param18, param19, param20,
                                                                                          param21, param22, param23, param24, param25, param27 });
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
            return(Serializer.ReturnContent(TestingMaterial, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
        }
Example #7
0
        public HttpResponseMessage Get(string WorkStudyID, string LotID, int recID)
        {
            // read MillLotNo,SoNum,Hole,PieceNo - from RNDProcessing
            // send MillLotNo - as parameter read UACPArt, Alloy , Temper from RNDMAterial - give the first record.

            _logger.Debug("Testing Get with WorkStudy and LotID Called");
            //SqlDataReader reader = null;
            RNDTesting TM = null;

            CurrentUser user = ApiUser;

            TM = new RNDTesting();
            AdoHelper ado = new AdoHelper();


            //    TM.ddGageThickness = new List<SelectListItem>() { GetInitialSelectItem() };
            TM.ddHole = new List <SelectListItem>()
            {
                GetInitialSelectItem()
            };
            TM.ddPieceNo = new List <SelectListItem>()
            {
                GetInitialSelectItem()
            };
            TM.ddLocation2 = new List <SelectListItem>()
            {
                GetInitialSelectItem()
            };
            // TM.ddSubTestType = new List<SelectListItem>() { GetInitialSelectItem() };

            try
            {
                //alloy temper uacpart and cust part can be added directly to table - its not in UI.
                //if (!string.IsNullOrEmpty(WorkStudyID) && !string.IsNullOrEmpty(LotID) && !string.IsNullOrEmpty(TestType))

                if (!string.IsNullOrEmpty(WorkStudyID) && !string.IsNullOrEmpty(LotID))
                {
                    int MillLotNo = findMillLotNo(LotID);

                    //can be called during insert - as it is not in UI

                    // SqlParameter param0 = new SqlParameter("@MillLotNo", MillLotNo);
                    //// SqlParameter param1 = new SqlParameter("@testdesc", TestType);

                    // using (reader = ado.ExecDataReaderProc("RNDGetAlloyPartTemper", "RND", param0))
                    // {
                    //     if (reader.HasRows)
                    //     {
                    //         if (reader.Read())
                    //         {
                    //             TM.UACPart = Convert.ToDecimal(reader["UACPart"]);
                    //             TM.CustPart = Convert.ToString(reader["CustPart"]);
                    //             TM.Alloy = Convert.ToString(reader["Alloy"]);
                    //             TM.Temper = Convert.ToString(reader["Temper"]);
                    //         }
                    //     }
                    // }

                    //populate the Location2 dropdown menu - after getting the LotID from the user.
                    SqlParameter param1  = new SqlParameter("@MillLotNo", MillLotNo);
                    SqlParameter param11 = new SqlParameter("@WorkStudyID", WorkStudyID);

                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetLocation2", "RND", param1, param11))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddLocation2.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["Location2"]),
                                    Text     = Convert.ToString(reader["Location2"]),
                                    Selected = (TM.Location2 == Convert.ToString(reader["Location2"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }

                    // SoNum can be directly added in table - it not in UI.
                    //Hole Piece No and Loc 2 - need to be drop down menus.

                    // SqlParameter param1 = new SqlParameter("@testdesc", TestType);

                    SqlParameter param2 = new SqlParameter("@ProcessID", LotID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetHole", "RND", param2))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddHole.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["Hole"]),
                                    Text     = Convert.ToString(reader["Hole"]),
                                    Selected = (TM.Hole == Convert.ToString(reader["Hole"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                    SqlParameter param3 = new SqlParameter("@ProcessID", LotID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetPieceNo", "RND", param3))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddPieceNo.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["PieceNo"]),
                                    Text     = Convert.ToString(reader["PieceNo"]),
                                    Selected = (TM.PieceNo == Convert.ToString(reader["PieceNo"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                }
                return(Serializer.ReturnContent(TM, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Example #8
0
        public HttpResponseMessage Get(int recID)
        {
            _logger.Debug("Testing Get Called");
            //SqlDataReader reader = null;
            RNDTesting TM = null;

            try
            {
                CurrentUser user = ApiUser;
                TM = new RNDTesting();
                AdoHelper ado = new AdoHelper();

                //  TM.ddTestType = new List<SelectListItem>() { GetInitialSelectItem() };
                TM.ddTestType = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                TM.ddLotID = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                TM.ddSubTestType = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                TM.ddLocation2 = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                TM.ddHole = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };
                TM.ddPieceNo = new List <SelectListItem>()
                {
                    GetInitialSelectItem()
                };

                if (recID > 0)
                {
                    //edit
                    SqlParameter param1 = new SqlParameter("@TestingNo", recID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDTestingMaterial_ReadByTestingNo", "RND", new object[] { param1 }))
                    {
                        if (reader.HasRows)
                        {
                            if (reader.Read())
                            {
                                TM.TestingNo     = Convert.ToInt32(reader["TestingNo"]);
                                TM.WorkStudyID   = Convert.ToString(reader["WorkStudyID"]);
                                TM.LotID         = Convert.ToString(reader["LotID"]);
                                TM.MillLotNo     = Convert.ToInt32(reader["MillLotNo"]);
                                TM.SoNum         = Convert.ToString(reader["SoNum"]);
                                TM.Hole          = Convert.ToString(reader["Hole"]);
                                TM.PieceNo       = Convert.ToString(reader["PieceNo"]);
                                TM.Alloy         = Convert.ToString(reader["Alloy"]);
                                TM.Temper        = Convert.ToString(reader["Temper"]);
                                TM.CustPart      = Convert.ToString(reader["CustPart"]);
                                TM.UACPart       = Convert.ToInt32(reader["UACPart"]);
                                TM.GageThickness = Convert.ToString(reader["GageThickness"]);
                                TM.Orientation   = Convert.ToString(reader["Orientation"]);
                                TM.Location1     = Convert.ToString(reader["Location1"]);
                                TM.Location2     = Convert.ToString(reader["Location2"]);
                                TM.Location3     = Convert.ToString(reader["Location3"]);
                                TM.SpeciComment  = Convert.ToString(reader["SpeciComment"]);
                                TM.TestType      = Convert.ToString(reader["TestType"]).Trim();
                                TM.SubTestType   = Convert.ToString(reader["SubTestType"]);
                                TM.Status        = Convert.ToChar(reader["Status"]);
                                TM.Selected      = Convert.ToChar(reader["Selected"]);
                                TM.EntryDate     = (!string.IsNullOrEmpty(reader["EntryDate"].ToString())) ? Convert.ToDateTime(reader["EntryDate"]) : (DateTime?)null;
                                TM.EntryBy       = Convert.ToString(reader["EntryBy"]);
                                TM.TestLab       = Convert.ToString(reader["TestLab"]);
                                TM.Printed       = Convert.ToChar(reader["Printed"]);
                                TM.Replica       = Convert.ToString(reader["Replica"]);
                                // TM.RCS = Convert.ToChar(reader["RCS"]);
                                TM.total = 0;
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                    string       WorkStudyID = TM.WorkStudyID;
                    SqlParameter param2      = new SqlParameter("@WorkStudyID", WorkStudyID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDLotID_READ", "RND", param2))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddLotID.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["LotID"]),
                                    Text     = Convert.ToString(reader["LotID"]),
                                    Selected = (TM.LotID == Convert.ToString(reader["LotID"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                    SqlParameter param3 = new SqlParameter("@TestType", TM.TestType);
                    if (!string.IsNullOrEmpty(TM.TestType))
                    {
                        using (SqlDataReader reader = ado.ExecDataReaderProc("RNDSubTestType_READ", "RND", param3))
                        {
                            if (reader.HasRows)
                            {
                                while (reader.Read())
                                {
                                    TM.ddSubTestType.Add(new SelectListItem
                                    {
                                        Value    = Convert.ToString(reader["SubTestType"]),
                                        Text     = Convert.ToString(reader["SubTestType"]),
                                        Selected = (TM.SubTestType == Convert.ToString(reader["SubTestType"])) ? true : false,
                                    });
                                }
                            }
                            if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                            {
                                ado._conn.Close(); ado._conn.Dispose();
                            }
                        }
                    }
                    SqlParameter param4  = new SqlParameter("@MillLotNo", TM.MillLotNo);
                    SqlParameter param41 = new SqlParameter("@WorkStudyID", TM.WorkStudyID);

                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetLocation2", "RND", param4, param41))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddLocation2.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["Location2"]),
                                    Text     = Convert.ToString(reader["Location2"]),
                                    Selected = (TM.Location2 == Convert.ToString(reader["Location2"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                    SqlParameter param5 = new SqlParameter("@ProcessID", TM.LotID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetHole", "RND", param5))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddHole.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["Hole"]),
                                    Text     = Convert.ToString(reader["Hole"]),
                                    Selected = (TM.Hole == Convert.ToString(reader["Hole"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                    SqlParameter param6 = new SqlParameter("@ProcessID", TM.LotID);
                    using (SqlDataReader reader = ado.ExecDataReaderProc("RNDGetPieceNo", "RND", param6))
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                TM.ddPieceNo.Add(new SelectListItem
                                {
                                    Value    = Convert.ToString(reader["PieceNo"]),
                                    Text     = Convert.ToString(reader["PieceNo"]),
                                    Selected = (TM.PieceNo == Convert.ToString(reader["PieceNo"])) ? true : false,
                                });
                            }
                        }
                        if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                        {
                            ado._conn.Close(); ado._conn.Dispose();
                        }
                    }
                }

                using (SqlDataReader reader = ado.ExecDataReaderProc("RNDTestType_READ", "RND"))
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            TM.ddTestType.Add(new SelectListItem
                            {
                                Value    = Convert.ToString(reader["TestDesc"]).Trim(),
                                Text     = Convert.ToString(reader["TestDesc"]).Trim(),
                                Selected = (TM.TestType == Convert.ToString(reader["TestDesc"]).Trim()) ? true : false,
                            });
                        }
                    }
                    if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                    {
                        ado._conn.Close(); ado._conn.Dispose();
                    }
                }

                return(Serializer.ReturnContent(TM, this.Configuration.Services.GetContentNegotiator(), this.Configuration.Formatters, this.Request));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
        //public ActionResult TestingMaterialList(List<SelectListItem> ddlTestType, int RecID, string workStudyID)
        //{
        //    _logger.Debug("TestingMaterialList");

        //    //List<SelectListItem> ddlTestType = null;
        //    //  List<SelectListItem> ddlLotID = null;
        //    //  List<SelectListItem> ddlSubTestType = null;
        //      List<SelectListItem> ddAvailableTestType = null;

        //    //List<SelectListItem> TestLabs = null;
        //    //List<SelectListItem> Orientations = null;
        //    //List<SelectListItem> Location1s = null;

        //    RNDTesting testing = null;
        //    try
        //    {
        //        var client = GetHttpClient();
        //        // var task = client.GetAsync(Api + "api/TestingMaterial?TestingNo=0").ContinueWith((res) =>
        //        var task = client.GetAsync(Api + "api/Testing?RecID=0").ContinueWith((res) =>
        //        {
        //            if (res.Result.IsSuccessStatusCode)
        //            {
        //                RNDTesting rndTesting = JsonConvert.DeserializeObject<RNDTesting>(res.Result.Content.ReadAsStringAsync().Result);
        //                if (rndTesting != null)
        //                {
        //                    //in workStudyController

        //                    ddlTestType = rndTesting.ddTestType;
        //                    //       ddlLotID = rndTesting.ddLotID;
        //                    // ddlSubTestType = rndTesting.ddSubTestType;
        //                    //  ddAvailableTestType = rndTesting.ddAvailableTestType;
        //                    // TestLabs = rndTesting.TestLabs;
        //                    // Orientations = rndTesting.Orientations;
        //                    //Location1s = rndTesting.Location1s;
        //                }
        //            }
        //        });
        //        task.Wait();
        //        testing = new RNDTesting
        //        {
        //            WorkStudyID = workStudyID
        //        };
        //        ViewBag.ddlTestType = ddlTestType;
        //        // testing.GageThickness = "LotID";
        //        //    ViewBag.ddlLotID = ddlLotID;
        //        //ViewBag.ddlSubTestType = ddlSubTestType;
        //        //  ViewBag.ddAvailableTestType = ddAvailableTestType;
        //        // ViewBag.ddTestLabs = TestLabs;
        //        // ViewBag.ddOrientations = Orientations;
        //        //ViewBag.ddLocation1s = Location1s;
        //    }
        //    catch (Exception ex)
        //    {
        //        _logger.Error(ex);
        //    }
        //    return View(testing);
        //}

        public ActionResult SaveTestingMaterial(int id, string workStudyId, List <string> avialableTT)
        {
            RNDTesting testing = null;

            List <SelectListItem> ddlLotID       = null;
            List <SelectListItem> ddlOrientation = null;
            List <SelectListItem> ddlReplica     = null;
            List <SelectListItem> ddlLocation1   = null;
            List <SelectListItem> ddlTestLab     = null;
            List <SelectListItem> ddlHole        = null;
            List <SelectListItem> ddlPieceNo     = null;
            List <SelectListItem> ddlLocation2   = null;
            List <SelectListItem> ddlSubTestType = null;

            int intRowId;
            int intCount = 25;

            string[] strOrient = { " ", "L", "LT", "ST", "L-T", "L-S", "T-L", "T-S", "S-L", "S-T", "Custom" };
            string[] strLocOne = { " ", "Front", "Middle", "Back", "Low Con" };
            string[] strTesLab = { "Canton", "Anaheim", "WMTR", "ATS" };

            List <SelectListItem> ddlAvailableTestType = null;

            try
            {
                var client = GetHttpClient();
                if (workStudyId == null)
                {
                    //edit
                    var task = client.GetAsync(Api + "api/Testing?recID=" + id).ContinueWith((res) =>
                    {
                        if (res.Result.IsSuccessStatusCode)
                        {
                            testing = JsonConvert.DeserializeObject <RNDTesting>(res.Result.Content.ReadAsStringAsync().Result);
                            if (testing != null)
                            {
                                ddlHole        = new List <SelectListItem>();
                                ddlPieceNo     = new List <SelectListItem>();
                                ddlLocation2   = new List <SelectListItem>();
                                ddlSubTestType = new List <SelectListItem>();

                                ddlAvailableTestType = testing.ddTestType;
                                ddlLotID             = testing.ddLotID;
                                ddlSubTestType       = testing.ddSubTestType;
                                ddlLocation2         = testing.ddLocation2;
                                ddlHole    = testing.ddHole;
                                ddlPieceNo = testing.ddPieceNo;
                            }
                        }
                    });
                    task.Wait();
                }
                else
                {
                    var task = client.GetAsync(Api + "api/Testing?recID=" + id + "&workStudyID=" + workStudyId).ContinueWith((res) =>
                    {
                        if (res.Result.IsSuccessStatusCode)
                        {
                            testing = JsonConvert.DeserializeObject <RNDTesting>(res.Result.Content.ReadAsStringAsync().Result);
                            if (testing != null)
                            {
                                if (!string.IsNullOrEmpty(workStudyId))
                                {
                                    testing.WorkStudyID = workStudyId;
                                }
                                ddlLotID = testing.ddLotID;
                            }
                        }
                    });
                    task.Wait();
                }

                ddlOrientation = new List <SelectListItem>();
                ddlLocation1   = new List <SelectListItem>();
                ddlTestLab     = new List <SelectListItem>();
                ddlReplica     = new List <SelectListItem>();

                if (workStudyId != null)
                {
                    //new record
                    ddlHole        = new List <SelectListItem>();
                    ddlPieceNo     = new List <SelectListItem>();
                    ddlLocation2   = new List <SelectListItem>();
                    ddlSubTestType = new List <SelectListItem>();
                }


                intRowId = 0;
                string strValue = string.Empty;
                while (intRowId < strOrient.Length)
                {
                    strValue = strOrient[intRowId];
                    if (testing != null)
                    {
                        string testingOrientation = Convert.ToString(testing.Orientation);
                        if (testingOrientation != null)
                        {
                            testingOrientation = testingOrientation.Trim();
                        }

                        ddlOrientation.Add(new SelectListItem
                        {
                            Value    = strValue,
                            Text     = strValue,
                            Selected = (testingOrientation == Convert.ToString(strValue)) ? true : false,
                        });
                    }

                    intRowId += 1;
                }

                intRowId = 0;
                while (intRowId < strLocOne.Length)
                {
                    string testingLocation1 = Convert.ToString(testing.Location1);
                    if (testingLocation1 != null)
                    {
                        testingLocation1 = testingLocation1.Trim();
                    }

                    ddlLocation1.Add(new SelectListItem
                    {
                        Value    = strLocOne[intRowId],
                        Text     = strLocOne[intRowId],
                        Selected = (testingLocation1 == Convert.ToString(strLocOne[intRowId])) ? true : false,
                    });
                    intRowId += 1;
                }

                intRowId = 0;
                while (intRowId < strTesLab.Length)
                {
                    string testingTestLab = Convert.ToString(testing.TestLab);
                    if (testingTestLab != null)
                    {
                        testingTestLab = testingTestLab.Trim();
                    }

                    ddlTestLab.Add(new SelectListItem
                    {
                        Value    = strTesLab[intRowId],
                        Text     = strTesLab[intRowId],
                        Selected = (testingTestLab == Convert.ToString(strTesLab[intRowId])) ? true : false,
                    });
                    intRowId += 1;
                }

                intRowId = 0;
                while (intRowId < intCount)
                {
                    string testingReplica = Convert.ToString(testing.Replica);
                    if (testingReplica != null)
                    {
                        testingReplica = testingReplica.Trim();
                    }

                    intRowId += 1;
                    ddlReplica.Add(new SelectListItem
                    {
                        Value    = Convert.ToString(intRowId),
                        Text     = Convert.ToString(intRowId),
                        Selected = (testingReplica == Convert.ToString(intRowId)) ? true : false,
                    });
                }
                //ends here

                if (workStudyId != null)
                {
                    //new record

                    ddlHole.Add(new SelectListItem
                    {
                        Value    = "Select LotID",
                        Text     = "Select LotID",
                        Selected = (Convert.ToString(testing.Hole) == Convert.ToString("Select LotID")) ? true : false,
                    });
                    ddlPieceNo.Add(new SelectListItem
                    {
                        Value    = "Select LotID",
                        Text     = "Select LotID",
                        Selected = (Convert.ToString(testing.PieceNo) == Convert.ToString("Select LotID")) ? true : false,
                    });
                    ddlLocation2.Add(new SelectListItem
                    {
                        Value    = "Select LotID",
                        Text     = "Select LotID",
                        Selected = (Convert.ToString(testing.Location2) == Convert.ToString("Select LotID")) ? true : false,
                    });
                    ddlSubTestType.Add(new SelectListItem
                    {
                        Value    = "Select Test Type",
                        Text     = "Select Test Type",
                        Selected = (Convert.ToString(testing.SubTestType) == Convert.ToString("Select Test Type")) ? true : false,
                    });
                }

                ddlAvailableTestType = new List <SelectListItem>();

                if ((avialableTT != null) && (avialableTT.Count > 0))
                {
                    //  List<string> selectedTT = SeperateValues(avialableTT[0]);
                    string[] selectedTT = SeperateValues(avialableTT[0]);
                    //start here
                    foreach (string s in selectedTT)
                    {
                        if (s == "-1")
                        {
                            ddlAvailableTestType.Add(new SelectListItem
                            {
                                Value    = "Please Select",
                                Text     = "Please Select",
                                Selected = (Convert.ToString(testing.TestType) == Convert.ToString("Please Select")) ? true : false,
                            });
                        }
                        else
                        {
                            ddlAvailableTestType.Add(new SelectListItem
                            {
                                Value    = s,
                                Text     = s,
                                Selected = (Convert.ToString(testing.TestType) == Convert.ToString(s)) ? true : false,
                            });
                        }
                    }
                    //ends here
                }
                else
                {
                    ddlAvailableTestType.Add(new SelectListItem
                    {
                        Value    = "Please Select",
                        Text     = "Please Select",
                        Selected = (Convert.ToString(testing.TestType) == Convert.ToString("Please Select")) ? true : false,
                    });
                }

                ddlOrientation.ForEach(o => {
                    if (o.Selected)
                    {
                        testing.Orientation = o.Value;
                    }
                });

                ddlLocation1.ForEach(l => {
                    if (l.Selected)
                    {
                        testing.Location1 = l.Value;
                    }
                });


                ddlReplica.ForEach(r => {
                    if (r.Selected)
                    {
                        testing.Replica = r.Value;
                    }
                });

                ViewBag.ddlAvailableTestType = ddlAvailableTestType;
                ViewBag.ddlLotID             = ddlLotID;
                ViewBag.ddlOrientation       = ddlOrientation;
                ViewBag.ddlReplica           = ddlReplica;
                ViewBag.ddlLocation1         = ddlLocation1;
                ViewBag.ddlTestLab           = ddlTestLab;

                ViewBag.ddlHole        = ddlHole;
                ViewBag.ddlPieceNo     = ddlPieceNo;
                ViewBag.ddlLocation2   = ddlLocation2;
                ViewBag.ddlSubTestType = ddlSubTestType;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(View(testing));
        }
Example #10
0
        private DataSearch <RNDTesting> GetTestingMaterial(DataGridoption option)
        {
            _logger.Debug("GetTestingMaterial");

            AdoHelper ado = new AdoHelper();
            //SqlDataReader reader = null;

            List <RNDTesting>   lstTestingMaterial = new List <RNDTesting>();
            List <SqlParameter> lstSqlParameter    = new List <SqlParameter>();

            lstSqlParameter.Add(new SqlParameter("@CurrentPage", option.pageIndex));
            lstSqlParameter.Add(new SqlParameter("@NoOfRecords", option.pageSize));
            AddSearchFilter(option, lstSqlParameter);
            using (SqlDataReader reader = ado.ExecDataReaderProc("RNDTestingMaterial_Read", "RND", lstSqlParameter.Cast <object>().ToArray()))
            {
                if (reader.HasRows)
                {
                    RNDTesting TM = null;
                    while (reader.Read())
                    {
                        TM               = new RNDTesting();
                        TM.total         = Convert.ToInt32(reader["total"]);
                        TM.TestingNo     = Convert.ToInt32(reader["TestingNo"]);
                        TM.WorkStudyID   = Convert.ToString(reader["WorkStudyID"]);
                        TM.LotID         = Convert.ToString(reader["LotID"]);
                        TM.MillLotNo     = Convert.ToInt32(reader["MillLotNo"]);
                        TM.SoNum         = Convert.ToString(reader["SoNum"]);
                        TM.Hole          = Convert.ToString(reader["Hole"]);
                        TM.PieceNo       = Convert.ToString(reader["PieceNo"]);
                        TM.Alloy         = Convert.ToString(reader["Alloy"]);
                        TM.Temper        = Convert.ToString(reader["Temper"]);
                        TM.CustPart      = Convert.ToString(reader["CustPart"]);
                        TM.UACPart       = Convert.ToInt32(reader["UACPart"]);
                        TM.GageThickness = Convert.ToString(reader["GageThickness"]);
                        TM.Orientation   = Convert.ToString(reader["Orientation"]);
                        TM.Location1     = Convert.ToString(reader["Location1"]);
                        TM.Location2     = Convert.ToString(reader["Location2"]);
                        TM.Location3     = Convert.ToString(reader["Location3"]);
                        TM.SpeciComment  = Convert.ToString(reader["SpeciComment"]);
                        TM.TestType      = Convert.ToString(reader["TestType"]);
                        TM.SubTestType   = Convert.ToString(reader["SubTestType"]);
                        TM.Status        = Convert.ToChar(reader["Status"]);
                        TM.Selected      = Convert.ToChar(reader["Selected"]);
                        TM.EntryDate     = (!string.IsNullOrEmpty(reader["EntryDate"].ToString())) ? Convert.ToDateTime(reader["EntryDate"]) : (DateTime?)null;
                        TM.EntryBy       = Convert.ToString(reader["EntryBy"]);
                        TM.TestLab       = Convert.ToString(reader["TestLab"]);
                        TM.Printed       = Convert.ToChar(reader["Printed"]);
                        TM.Replica       = Convert.ToString(reader["Replica"]);
                        //  TM.RCS = (!string.IsNullOrEmpty(reader["RCS"].ToString())) ? Convert.ToChar(reader["RCS"]) : (char?)null;

                        lstTestingMaterial.Add(TM);
                    }
                }
                if (ado._conn != null && ado._conn.State == System.Data.ConnectionState.Open)
                {
                    ado._conn.Close(); ado._conn.Dispose();
                }
            }
            DataSearch <RNDTesting> ds = new DataSearch <RNDTesting>
            {
                items = lstTestingMaterial,
                total = (lstTestingMaterial != null && lstTestingMaterial.Count > 0) ? lstTestingMaterial[0].total : 0
            };

            return(ds);
        }