using FineUIPro; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; namespace BLL { public static class HJGL_PackagingmanageService { public static Model.SGGLDB db = Funs.DB; /// /// 未到场 /// public static int state_0 = 0; /// /// 已发货 /// public static int state_1 = 1; /// /// 已到场 /// public static int state_2 = 2; public static ListItem[] GetState() { ListItem[] list = new ListItem[3]; list[0] = new ListItem("未到场", state_0.ToString()); list[1] = new ListItem("已出库", state_1.ToString()); list[2] = new ListItem("已到场", state_2.ToString()); return list; } #region 获取列表 /// /// 记录数 /// public static int count { get; set; } /// 获取分页列表 /// /// 页码 /// 每页数量 /// public static IEnumerable getListData(string name, Grid Grid1) { IQueryable q1 = (from x in db.HJGL_PackagingManage join y in db.HJGL_Pipeline_Component on x.PipelineComponentId equals y.PipelineComponentId join z in db.HJGL_Pipeline on y.PipelineId equals z.PipelineId select x ); if (!string.IsNullOrEmpty(name)) { q1 = q1.Where(e => e.PackagingManageId.Contains(name)); } count = q1.Count(); if (count == 0) { return null; } q1 = SortConditionHelper.SortingAndPaging(q1, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); return from x in q1 select new { x.PackagingManageId, x.PackagingCode, x.ProjectId, x.PipelineComponentId, x.StackingPosition, x.State, x.ContactName, x.ContactPhone, x.Remark, }; } #endregion public static Model.HJGL_PackagingManage GetHJGL_PackagingManageById(string PackagingManageId) { return db.HJGL_PackagingManage.FirstOrDefault(x => x.PackagingManageId == PackagingManageId); } /// /// 形成出库单 /// /// public static void PutOutOrder(string PackagingManageId) { var model= GetHJGL_PackagingManageById(PackagingManageId); if (model.State==state_0) { model.State = state_1; UpdateHJGL_PackagingManage(model); } } /// /// 根据主键获取装箱明细 /// /// /// public static DataTable GetPackagingDetailById(string PackagingManageId) { DataTable tb = new DataTable(); var model = GetHJGL_PackagingManageById(PackagingManageId); if (!string .IsNullOrEmpty(model.PipelineComponentId)) { var PipelineComponentIds = model.PipelineComponentId.Split(','); string strSql = @"select com.PipelineComponentId, com.PipelineComponentCode,com.PlanStartDate,unitwork.UnitWorkName,'1' as num ,'个' as CU from HJGL_Pipeline_Component com left join HJGL_Pipeline pipe on com.PipelineId=pipe.PipelineId left join WBS_UnitWork unitwork on pipe.UnitWorkId=unitwork.UnitWorkId "; List listStr = new List(); strSql += string.Format("where com.PipelineComponentId in ( {0}) ", "'" + string.Join("','", PipelineComponentIds) + "'"); SqlParameter[] parameter = listStr.ToArray(); tb = SQLHelper.GetDataTableRunText(strSql, parameter); } return tb; } /// /// 根据项目号获取包装编号历史记录 /// /// /// public static List GetPackagingCode(string projectid) { Model.SGGLDB db = Funs.DB; var q = (from x in db.HJGL_PackagingManage where x.ProjectId.Contains(projectid) select x.PackagingCode).Distinct().ToList(); return q; } /// /// 新增实体 /// /// public static void AddHJGL_PackagingManage(Model.HJGL_PackagingManage newtable) { Model.HJGL_PackagingManage table = new Model.HJGL_PackagingManage { PackagingManageId = newtable.PackagingManageId, PackagingCode = newtable.PackagingCode, ProjectId = newtable.ProjectId, PipelineComponentId = newtable.PipelineComponentId, StackingPosition = newtable.StackingPosition, State = newtable.State, ContactName = newtable.ContactName, ContactPhone = newtable.ContactPhone, Remark = newtable.Remark, }; db.HJGL_PackagingManage.InsertOnSubmit(table); db.SubmitChanges(); } public static void UpdateHJGL_PackagingManage(Model.HJGL_PackagingManage newtable) { Model.HJGL_PackagingManage table = db.HJGL_PackagingManage.FirstOrDefault(x => x.PackagingManageId == newtable.PackagingManageId); if (table != null) { table.PackagingManageId = newtable.PackagingManageId; table.PackagingCode = newtable.PackagingCode; table.ProjectId = newtable.ProjectId; table.PipelineComponentId = newtable.PipelineComponentId; table.StackingPosition = newtable.StackingPosition; table.State = newtable.State; table.ContactName = newtable.ContactName; table.ContactPhone = newtable.ContactPhone; table.Remark = newtable.Remark; db.SubmitChanges(); } } public static void DeleteHJGL_PackagingManageById(string PackagingManageId) { Model.HJGL_PackagingManage table = db.HJGL_PackagingManage.FirstOrDefault(x => x.PackagingManageId == PackagingManageId); if (table != null) { db.HJGL_PackagingManage.DeleteOnSubmit(table); db.SubmitChanges(); } } /// /// 管线下拉框 /// /// 下拉框名字 /// 是否显示请选择 public static void InitPipelineDownList(FineUIPro.DropDownList dropName, string projectid, bool isShowPlease) { dropName.DataValueField = "string"; dropName.DataTextField = "string"; dropName.DataSource = GetPackagingCode(projectid); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName); } } } }