[Route("SupplierProductAmount/Count")] ///SupplierProductAmount/Count public HttpResponseMessage Stockseedanimal() { 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(); } } DataSet ds = SqlHelper.ExecuteDataset(scc, CommandType.StoredProcedure, "sp_Stock_count", new SqlParameter("@OrganizationOid", OrganizeOid)); List <Stock_info> titile_Groups = new List <Stock_info>(); Stock_info stock_Info = new Stock_info(); List <SeedAnimal_info> detail = new List <SeedAnimal_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["SeedLevelCode"].ToString()) { number = number; SeedAnimal_info item = new SeedAnimal_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 { SeedAnimal_info item = new SeedAnimal_info(); item.Title = dr["SeedName"].ToString(); item.Weight = Convert.ToDouble(dr["TotalWeight"]); item.Unit = dr["WeightUnit"].ToString(); number = number + 1; Temp_Group_Name = dr["SeedLevelCode"].ToString(); stock_Info = new Stock_info(); stock_Info.Id = number; stock_Info.Title = dr["SeedLevelCode"].ToString(); stock_Info.Total = Convert.ToDouble(dr["SumWeight"].ToString()); switch (dr["SeedLevelCode"].ToString()) { case "BS": stock_Info.Color = "#F1948A"; break; case "CS": stock_Info.Color = "#FF7F27"; break; case "FS": stock_Info.Color = "#00E142"; break; case "RS": stock_Info.Color = "#99D9EA"; 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)); } else { 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.ClearAllPools(); } }
[Route("SupplierProductAmount/Count/Admin")] ///SupplierProductAmount/Count public HttpResponseMessage Stockseedanimal_Admin() { try { string OrganizeOid = null; // Oid จังหวัด 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_StockforAdmin"); List <Stock_info> titile_Groups = new List <Stock_info>(); Stock_info stock_Info = new Stock_info(); List <SeedAnimal_info> detail = new List <SeedAnimal_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["SeedLevelCode"].ToString()) { number = number; SeedAnimal_info item = new SeedAnimal_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 { SeedAnimal_info item = new SeedAnimal_info(); item.Title = dr["SeedName"].ToString(); item.Weight = Convert.ToDouble(dr["TotalWeight"]); item.Unit = dr["WeightUnit"].ToString(); number = number + 1; Temp_Group_Name = dr["SeedLevelCode"].ToString(); stock_Info = new Stock_info(); stock_Info.Id = number; stock_Info.Title = dr["SeedLevelCode"].ToString(); stock_Info.Total = Convert.ToDouble(dr["SumWeight"].ToString()); switch (dr["SeedLevelCode"].ToString()) { case "BS": stock_Info.Color = "#F1948A"; break; case "CS": stock_Info.Color = "#FF7F27"; break; case "FS": stock_Info.Color = "#00E142"; break; case "RS": stock_Info.Color = "#99D9EA"; 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)); } else { UserError err2 = new UserError(); err2.code = "0"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ err2.message = "NoData"; 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.ClearAllPools(); } }