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 AddStockLayout(StockLayout stocklayout) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { StockLayout result = alading.StockLayout.FirstOrDefault(i => i.StockLayoutCode == stocklayout.StockLayoutCode); if (result != null) { return(ReturnType.PropertyExisted); } alading.AddToStockLayout(stocklayout); if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.PropertyExisted); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType UpdateStockLayout(StockLayout stocklayout) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*StockLayout result = alading.StockLayout.Where(p => p.StockLayoutID == stocklayout.StockLayoutID).FirstOrDefault();*/ StockLayout result = alading.StockLayout.FirstOrDefault(p => p.StockLayoutCode == stocklayout.StockLayoutCode); if (result == null) { return(ReturnType.NotExisted); } result.LayoutName = stocklayout.LayoutName; result.LayoutRemark = stocklayout.LayoutRemark; if (alading.SaveChanges() == 1) { return(ReturnType.Success); } return(ReturnType.OthersError); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType RemoveStockLayout(string stocklayoutCode) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*List<StockLayout> list = alading.StockLayout.Where(p => p.StockLayoutID == stocklayoutID).ToList();*/ List <StockLayout> list = alading.StockLayout.Where(p => p.StockLayoutCode == stocklayoutCode).ToList(); if (list.Count == 0) { return(ReturnType.NotExisted); } else { StockLayout 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 ModifyLayout(StockLayout stockLayout, string houseName) { InitializeComponent(); stockLayoutCode = stockLayout.StockLayoutCode; textLayoutName.Text = stockLayout.LayoutName; memoLayoutRemark.Text = stockLayout.LayoutRemark; //仓库名 comboBoxHouse.Text = houseName; textEditLayoutCode.Text = stockLayout.StockLayoutCode; textEditLayoutCode.Properties.ReadOnly = true; }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleConfirm_Click(object sender, EventArgs e) { StockLayout stockLayout = new StockLayout(); stockLayout.LayoutName = textLayoutName.Text; stockLayout.LayoutRemark = memoLayoutRemark.Text; if (modifyFlag == true) { stockLayout.StockLayoutCode = stockLayoutCode; if (StockLayoutService.UpdateStockLayout(stockLayout) == ReturnType.Success) { XtraMessageBox.Show("修改库位信息成功", Constants.SYSTEM_PROMPT); this.Close(); } else { XtraMessageBox.Show("修改库位信息失败", Constants.SYSTEM_PROMPT); } } else { stockLayout.StockHouseCode = stockHouseCode; if (textEditLayoutCode.Text == string.Empty) { stockLayout.StockLayoutCode = Guid.NewGuid().ToString(); } else { stockLayout.StockLayoutCode = textEditLayoutCode.Text; } ReturnType result = StockLayoutService.AddStockLayout(stockLayout); if (result == ReturnType.Success) { XtraMessageBox.Show("新增库位成功", Constants.SYSTEM_PROMPT); this.Close(); } else if (result == ReturnType.PropertyExisted) { XtraMessageBox.Show("库位编码重复,请重输", Constants.SYSTEM_PROMPT); textEditLayoutCode.Focus(); } else { XtraMessageBox.Show("新增库位失败", Constants.SYSTEM_PROMPT); } } }
/// <summary> /// 库位修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barModifyLayout_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { StockLayout stockLayout = gViewStockLayout.GetFocusedRow() as StockLayout; if (stockLayout != null) { if (stockLayout.StockLayoutCode == Constants.DEFAULT_STOCKLAYOUT_CODE || stockLayout.LayoutName == "默认库位") { XtraMessageBox.Show("系统默认库位,不能修改", Constants.SYSTEM_PROMPT); return; } ModifyLayout Layout = new ModifyLayout(stockLayout, textHouseName.Text); Layout.ShowDialog(); //重新加载库位 LoadLayout(stockHouseCode); } }
public ReturnType UpdateStockLayout(string stocklayoutCode, StockLayout stocklayout) { throw new NotImplementedException(); //try //{ // using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) // { // /*var result = alading.StockLayout.Where(p => p.StockLayoutID == stocklayoutID).ToList();*/ // var result = alading.StockLayout.Where(p => p.StockLayoutCode == stocklayoutCode).ToList(); // if (result.Count == 0) // { // return ReturnType.NotExisted; // } // StockLayout ob = result.First(); // ob.HouseCode = stocklayout.HouseCode; // ob.LayoutName = stocklayout.LayoutName; // ob.LayoutRemark = stocklayout.LayoutRemark; // if (alading.SaveChanges() == 1) // { // return ReturnType.Success; // } // else // { // return ReturnType.OthersError; // } // } //} //catch (SqlException sex) //{ // return ReturnType.ConnFailed; //} //catch (System.Exception ex) //{ // return ReturnType.OthersError; //} }
public static ReturnType UpdateStockLayout(string stocklayoutCode, StockLayout stocklayout) { return(DataProviderClass.Instance().UpdateStockLayout(stocklayoutCode, stocklayout)); }
public static ReturnType AddStockLayout(StockLayout stocklayout) { return(DataProviderClass.Instance().AddStockLayout(stocklayout)); }