120 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			120 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace BLL
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								   public static class UnitStoreService
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键获取单位仓库
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="specificationsId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static Model.Weld_UnitStore GetUnitStoreById(string unitStoreId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return Funs.DB.Weld_UnitStore.FirstOrDefault(e => e.UnitStoreId == unitStoreId);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public static List<Model.Weld_UnitStore> GetUnitStoreByUnitId(string unitId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return Funs.DB.Weld_UnitStore.Where(e => e.UnitId==unitId).ToList();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 添加单位仓库
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="specifications"></param>
							 | 
						|||
| 
								 | 
							
								        public static void AddUnitStore(Model.Weld_UnitStore unitStore)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UnitStore newUnitStore = new Model.Weld_UnitStore();
							 | 
						|||
| 
								 | 
							
								            newUnitStore.UnitStoreId = unitStore.UnitStoreId;
							 | 
						|||
| 
								 | 
							
								            newUnitStore.ProjectId = unitStore.ProjectId;
							 | 
						|||
| 
								 | 
							
								            newUnitStore.UnitId = unitStore.UnitId;
							 | 
						|||
| 
								 | 
							
								            newUnitStore.UnitStoreCode = unitStore.UnitStoreCode;
							 | 
						|||
| 
								 | 
							
								            newUnitStore.UnitStoreName = unitStore.UnitStoreName;
							 | 
						|||
| 
								 | 
							
								            newUnitStore.StorePosition = unitStore.StorePosition;
							 | 
						|||
| 
								 | 
							
								            db.Weld_UnitStore.InsertOnSubmit(newUnitStore);
							 | 
						|||
| 
								 | 
							
								            db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 修改单位仓库
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="unitStore"></param>
							 | 
						|||
| 
								 | 
							
								        public static void UpdateUnitStore(Model.Weld_UnitStore unitStore)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UnitStore newUnitStore = db.Weld_UnitStore.FirstOrDefault(e => e.UnitStoreId == unitStore.UnitStoreId);
							 | 
						|||
| 
								 | 
							
								            if (newUnitStore != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                newUnitStore.ProjectId = unitStore.ProjectId;
							 | 
						|||
| 
								 | 
							
								                newUnitStore.UnitId = unitStore.UnitId;
							 | 
						|||
| 
								 | 
							
								                newUnitStore.UnitStoreCode = unitStore.UnitStoreCode;
							 | 
						|||
| 
								 | 
							
								                newUnitStore.UnitStoreName = unitStore.UnitStoreName;
							 | 
						|||
| 
								 | 
							
								                newUnitStore.StorePosition = unitStore.StorePosition;
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 根据主键删除单位仓库
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="unitStoreId"></param>
							 | 
						|||
| 
								 | 
							
								        public static void DeleteUnitStoreById(string unitStoreId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.SGGLDB db = Funs.DB;
							 | 
						|||
| 
								 | 
							
								            Model.Weld_UnitStore delUnitStore = db.Weld_UnitStore.FirstOrDefault(e => e.UnitStoreId == unitStoreId);
							 | 
						|||
| 
								 | 
							
								            if (delUnitStore != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                db.Weld_UnitStore.DeleteOnSubmit(delUnitStore);
							 | 
						|||
| 
								 | 
							
								                db.SubmitChanges();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 验证单位仓库是否存在
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="unitId"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="unitStoreCode"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="id"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        public static bool IsExitUnitStore(string unitId, string unitStoreCode, string id)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var q = Funs.DB.Weld_UnitStore.FirstOrDefault(x => x.UnitId == unitId && x.UnitStoreCode == unitStoreCode && x.UnitStoreId != id);
							 | 
						|||
| 
								 | 
							
								            if (q != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return true;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return false;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public static void InitUnitStoreDropDownList(FineUIPro.DropDownList dropName, string unitId, bool isShowPlease)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var store = from x in Funs.DB.Weld_UnitStore
							 | 
						|||
| 
								 | 
							
								                        join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
							 | 
						|||
| 
								 | 
							
								                        orderby y.UnitName, x.UnitStoreCode
							 | 
						|||
| 
								 | 
							
								                        select new { x.UnitStoreId, UnitStoreName = (y.UnitName + "(" + x.UnitStoreName + ")"), y.UnitName, x.UnitId };
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(unitId))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                store = store.Where(x => x.UnitId == unitId);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            dropName.DataValueField = "UnitStoreId";
							 | 
						|||
| 
								 | 
							
								            dropName.DataTextField = "UnitStoreName";
							 | 
						|||
| 
								 | 
							
								            dropName.DataGroupField = "UnitName";
							 | 
						|||
| 
								 | 
							
								            dropName.DataSource = store.ToList();
							 | 
						|||
| 
								 | 
							
								            dropName.DataBind();
							 | 
						|||
| 
								 | 
							
								            if (isShowPlease)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Funs.FineUIPleaseSelect(dropName);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |