public static StockOut From(StockIn stockIn, Department department,StockDefinitionStatus definitionStatus, int confirmFlag = 0,string description ="") { IDictionary<Product,long> productList = new Dictionary<Product, long>(); foreach (var detail in stockIn.StockInDetails) { productList.Add(detail.Product,detail.Quantity); } return Create( department, productList, stockIn.CreateId, stockIn.CreateDate, definitionStatus, description, 0); }
public static StockOut Create(Department department,IDictionary<Product,long> productList, string createId,DateTime createDate,StockDefinitionStatus definitionStatus,string description,int confirmFlag = 1) { CoralPOS.Models.StockOut stockOut = new CoralPOS.Models.StockOut { CreateDate = createDate, ConfirmFlg = confirmFlag, CreateId = createId, UpdateId = createId, UpdateDate = createDate, Description = description, Department = department, DefinitionStatus = definitionStatus, ExclusiveKey = 0, DelFlg = 0, StockOutDate = createDate, StockOutDetails = new List<StockOutDetail>(), }; foreach (var stockInProduct in productList) { CoralPOS.Models.StockOutDetail detail = new StockOutDetail { StockOut = stockOut, CreateDate = createDate, UpdateDate = createDate, CreateId = createId, UpdateId = createId, Description = description, DelFlg = 0, ExclusiveKey = 0, Quantity = stockInProduct.Value, Product = stockInProduct.Key, ProductMaster = stockInProduct.Key.ProductMaster, GoodQuantity = stockInProduct.Value, DefectStatusId = definitionStatus.DefectStatusId }; stockOut.StockOutDetails.Add(detail); } return stockOut; }
public static StockIn Create(Department department,IDictionary<Product,long> productList, string createId,DateTime createDate,string description,int stockInType = 1,int confirmFlag = 1) { CoralPOS.Models.StockIn stockIn = new CoralPOS.Models.StockIn { CreateDate = createDate, ConfirmFlg = confirmFlag, CreateId = createId, UpdateId = createId, UpdateDate = createDate, Description = description, ExclusiveKey = 0, DelFlg = 0, StockInDate = createDate, StockInDetails = new List<StockInDetail>(), StockInType = 3, }; foreach (var tempValid in productList) { CoralPOS.Models.StockInDetail detail = new StockInDetail { StockIn = stockIn, CreateDate = createDate, UpdateDate = createDate, CreateId = createId, UpdateId = createId, DelFlg = 0, ExclusiveKey = 0, Quantity = tempValid.Value, Product = tempValid.Key, ProductMaster = tempValid.Key.ProductMaster, StockInType = stockInType, }; stockIn.StockInDetails.Add(detail); } return stockIn; }
protected override void OnInitialize() { base.OnInitialize(); var list = Flow.Session.Get(FlowConstants.PRODUCT_NAMES_LIST); DefinitionStatus = new StockDefinitionStatus(); ProductMasterList = list as IList; var deptsList = Flow.Session.Get(FlowConstants.DEFINITION_STATUS_LIST); DefinitionStatusList = deptsList as IList; ProductMaster = new CoralPOS.Models.ProductMaster(); var details = new ArrayList(); StockOutDetails = details; CreateDate = DateTime.Now; CoralPOS.Models.StockOut stockOut = Flow.Session.Get(FlowConstants.SAVE_STOCK_OUT) as CoralPOS.Models.StockOut; if (stockOut != null) { StockOutDetails = ObjectConverter.ConvertFrom(stockOut.StockOutDetails); DefinitionStatus = stockOut.DefinitionStatus; } else { /*StockDefinitionStatus definitionStatus = DataErrorInfoFactory.Create<StockDefinitionStatus>(); definitionStatus.DefectStatusId = (int)StockOutType.Normal; definitionStatus.DefectStatusName = "NORMAL";*/ Department department = new Department{ DepartmentId = 0,DepartmentName = "KHO CHINH"}; stockOut = DataErrorInfoFactory.Create<CoralPOS.Models.StockOut>(); stockOut.ConfirmFlg = 0; stockOut.CreateDate = DateTime.Now; stockOut.UpdateDate = DateTime.Now; stockOut.StockOutDate = DateTime.Now; stockOut.CreateId = "admin"; stockOut.UpdateId = "admin"; stockOut.DelFlg = 0; stockOut.ExclusiveKey = 0; stockOut.Department = department; /*stockOut.DefinitionStatus = definitionStatus;*/ } StockOut = stockOut; }
public void Delete(Department data) { DepartmentDao.Delete(data); }
public Department Add(Department data) { DepartmentDao.Add(data); return data; }
public void Update(Department data) { DepartmentDao.Update(data); }
/// <summary> /// Populates the stock temp valid list. /// </summary> /// <param name="selectedDepartment">The selected department.</param> /// <returns></returns> private object PopulateStockTempValidList(Department selectedDepartment) { IList<DepartmentStockTempValid> list = DepartmentStockTempValidLogic.FindStockTempValidForDepartment(SelectedDepartment); /* ------------ PATCH FOR USING DepartmentStockTempValidDTO --------- */ var showList = DepartmentStockTempValidDTO.From(list); StockInventoryList = showList as IList; CalculateSum(); // populate ProductTypeList var productMasterList = (from stockValid in list select stockValid.ProductMaster).Distinct().ToList(); var productTypeList = (from prdMaster in productMasterList select prdMaster.ProductType).Distinct().ToList(); productTypeList.Insert(0, new ProductType { TypeId = 0, TypeName = "TAT CA CAC LOAI" }); ProductTypeList = productTypeList as IList; ProductMasterList = productMasterList as IList; return 0; }
public void OnActivated() { var list = Flow.Session.Get(FlowConstants.PRODUCT_NAMES_LIST); ProductMasterList = list as IList; var deptsList = Flow.Session.Get(FlowConstants.DEPARTMENTS); Departments = deptsList as IList; ProductMaster = new CoralPOS.Models.ProductMaster(); var details = new ArrayList(); DepartmentStockOutDetails = details; CreateDate = DateTime.Now; CoralPOS.Models.DepartmentStockOut stockOut = Flow.Session.Get(FlowConstants.SAVE_DEPT_STOCK_OUT) as CoralPOS.Models.DepartmentStockOut; if (stockOut != null) { DepartmentStockOutDetails = ObjectConverter.ConvertFrom(stockOut.DepartmentStockOutDetails); Department = new Department { DepartmentId = stockOut.DepartmentStockOutPK.DepartmentId, DepartmentName = "CK" }; } else { StockDefinitionStatus definitionStatus = DataErrorInfoFactory.Create<StockDefinitionStatus>(); definitionStatus.DefectStatusId = (int)StockOutType.Normal; definitionStatus.DefectStatusName = "NORMAL"; stockOut = DataErrorInfoFactory.Create<CoralPOS.Models.DepartmentStockOut>(); stockOut.ConfirmFlg = 0; stockOut.CreateDate = DateTime.Now; stockOut.UpdateDate = DateTime.Now; stockOut.StockOutDate = DateTime.Now; stockOut.CreateId = "admin"; stockOut.UpdateId = "admin"; stockOut.DelFlg = 0; stockOut.ExclusiveKey = 0; stockOut.StockDefinitionStatus = definitionStatus; } DepartmentStockOut = stockOut; }
protected bool Equals(Department entity) { if (entity == null) return false; if (!base.Equals(entity)) return false; return true; }
public IList<DepartmentStockTempValid> FindStockTempValidForDepartment(Department selectedDepartment) { if(selectedDepartment.DepartmentId == 0) // main stock { return (IList<DepartmentStockTempValid>)DepartmentStockTempValidDao.Execute(delegate(ISession session) { var query = session.Query<MainStock>(); /*query.Expand("Product"); query.Expand("ProductMaster");*/ var stockList = from stock in query.Fetch(x=>x.Product).ThenFetch(x=>x.ProductMaster) where stock.Quantity > 0 select stock; var result = from stock in (stockList.ToList()) select new DepartmentStockTempValid { DepartmentStockTempValidPK = new DepartmentStockTempValidPK { CreateDate = DateTime.Now, DepartmentId = selectedDepartment.DepartmentId, ProductId = stock.Product.ProductId }, CreateId = "admin", UpdateId = "admin", ProductMaster = stock.ProductMaster, Product = stock.Product, UpdateDate = DateTime.Now, DamageQuantity = 0, DelFlg = 0, ErrorQuantity = 0, ExclusiveKey = 0, Quantity = stock.Quantity, GoodQuantity = 0, LostQuantity = 0, ExFld1 = 0, ExFld2 = 0, ExFld3 = 0, ExFld4 = "", ExFld5 = "", Fixed = 0, OnStorePrice = 0, UnconfirmQuantity = 0 }; return result.ToList(); } ); } else // department stock { return (IList<DepartmentStockTempValid>)DepartmentStockTempValidDao.Execute(delegate(ISession session) { var query = session.Query<DepartmentStock>(); /*query.Expand("Product"); query.Expand("ProductMaster");*/ var stockList = from stock in query.Fetch(x=>x.Product).ThenFetch(x=>x.ProductMaster) where stock.Quantity > 0 select stock; var result = from stock in (stockList.ToList()) select new DepartmentStockTempValid { DepartmentStockTempValidPK = new DepartmentStockTempValidPK { CreateDate = DateTime.Now, DepartmentId =selectedDepartment.DepartmentId, ProductId = stock.Product.ProductId }, CreateId = "admin", UpdateId = "admin", UpdateDate = DateTime.Now, ProductMaster = stock.ProductMaster, Product = stock.Product, DamageQuantity = 0, DelFlg = 0, ErrorQuantity = 0, ExclusiveKey = 0, Quantity = stock.Quantity, GoodQuantity = 0 }; return result.ToList(); } ); } }
protected override void OnActivate() { SelectedDepartment = new Department(); Departments = new ArrayList(); ObjectCriteria<Department> criteria = new ObjectCriteria<Department>(); criteria.Add(t => t.DepartmentId > 0); IList<CoralPOS.Models.Department> departments = DepartmentLogic.FindAll(criteria); Departments = ObjectConverter.ConvertFrom(departments); }
public static void WriteLastSyncTime(DateTime syncTime, string exportPath, Department department, SyncType syncType) { DateTime lastSyncTime = DateTime.Now; string mark = "_Status"; if (syncType == SyncType.SyncUp) { mark += "SyncUp"; } if (syncType == SyncType.SyncDown) { mark += "SyncDown"; } string lastSyncFile = exportPath + "\\" + department.DepartmentId + mark + ".synctime"; Stream stream = File.Open(lastSyncFile, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, syncTime); stream.Close(); }
public static DateTime GetLastSyncTime(string exportPath, Department department, SyncType syncType) { DateTime lastSyncTime = DateTime.MinValue; string[] syncTimeFiles = Directory.GetFiles(exportPath, "*.synctime"); string mark = "_Status"; if (syncType == SyncType.SyncUp) { mark += "SyncUp"; } if (syncType == SyncType.SyncDown) { mark += "SyncDown"; } foreach (string file in syncTimeFiles) { if (file.IndexOf(department.DepartmentId + mark) >= 0) { Stream stream = File.OpenRead(file); BinaryFormatter formatter = new BinaryFormatter(); lastSyncTime = (DateTime)formatter.Deserialize(stream); stream.Close(); } } return lastSyncTime; }
public static string EnsureSyncPath(string path, Department department) { string ensurePath = path + "\\" + department.DepartmentId; bool result = false; try { if (!Directory.Exists(ensurePath)) { Directory.CreateDirectory(ensurePath); } result = true; } catch (Exception) { } if (result) { return ensurePath; } else { return path; } }