public ReturnType AddStockHouse(StockHouse stockhouse) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { StockHouse result = alading.StockHouse.FirstOrDefault(i => i.StockHouseCode == stockhouse.StockHouseCode); if (result != null) { return(ReturnType.PropertyExisted); } StockLayout stockLayout = new StockLayout(); stockLayout.LayoutName = "默认库位"; stockLayout.LayoutRemark = string.Empty; stockLayout.StockHouseCode = stockhouse.StockHouseCode; stockLayout.StockLayoutCode = Guid.NewGuid().ToString(); alading.AddToStockHouse(stockhouse); alading.AddToStockLayout(stockLayout); alading.SaveChanges(); return(ReturnType.Success); } } catch (Exception ex) { throw ex; } }
public ReturnType UpdateStockHouse(StockHouse stockhouse) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*StockHouse result = alading.StockHouse.Where(p => p.StockHouseID == stockhouse.StockHouseID).FirstOrDefault();*/ StockHouse result = alading.StockHouse.Where(p => p.StockHouseCode == stockhouse.StockHouseCode).FirstOrDefault(); if (result == null) { return(ReturnType.NotExisted); } #region Using Attach() Function Update,Default USE; result.HouseAddress = stockhouse.HouseAddress; result.HouseContact = stockhouse.HouseContact; result.HouseName = stockhouse.HouseName; result.HouseRemark = stockhouse.HouseRemark; result.HouseTel = stockhouse.HouseTel; #endregion #region Using All Items Replace To Update ,Default UnUse /* * * result.HouseCode = stockhouse.HouseCode; * * result.HouseName = stockhouse.HouseName; * * result.HouseAddress = stockhouse.HouseAddress; * * result.HouseRemark = stockhouse.HouseRemark; * */ #endregion if (alading.SaveChanges() == 1) { return(ReturnType.Success); } return(ReturnType.OthersError); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType RemoveStockHouse(string stockhouseCode) { System.Data.Common.DbTransaction tran = null; using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { try { /*List<StockHouse> list = alading.StockHouse.Where(p => p.StockHouseID == stockhouseID).ToList();*/ List <StockHouse> list = alading.StockHouse.Where(p => p.StockHouseCode == stockhouseCode).ToList(); if (list.Count == 0) { return(ReturnType.NotExisted); } else { alading.Connection.Open(); tran = alading.Connection.BeginTransaction(); List <StockLayout> layoutList = alading.StockLayout.Where(i => i.StockHouseCode == stockhouseCode).ToList(); if (layoutList != null) { foreach (StockLayout layout in layoutList) { alading.DeleteObject(layout); } } StockHouse sy = list.First(); alading.DeleteObject(sy); alading.SaveChanges(); return(ReturnType.Success); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } } }
public ReturnType UpdateStockHouse(string stockhouseCode, StockHouse stockhouse) { throw new NotImplementedException(); //try //{ // using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) // { // /*var result = alading.StockHouse.Where(p => p.StockHouseID == stockhouseID).ToList();*/ // var result = alading.StockHouse.Where(p => p.StockHouseCode == stockhouseCode).ToList(); // if (result.Count == 0) // { // return ReturnType.NotExisted; // } // StockHouse ob = result.First(); // ob.HouseCode = stockhouse.HouseCode; // ob.HouseName = stockhouse.HouseName; // ob.HouseAddress = stockhouse.HouseAddress; // ob.HouseRemark = stockhouse.HouseRemark; // if (alading.SaveChanges() == 1) // { // return ReturnType.Success; // } // else // { // return ReturnType.OthersError; // } // } //} //catch (SqlException sex) //{ // return ReturnType.ConnFailed; //} //catch (System.Exception ex) //{ // return ReturnType.OthersError; //} }
void OnGUI() { if (work == true) { string text = ""; for (int i = 0; i < 8; i++) { if (needSource[selectHouse, i] != 0) { text += "\r\n" + sourceName[i] + ":" + playerNow.source[i] + "/" + needSource[selectHouse, i]; } } // text+=+"\r\nwood:"+playerNow.source[0]+"/"+needSource[selectHouse,0]+"\r\nstone:"+playerNow.source[1]+"/"+needSource[selectHouse,1]+"\r\nmetal:"+playerNow.source[2]+"/"+needSource[selectHouse,2]; GUI.BeginGroup(new Rect(Screen.width / 10, Screen.height / 10, Screen.width * 4 / 5, Screen.height * 4 / 5)); GUI.Box(new Rect(0, 0, Screen.width * 4 / 5, Screen.height * 4 / 5), "", guiSkin.box); GUI.Box(new Rect(Screen.width / 10, Screen.height / 16, Screen.width * 1 / 5, Screen.width * 1 / 5), housePng[selectHouse], guiSkin.box); //GUI.Label (new Rect (Screen.width/10,Screen.height*3/10, Screen.width*1/5, Screen.width*1/25), HouseName[selectHouse], guiSkin.label); GUI.Label(new Rect(Screen.width / 10, Screen.height * 9 / 20, Screen.width * 1 / 5, Screen.width * 1 / 5), text, guiSkin.label); GUI.Label(new Rect(Screen.width * 3 / 8, Screen.height * 12 / 20, Screen.width / 3, Screen.height / 8), HouseInfo[selectHouse], guiSkin.label); if (GUI.Button(new Rect(Screen.width * 3 / 8, Screen.height * 2 / 20, Screen.width / 3, Screen.height / 10), "住宅", guiSkin.button)) { selectHouse = 3; } if (GUI.Button(new Rect(Screen.width * 3 / 8, Screen.height * 4 / 20, Screen.width / 3, Screen.height / 10), "倉庫", guiSkin.button)) { selectHouse = 0; } if (GUI.Button(new Rect(Screen.width * 3 / 8, Screen.height * 6 / 20, Screen.width / 3, Screen.height / 10), "工作屋", guiSkin.button)) { selectHouse = 1; } if (GUI.Button(new Rect(Screen.width * 3 / 8, Screen.height * 8 / 20, Screen.width / 3, Screen.height / 10), "精煉屋", guiSkin.button)) { selectHouse = 2; } if (GUI.Button(new Rect(Screen.width * 3 / 8, Screen.height * 10 / 20, Screen.width / 3, Screen.height / 10), "世界奇觀", guiSkin.button)) { selectHouse = 4; } if (GUI.Button(new Rect(Screen.width * 11 / 15, 0, Screen.width / 15, Screen.width / 15), "X", guiSkin.button)) { work = false; playerNow.click = false; } GUI.EndGroup(); if (playerNow.source[0] >= needSource[selectHouse, 0] && playerNow.source[1] >= needSource[selectHouse, 1] && playerNow.source[2] >= needSource[selectHouse, 2] && playerNow.source[3] >= needSource[selectHouse, 3] && playerNow.source[4] >= needSource[selectHouse, 4] && playerNow.source[5] >= needSource[selectHouse, 5] && playerNow.source[6] >= needSource[selectHouse, 6] && playerNow.source[7] >= needSource[selectHouse, 7]) { GUI.enabled = true; } else { GUI.enabled = false; } if (GUI.Button(new Rect(Screen.width * 2 / 10, Screen.height * 4 / 10 + Screen.width * 1 / 5, Screen.width * 1 / 5, Screen.width * 1 / 15), "建造", guiSkin.button)) { switch (selectHouse) { case 0: buildNow = (Rigidbody)Instantiate(build_stock, this.transform.position, build_stock.transform.rotation); buildNow.gameObject.collider.enabled = true; StockHouse thisStockBuild = buildNow.GetComponent <StockHouse>(); thisStockBuild.PlayerID = playerNow.PlayerID; thisStockBuild.HP = 100; for (int i = 0; i < 8; i++) { thisStockBuild.stockSource[i] = 0; playerNow.source[i] = playerNow.source[i] - needSource[0, i]; } playerNow.infomationText("Stock House is Build"); playerNow.click = false; Destroy(this.gameObject); work = false; break; case 1: buildNow = (Rigidbody)Instantiate(build_work, this.transform.position, build_work.transform.rotation); buildNow.gameObject.collider.enabled = true; WorkHouse thisWorkBuild = buildNow.GetComponent <WorkHouse>(); thisWorkBuild.PlayerID = playerNow.PlayerID; thisWorkBuild.HP = 100; for (int i = 0; i < 8; i++) { playerNow.source[i] = playerNow.source[i] - needSource[1, i]; } playerNow.infomationText("Work House is Build"); playerNow.click = false; Destroy(this.gameObject); work = false; break; case 2: buildNow = (Rigidbody)Instantiate(build_science, this.transform.position, build_science.transform.rotation); buildNow.gameObject.collider.enabled = true; ScientificHouse thisScienceBuild = buildNow.GetComponent <ScientificHouse>(); thisScienceBuild.PlayerID = playerNow.PlayerID; thisScienceBuild.HP = 100; for (int i = 0; i < 8; i++) { playerNow.source[i] = playerNow.source[i] - needSource[2, i]; } playerNow.infomationText("Science House is Build"); playerNow.click = false; Destroy(this.gameObject); work = false; break; case 3: if (!playerNow.isHomeExsist) { buildNow = (Rigidbody)Instantiate(build_house, this.transform.position, build_house.transform.rotation); buildNow.gameObject.collider.enabled = true; Home thisHomeBuild = buildNow.GetComponent <Home>(); thisHomeBuild.PlayerID = playerNow.PlayerID; thisHomeBuild.HP = 100; for (int i = 0; i < 8; i++) { playerNow.source[i] = playerNow.source[i] - needSource[3, i]; } playerNow.infomationText("Home is Build"); playerNow.click = false; Destroy(this.gameObject); playerNow.isHomeExsist = true; work = false; } break; case 4: if (!playerNow.isHomeExsist) { buildNow = (Rigidbody)Instantiate(build_house, this.transform.position, build_house.transform.rotation); buildNow.gameObject.collider.enabled = true; Home thisHomeBuild = buildNow.GetComponent <Home>(); thisHomeBuild.PlayerID = playerNow.PlayerID; thisHomeBuild.HP = 100; for (int i = 0; i < 8; i++) { playerNow.source[i] = playerNow.source[i] - needSource[3, i]; } playerNow.infomationText("Home is Build"); playerNow.click = false; Destroy(this.gameObject); playerNow.isHomeExsist = true; work = false; } break; } Vector3 Pos = new Vector3(buildNow.gameObject.transform.position.x - 1, buildNow.gameObject.transform.position.y + 5, buildNow.gameObject.transform.position.z + 1); GameObject animateNow = (GameObject)Instantiate(Building, Pos, Building.transform.rotation); Pos = new Vector3(this.transform.position.x, this.transform.position.y + 4, this.transform.position.z); GameObject SomkeNow = (GameObject)Instantiate(Smoke, Pos, Building.transform.rotation); Pos = new Vector3(this.transform.position.x, this.transform.position.y + 4.1f, this.transform.position.z); GameObject SmokeAnimateNow = (GameObject)Instantiate(SmokeAnimation, Pos, Building.transform.rotation); Destroy(animateNow, 3); Destroy(SomkeNow, 3); Destroy(SmokeAnimateNow, 3); } GUI.enabled = true; } }
public static ReturnType UpdateStockHouse(string stockhouseCode, StockHouse stockhouse) { return(DataProviderClass.Instance().UpdateStockHouse(stockhouseCode, stockhouse)); }
public static ReturnType AddStockHouse(StockHouse stockhouse) { return(DataProviderClass.Instance().AddStockHouse(stockhouse)); }