[Route("SupplierAnimalAmount/Count")] ///SupplierProductAmount/Count public HttpResponseMessage StockAnimal() { try { string OrganizeOid = null; // Oid จังหวัด string BudgetSourceOid = null; string DLD = null; if (HttpContext.Current.Request.Form["OrganizationOid"].ToString() != null) { if (HttpContext.Current.Request.Form["OrganizationOid"].ToString() != "") { OrganizeOid = HttpContext.Current.Request.Form["OrganizationOid"].ToString(); } } // BudgetSourceOid = HttpContext.Current.Request.Form["BudgetSourceOid"].ToString(); // DLD = HttpContext.Current.Request.Form["DLD"].ToString(); //} DataSet ds = SqlHelper.ExecuteDataset(scc, CommandType.StoredProcedure, "sp_StockAnimal_count", new SqlParameter("@OrganizationOid", OrganizeOid) ); List <StockAnimals> titile_Groups = new List <StockAnimals>(); StockAnimals stock_Info = new StockAnimals(); List <SeedAnimalStock_info> detail = new List <SeedAnimalStock_info>(); if (ds.Tables[0].Rows.Count > 0) { int number = 0; string Temp_Group_Name = ""; foreach (DataRow dr in ds.Tables[0].Rows) { if (Temp_Group_Name == dr["AnimalSupplieName"].ToString()) { number = number; SeedAnimalStock_info item = new SeedAnimalStock_info(); item.Title = dr["SeedName"].ToString(); item.Weight = Convert.ToDouble(dr["TotalWeight"]); item.Unit = dr["WeightUnit"].ToString(); //status.Add(item); stock_Info.Data.Add(item); } else { SeedAnimalStock_info item = new SeedAnimalStock_info(); item.Title = dr["SeedName"].ToString(); item.Weight = Convert.ToDouble(dr["TotalWeight"]); item.Unit = dr["WeightUnit"].ToString(); number = number + 1; Temp_Group_Name = dr["AnimalSupplieName"].ToString(); stock_Info = new StockAnimals(); stock_Info.Id = number; stock_Info.Title = dr["AnimalSupplieName"].ToString(); stock_Info.Total = Convert.ToDouble(dr["SumWeight"].ToString()); switch (dr["AnimalSupplieName"].ToString()) { case "สด": stock_Info.Color = "#F1948A"; break; case "หมัก": stock_Info.Color = "#FF7F27"; break; case "แห้ง": stock_Info.Color = "#00E142"; break; default: stock_Info.Color = "#ABB2B9"; break; } //status.Add(item); //Group_.Status_List = status; stock_Info.Data.Add(item); titile_Groups.Add(stock_Info); } } UserError err = new UserError(); err.code = ""; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = "OK"; return(Request.CreateResponse(HttpStatusCode.OK, titile_Groups)); } UserError err2 = new UserError(); err2.code = "0"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err2.message = "กรุณาระบุศูนย์"; return(Request.CreateResponse(HttpStatusCode.BadRequest)); } catch (Exception ex) { UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } finally { SqlConnection.ClearPool(scc); } }
[Route("SupplierAnimalAmount/Count/Admin")] ///SupplierProductAmount/Count public HttpResponseMessage StockAnimalAdmin() { try { user.User_info objUser_info = new user.User_info(); objUser_info.ActionName = HttpContext.Current.Request.Form["actionName"]; if (objUser_info.ActionName.Contains("EditAdmin") == true) { DataSet ds = SqlHelper.ExecuteDataset(scc, CommandType.StoredProcedure, "sp_StockanimalforAdmin"); List <StockAnimals> titile_Groups = new List <StockAnimals>(); StockAnimals stock_Info = new StockAnimals(); List <SeedAnimalStock_info> detail = new List <SeedAnimalStock_info>(); if (ds.Tables[0].Rows.Count > 0) { int number = 0; string Temp_Group_Name = ""; foreach (DataRow dr in ds.Tables[0].Rows) { if (Temp_Group_Name == dr["AnimalSupplieName"].ToString()) { SeedAnimalStock_info item = new SeedAnimalStock_info(); item.Title = dr["SeedName"].ToString(); item.Weight = Convert.ToDouble(dr["TotalWeight"]); item.Unit = dr["WeightUnit"].ToString(); //status.Add(item); stock_Info.Data.Add(item); } else { SeedAnimalStock_info item = new SeedAnimalStock_info(); item.Title = dr["SeedName"].ToString(); item.Weight = Convert.ToDouble(dr["TotalWeight"]); item.Unit = dr["WeightUnit"].ToString(); number = number + 1; Temp_Group_Name = dr["AnimalSupplieName"].ToString(); stock_Info = new StockAnimals(); stock_Info.Id = number; stock_Info.Title = dr["AnimalSupplieName"].ToString(); stock_Info.Total = Convert.ToDouble(dr["SumWeight"].ToString()); switch (dr["AnimalSupplieName"].ToString()) { case "สด": stock_Info.Color = "#F1948A"; break; case "หมัก": stock_Info.Color = "#FF7F27"; break; case "แห้ง": stock_Info.Color = "#00E142"; break; default: stock_Info.Color = "#ABB2B9"; break; } //status.Add(item); //Group_.Status_List = status; stock_Info.Data.Add(item); titile_Groups.Add(stock_Info); } } UserError err = new UserError(); err.code = ""; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = "OK"; return(Request.CreateResponse(HttpStatusCode.OK, titile_Groups)); } UserError err2 = new UserError(); err2.code = "0"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err2.message = "กรุณาระบุศูนย์"; return(Request.CreateResponse(HttpStatusCode.NotFound, err2)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "ไม่ใช่ Admin")); } } catch (Exception ex) { UserError err = new UserError(); err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err.message = ex.Message; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } finally { SqlConnection.ClearPool(scc); } }