void mainStockInView_DispatchDepartmentStockOut(object sender, DepartmentStockOutEventArgs e) { Department destDept = DepartmentLogic.FindById(e.DepartmentStockOut.OtherDepartmentId); if (destDept != null) { foreach (DepartmentStockOutDetail detail in e.DepartmentStockOut.DepartmentStockOutDetails) { string prdMasterId = detail.Product.ProductMaster.ProductMasterId; DepartmentPricePK pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = prdMasterId }; detail.DepartmentPrice = DepartmentPriceLogic.FindById(pricePk); } ServerServiceClient serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding); serverService.MakeRawDepartmentStockOut(destDept,e.DepartmentStockOut,new DepartmentPrice()); } }
public void _departmentStockOutView_LoadProductSizeEvent(object sender, DepartmentStockOutEventArgs e) { if (e.SelectedDepartmentStockOutDetail != null && e.SelectedDepartmentStockOutDetail.Product != null && !string.IsNullOrEmpty(e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductName)) { var subCriteria = new SubObjectCriteria("ProductMasters"); subCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); subCriteria.AddEqCriteria("ProductType", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductType); subCriteria.AddEqCriteria("ProductName", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductName); subCriteria.AddEqCriteria("ProductColor", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductColor); subCriteria.AddEqCriteria("Country", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Country); subCriteria.AddEqCriteria("Manufacturer", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Manufacturer); subCriteria.AddEqCriteria("Distributor", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Distributor); subCriteria.AddEqCriteria("Packager", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Packager); var criteria = new ObjectCriteria(); criteria.AddSubCriteria("ProductMasters", subCriteria); IList productSizes = ProductSizeLogic.FindAll(criteria); e.ProductSizeList = productSizes; } }
public void _departmentStockOutView_SaveStockOutEvent(object sender, DepartmentStockOutEventArgs e) { if (e.DepartmentStockOut.DepartmentStockOutPK == null || e.DepartmentStockOut.DepartmentStockOutPK.StockOutId == 0) { DepartmentStockOutLogic.Add(e.DepartmentStockOut); ClientUtility.Log(logger, e.DepartmentStockOut.ToString(), "Lưu xuất kho cửa hàng"); e.EventResult = "Success"; } }
public void _departmentStockOutView_FindBarcodeEvent(object sender, DepartmentStockOutEventArgs e) { var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("Product.ProductId", e.ProductId); IList list = DepartmentStockLogic.FindAll(criteria); if (list.Count == 0) { return; } Stock stock = list[0] as Stock; e.SelectedDepartmentStockOutDetail = new DepartmentStockOutDetail(); e.SelectedDepartmentStockOutDetail.Product = stock.Product; e.SelectedDepartmentStockOutDetail.Quantity = stock.Quantity; e.SelectedDepartmentStockOutDetail.GoodQuantity = stock.Quantity; e.SelectedDepartmentStockOutDetail.ErrorQuantity = stock.ErrorQuantity; e.SelectedDepartmentStockOutDetail.LostQuantity = stock.LostQuantity; e.SelectedDepartmentStockOutDetail.DamageQuantity = stock.DamageQuantity; e.SelectedDepartmentStockOutDetail.UnconfirmQuantity = stock.UnconfirmQuantity; e.EventResult = "Success"; }
public void _departmentStockOutView_LoadGoodsByNameColorSizeEvent(object sender, DepartmentStockOutEventArgs e) { throw new NotImplementedException(); }
private void cboProductMasters_DropDown(object sender, EventArgs e) { var mainStockInEventArgs = new DepartmentStockOutEventArgs(); /*if (dgvDeptStockIn == null || dgvDeptStockIn.CurrentRow == null) { return; }*/ // selectectIndex is the firstrow //int selectedIndex = 0; //mainStockInEventArgs.SelectedIndex = selectedIndex; //mainStockInEventArgs.SelectedStockInDetail = deptSODetailList[selectedIndex]; mainStockInEventArgs.SelectedDepartmentStockOutDetail = new DepartmentStockOutDetail { Product = new Product { ProductMaster = new ProductMaster { ProductName = cboProductMasters.Text } } }; mainStockInEventArgs.IsFillToComboBox = true; mainStockInEventArgs.ComboBoxDisplayMember = "ProductName"; EventUtility.fireEvent<DepartmentStockOutEventArgs>(FillProductToComboEvent, cboProductMasters, mainStockInEventArgs); }
private void DepartmentStockInExtra_Load(object sender, EventArgs e) { timer1.Start(); cbbStockOutType.Enabled = false; btnReset.Enabled = false; cboProductMasters.Enabled = false; rdoFastStockOut.Checked = true; rdoRetail.Checked = true; IList list = new ArrayList(); if (ClientSetting.IsSubStock()) { list.Add(new StockDefectStatus {DefectStatusId = 7, DefectStatusName = "Xuất đi cửa hàng khác"}); } else { list.Add(new StockDefectStatus { DefectStatusId = 4, DefectStatusName = "Xuất tạm để sửa hàng" }); list.Add(new StockDefectStatus { DefectStatusId = 6, DefectStatusName = "Xuất trả về kho chính" }); } DepartmentStockOutEventArgs eventArgs = new DepartmentStockOutEventArgs(); EventUtility.fireEvent(LoadAllDepartments,this,eventArgs); string directDept = ""; string marketDept = ""; if(eventArgs.DepartmentsList!= null && eventArgs.DepartmentsList.Count > 0) { BindingSource bdsDepartment = new BindingSource(); bdsDepartment.DataSource = typeof (Department); cboDepartment.DataSource = bdsDepartment; cboDepartment.DisplayMember = "DepartmentName"; foreach (Department department in eventArgs.DepartmentsList) { if (department.DepartmentId != CurrentDepartment.Get().DepartmentId) { /*if (!ClientSetting.IsSubStock()) {*/ bdsDepartment.Add(department); /*} else { string departmentId = department.DepartmentId.ToString(); string currentSubStock = CurrentDepartment.Get().DepartmentId.ToString(); if(currentSubStock.StartsWith(departmentId)) { bdsDepartment.Add(department); directDept = department.DepartmentName; } if(ClientSetting.MarketDept.Equals(departmentId)) { bdsDepartment.Add(department); marketDept = department.DepartmentName; } }*/ } } bdsDepartment.EndEdit(); cboDepartment.Refresh(); cboDepartment.Invalidate(); } cbbStockOutType.DataSource = list; cbbStockOutType.DisplayMember = "DefectStatusName"; /*if(!string.IsNullOrEmpty(directDept)) { rdoFastStockOut.Text = " Xuất đến " + directDept; }*/ /*foreach (Department department in cboDepartment.Items) { string departmentId = department.DepartmentId.ToString(); string currentSubStock = CurrentDepartment.Get().DepartmentId.ToString(); if (currentSubStock.StartsWith(departmentId)) { cboDepartment.SelectedItem = department; cboDepartment.Enabled = false; break; } }*/ rdoFastStockOut_CheckedChanged(null, null); rdoStockOut_CheckedChanged(null, null); deptSODetailList = new DepartmentStockOutDetailCollection(bdsStockIn); bdsStockIn.DataSource = deptSODetailList; dgvDeptStockIn.DataError += new DataGridViewDataErrorEventHandler(dgvDeptStockIn_DataError); // create DepartmentStockIn if (deptSO == null) { deptSO = new DepartmentStockOut(); deptSO.CreateDate = DateTime.Now; deptSO.UpdateDate = DateTime.Now; deptSO.CreateId = ClientInfo.getInstance().LoggedUser.Name; deptSO.UpdateId = ClientInfo.getInstance().LoggedUser.Name; deptSO.ExclusiveKey = 0; CreateNewStockInDetail(); // btnBarcode.Visible = false; // numericUpDownBarcode.Visible = false; // btnPreview.Visible = false; // load products to extra combo box LoadProductMasterToComboBox(); deptSODetailList.RemoveAt(0); bdsStockIn.EndEdit(); } else { // btnBarcode.Visible = true; // numericUpDownBarcode.Visible = true; // btnPreview.Visible = true; IList deptStockInDetails = deptSO.DepartmentStockOutDetails; foreach (DepartmentStockOutDetail detail in deptStockInDetails) { if (detail.DelFlg == CommonConstants.DEL_FLG_NO) { deptSODetailList.Add(detail); //detail.OldQuantity = detail.Quantity; } } for (int i = 0; i < dgvDeptStockIn.Columns.Count; i++) { dgvDeptStockIn.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; if (i != QUANTITY_POS && i != PRICE_POS && i != SELL_PRICE_POS) { dgvDeptStockIn.Columns[i].ReadOnly = true; } } // txtDexcription.Text = deptSO.Description; } deptSO.DepartmentStockOutDetails = ObjectConverter.ConvertToNonGenericList<DepartmentStockOutDetail>(deptSODetailList); UpdateStockOutDescription(); cboDepartment.Enabled = false; GlobalMessage message = (GlobalMessage)GlobalUtility.GetObject("GlobalMessage"); message.HasNewMessageEvent += new EventHandler<GlobalMessageEventArgs>(Instance_HasNewMessageEvent); }
public void _departmentStockOutView_SaveStockOutEvent(object sender, DepartmentStockOutEventArgs e) { if (e.DepartmentStockOut.DepartmentStockOutPK == null || e.DepartmentStockOut.DepartmentStockOutPK.StockOutId == 0) { if(e.DepartmentStockOut.DepartmentStockOutDetails!= null && e.DepartmentStockOut.DepartmentStockOutDetails.Count > 0) { foreach (DepartmentStockOutDetail detail in e.DepartmentStockOut.DepartmentStockOutDetails) { string prdMasterId = detail.Product.ProductMaster.ProductMasterId; DepartmentPricePK pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = prdMasterId }; detail.DepartmentPrice = DepartmentPriceLogic.FindById(pricePk); if (detail.DepartmentPrice != null) { if ("1".Equals(detail.Description)) // if ban si { if(detail.DepartmentPrice.WholeSalePrice == 0 ) { e.EventResult = " Error !"; throw new BusinessException(" Giá sỉ của " + detail.Product.ProductMaster.ProductName + " là 0 ?!"); } detail.Description = detail.DepartmentPrice.WholeSalePrice.ToString(); } else { if (ClientSetting.IsSubStock()) { if (detail.DepartmentPrice.Price == 0) { e.EventResult = null; throw new BusinessException(" Giá lẻ của " + detail.Product.ProductMaster.ProductName + " là 0 ?!"); } } detail.Description = detail.DepartmentPrice.Price.ToString(); } } } } DepartmentStockOutLogic.Add(e.DepartmentStockOut); ClientUtility.Log(logger, e.DepartmentStockOut.ToString(), "Lưu xuất kho cửa hàng"); e.EventResult = "Success"; } }
void deptStockOutView_DispatchDepartmentStockOut(object sender, DepartmentStockOutEventArgs e) { Department destDept = DepartmentLogic.FindById(e.DepartmentStockOut.OtherDepartmentId); if (destDept != null) { foreach (DepartmentStockOutDetail detail in e.DepartmentStockOut.DepartmentStockOutDetails) { string prdMasterId = detail.Product.ProductMaster.ProductMasterId; DepartmentPricePK pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = prdMasterId }; detail.DepartmentPrice = DepartmentPriceLogic.FindById(pricePk); } SyncFromDeptToDept fromDeptToDept = new SyncFromDeptToDept { DestinationDept = destDept }; fromDeptToDept.DepartmentStockOutList = new ArrayList(); fromDeptToDept.DepartmentStockOutList.Add(e.DepartmentStockOut); CopyToSyncFolder(fromDeptToDept); ServerServiceClient serverService = new ServerServiceClient(new InstanceContext(this), ClientSetting.ServiceBinding); serverService.MakeRawDepartmentStockOut(destDept,e.DepartmentStockOut,new DepartmentPrice()); } }
public void _departmentStockOutView_LoadGoodsByNameColorSizeEvent(object sender, DepartmentStockOutEventArgs e) { }
public void _departmentStockOutView_LoadStockStatusEvent(object sender, DepartmentStockOutEventArgs e) { if (e.SelectedProductMasterList == null || e.SelectedProductMasterList.Count == 0) return; IList productMasterIds = new ArrayList(); foreach (ProductMaster master in e.SelectedProductMasterList) { productMasterIds.Add(master.ProductMasterId); } ObjectCriteria prdCrit = new ObjectCriteria(); prdCrit.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); prdCrit.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds); IList prdList = ProductLogic.FindAll(prdCrit); IList stkPrdIdsList = new ArrayList(); foreach (Product product in prdList) { stkPrdIdsList.Add(product.ProductId); } var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddSearchInCriteria("DepartmentStockPK.ProductId", stkPrdIdsList); IList list = DepartmentStockLogic.FindAll(criteria); if (list.Count == 0) { return; } e.DepartmentStockList = new ArrayList(); e.FoundDepartmentStockOutDetailList = new ArrayList(); foreach (DepartmentStock stock in list) { /*if(stock.Quantity == 0) { continue; }*/ DepartmentStockOutDetail detail = new DepartmentStockOutDetail(); detail.DepartmentStockOutDetailPK = new DepartmentStockOutDetailPK { DepartmentId = CurrentDepartment.Get().DepartmentId }; detail.Product = stock.Product; detail.GoodQuantity = stock.GoodQuantity; detail.ErrorQuantity = stock.ErrorQuantity; detail.LostQuantity = stock.LostQuantity; detail.DamageQuantity = stock.DamageQuantity; detail.UnconfirmQuantity = stock.UnconfirmQuantity; detail.Quantity = stock.Quantity; e.DepartmentStockList.Add(stock); e.FoundDepartmentStockOutDetailList.Add(detail); } }
public void _departmentStockOutView_FindBarcodeEvent(object sender, DepartmentStockOutEventArgs e) { var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId); criteria.AddEqCriteria("DepartmentStockPK.ProductId", e.ProductId); IList list = DepartmentStockLogic.FindAll(criteria); if (list.Count == 0) { /* begin +++++++++++++++++++ XUAT TRUOT LO CHO KHO PHU +++++++++++++++++++++ */ if(ClientSetting.IsBlockSliding && ClientSetting.IsSubStock()) { // just sub-stock has the right to do block sliding if(ClientSetting.IsSubStock()) { Product product = ProductLogic.FindById(e.ProductId); if(product == null ) throw new BusinessException("Mã vạch này chưa từng được nhập vào kho."); ProductColor color = product.ProductMaster.ProductColor; ProductSize size = product.ProductMaster.ProductSize; string productName = product.ProductMaster.ProductName; var productCriteria = new ObjectCriteria(); IList slidedStockList = DepartmentStockLogic.FindSlidingStock(productName,color.ColorName,size.SizeName); BusinessException emptyStockException = new BusinessException(" Hàng " + productName + " - Màu:" + color.ColorName + " - Size:" + size.SizeName + " đã hết. Xin kiểm tra lại !"); if (slidedStockList.Count == 0) throw emptyStockException; foreach (DepartmentStock departmentStock in slidedStockList) { if(departmentStock.Quantity > 0 && departmentStock.GoodQuantity > 0 ) { list.Add(departmentStock); break; } } if (list.Count == 0) throw emptyStockException; } else // throw error if not sub stock { throw new BusinessException("Bạn đang dùng chức năng xuất trượt lô cho mã vạch không có trong kho. Chức năng xuất trượt lô chỉ có trong kho phụ."); return; } } else { throw new BusinessException("Mã vạch này không có trong kho ?!?! Đề nghị kiểm tra lại."); return; } /* end +++++++++++++++++++ XUAT TRUOT LO CHO KHO PHU +++++++++++++++++++++ */ } DepartmentStock stock = list[0] as DepartmentStock; e.SelectedDepartmentStockOutDetail = new DepartmentStockOutDetail(); e.SelectedDepartmentStockOutDetail.DepartmentStockOutDetailPK = new DepartmentStockOutDetailPK { DepartmentId = CurrentDepartment.Get().DepartmentId }; e.SelectedDepartmentStockOutDetail.Product = stock.Product; e.SelectedDepartmentStockOutDetail.Quantity = stock.Quantity; e.SelectedDepartmentStockOutDetail.GoodQuantity = stock.Quantity; e.SelectedDepartmentStockOutDetail.ErrorQuantity = stock.ErrorQuantity; e.SelectedDepartmentStockOutDetail.LostQuantity = stock.LostQuantity; e.SelectedDepartmentStockOutDetail.DamageQuantity = stock.DamageQuantity; e.SelectedDepartmentStockOutDetail.UnconfirmQuantity = stock.UnconfirmQuantity; e.DepartmentStock = stock; e.EventResult = "Success"; }
private void btnStart_Click(object sender, EventArgs e) { if(!CheckPOSSyncDriveExist()) return; string POSSyncDrive = ClientUtility.GetPOSSyncDrives()[0].ToString(); bool isConfirmPeriod = false; DialogResult dResult = MessageBox.Show( "Bạn xác định kết sổ cho ngày hôm nay ? Nếu phải, bấm Yes, còn nếu không, bấm No. Không làm gì, bấm Cancel", "Kết sổ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if(dResult == DialogResult.Cancel) { return; } if(dResult== DialogResult.Yes) { isConfirmPeriod = true; } // sync var configurationAppSettings = new AppSettingsReader(); syncResultBindingSource.DataSource = null; var exportPath = POSSyncDrive + ClientSetting.SyncExportPath; if (string.IsNullOrEmpty(exportPath) || !Directory.Exists(exportPath)) { MessageBox.Show("Không thể tìm thấy đường dẫn đến thư mục " + exportPath + "!Hãy kiễm tra file cấu hình phần SyncExportPath"); return; } try { // dump db ClientUtility.DumpDatabase(); exportPath = ClientUtility.EnsureSyncPath(exportPath, CurrentDepartment.Get()); // get last sync time DateTime lastSyncTime = ClientUtility.GetLastSyncTime(exportPath, CurrentDepartment.Get(),ClientUtility.SyncType.SyncUp); SyncResult result = new SyncResult(); string fileName = exportPath + "\\" + CurrentDepartment.Get().DepartmentId + "_SyncUp_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + CommonConstants.CLIENT_SYNC_FORMAT; var eventArgs = new DepartmentStockOutEventArgs(); eventArgs.IsConfirmPeriod = isConfirmPeriod; eventArgs.LastSyncTime = lastSyncTime; EventUtility.fireEvent(GetSyncDataEvent, this, eventArgs); SyncFromDepartmentToMain syncData = eventArgs.SyncFromDepartmentToMain; if (syncData != null) { Stream stream = File.Open(fileName, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, syncData); stream.Close(); result.FileName = fileName; result.Status = "Thành công"; ClientUtility.CleanDatabase(); // write last sync time //ClientUtility.WriteLastSyncTime(exportPath,CurrentDepartment.Get(),ClientUtility.SyncType.SyncUp); MessageBox.Show("Đồng bộ thành công"); } else { MessageBox.Show("Đồng bộ thất bại"); result.FileName = fileName; result.Status = "Thất bại"; } IList resultList = new ArrayList(); resultList.Add(result); syncResultBindingSource.DataSource = resultList; } catch (Exception exps) { if(exps is BusinessException) { MessageBox.Show(exps.Message); } else { MessageBox.Show("Có lỗi xảy ra"); } //throw; } // } }
private void btnSyncToMain_Click(object sender, EventArgs e) { if (!CheckPOSSyncDriveExist()) { return; } string POSSyncDrive = ClientUtility.GetPOSSyncDrives()[0].ToString(); DialogResult dResult = MessageBox.Show( "Bạn muốn đồng bộ thông tin từ cửa hàng ?", "Đồng bộ", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dResult == DialogResult.No) { return; } var configurationAppSettings = new AppSettingsReader(); //var importPath = (string)configurationAppSettings.GetValue("SyncImportPath", typeof(String)); //var successPath = (string)configurationAppSettings.GetValue("SyncImportSuccessPath", typeof(String)); //var errorPath = (string)configurationAppSettings.GetValue("SyncImportErrorPath", typeof(String)); var importPath = POSSyncDrive +ClientSetting.SyncImportPath; var successPath = POSSyncDrive + ClientSetting.SyncSuccessPath; var errorPath = POSSyncDrive + ClientSetting.SyncErrorPath; if (string.IsNullOrEmpty(importPath) || !Directory.Exists(importPath)) { MessageBox.Show("Không thể tìm thấy đường dẫn đến thư mục " + importPath + "!Hãy kiễm tra file cấu hình phần SyncImportPath"); return; } if (string.IsNullOrEmpty(successPath) || !Directory.Exists(successPath)) { MessageBox.Show("Không thể tìm thấy đường dẫn đến thư mục " + successPath + "!Hãy kiễm tra file cấu hình phần SyncImportSuccessPath"); return; } if (string.IsNullOrEmpty(errorPath) || !Directory.Exists(errorPath)) { MessageBox.Show("Không thể tìm thấy đường dẫn đến thư mục " + errorPath + "!Hãy kiễm tra file cấu hình phần SyncImportErrorPath"); return; } string[] fileNames = Directory.GetFiles(importPath, "*"+ CommonConstants.CLIENT_SYNC_FORMAT); if (fileNames.Length == 0) { MessageBox.Show("Không thể tìm thấy file nào để đồng bộ"); return; } StringBuilder errorStr = new StringBuilder(); foreach (string fileName in fileNames) { SyncFromDepartmentToMain deptStockIn = null; Stream stream = null; bool fail = true; try { stream = File.Open(fileName, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); deptStockIn = (SyncFromDepartmentToMain)bf.Deserialize(stream); if (deptStockIn == null) { fail = true; } else { var eventArgs = new DepartmentStockOutEventArgs(); eventArgs.SyncFromDepartmentToMain = deptStockIn; EventUtility.fireEvent(SyncToMainEvent, this, eventArgs); if (eventArgs.EventResult != null) { fail = false; } else { fail = true; } } } finally { if (stream != null) { stream.Close(); } if (fail) { //File.Move(fileName, errorPath + "\\" + fileName.Substring(fileName.LastIndexOf("\\"), fileName.Length - fileName.LastIndexOf("\\"))); ClientUtility.MoveFileToSpecificDir(errorPath, fileName); errorStr.Append(" > " + fileName.Substring(fileName.LastIndexOf("\\"), fileName.Length - fileName.LastIndexOf("\\")) + "\r\n"); } else { ClientUtility.MoveFileToSpecificDir(successPath, fileName); //File.Move(fileName, successPath + "\\" + fileName.Substring(fileName.LastIndexOf("\\"), fileName.Length - fileName.LastIndexOf("\\"))); } } } if (errorStr.Length > 0) { MessageBox.Show("Có lỗi diễn ra: \r\n" + errorStr.ToString()); } else { MessageBox.Show("Đồng bộ hoàn tất !"); } // var fileOpen = new OpenFileDialog(); // fileOpen.InitialDirectory = ".\\"; // fileOpen.Filter = "POS (*.xac)|*.xac"; // fileOpen.FilterIndex = 0; // fileOpen.RestoreDirectory = true; // if (fileOpen.ShowDialog() == DialogResult.OK) // { // string filePath = fileOpen.FileName; // if (String.IsNullOrEmpty(filePath)) // { // MessageBox.Show("Không tìm thấy file đồng bộ"); // return; // } // if (!File.Exists(filePath)) // { // MessageBox.Show("File đồng bộ không tồn tại"); // return; // } // SyncFromDepartmentToMain deptStockIn = null; // try // { // Stream stream = File.Open(filePath, FileMode.Open); // BinaryFormatter bf = new BinaryFormatter(); // deptStockIn = (SyncFromDepartmentToMain)bf.Deserialize(stream); // stream.Close(); // // if (deptStockIn == null) // { // MessageBox.Show("File đồng bộ bị lỗi"); // return; // } // } // catch (Exception) // { // MessageBox.Show("File đồng bộ bị lỗi"); // } // if (deptStockIn != null) // { // var eventArgs = new DepartmentStockOutEventArgs(); // eventArgs.SyncFromDepartmentToMain = deptStockIn; // EventUtility.fireEvent(SyncToMainEvent, this, eventArgs); // if (eventArgs.EventResult != null) // { // MessageBox.Show("Đồng bộ hoàn tất !"); // } // else // { // MessageBox.Show("Đồng bộ thất bại!"); // } // } // } }
private void btnInput_Click(object sender, EventArgs e) { if (cbbStockOutType.SelectedIndex < 0) { MessageBox.Show("Hãy chọn Loại để xuất kho"); return; } if (string.IsNullOrEmpty(txtBarcode.Text)) { if (cboProductMasters.SelectedIndex < 0) { MessageBox.Show("Hãy chọn 1 sản phẩm để xuất kho"); return; } if (lstColor.SelectedIndices == null || lstColor.SelectedIndices.Count <= 0) { MessageBox.Show("Hãy chọn màu sản phẩm để xuất kho"); return; } if (lstSize.SelectedIndices == null || lstSize.SelectedIndices.Count <= 0) { MessageBox.Show("Hãy chọn kích cỡ sản phẩm để xuất kho"); return; } if (cbbStockOutType.SelectedIndex < 0) { MessageBox.Show("Hãy chọn Loại để xuất kho"); return; } // long outValue = 0; // if (!NumberUtility.CheckLongNullIsZero(txtPriceIn.Text, out outValue) // || outValue < 0 // || !NumberUtility.CheckLongNullIsZero(txtPriceOut.Text, out outValue) // || outValue < 0) // { // MessageBox.Show("Giá phải là số dương"); // return; // } cbbStockOutType.Enabled = false; PopulateGridByProductMaster(lstColor.SelectedItems, lstSize.SelectedItems); } else { var eventArgs = new DepartmentStockOutEventArgs(); eventArgs.ProductId = txtBarcode.Text; EventUtility.fireEvent(FindBarcodeEvent, this, eventArgs); if (eventArgs.EventResult == null) { MessageBox.Show("Không tìm thấy mã vạch này"); return; } bool found = false; foreach (DepartmentStockOutDetail detail in deptSODetailList) { if (eventArgs.SelectedDepartmentStockOutDetail.Product.ProductId.Equals(detail.Product.ProductId)) { found = true; break; } } if (found) { MessageBox.Show("Mã vạch đã được nhập"); return; } if (eventArgs.DepartmentStock != null) { found = false; foreach (Stock detail in departmentStockList) { if (eventArgs.DepartmentStock.Product.ProductId.Equals(detail.Product.ProductId)) { found = true; break; } } if (!found) { departmentStockList.Add(eventArgs.DepartmentStock); } } eventArgs.SelectedDepartmentStockOutDetail.GoodQuantity = 1; deptSODetailList.Add(eventArgs.SelectedDepartmentStockOutDetail); deptSODetailList.EndNew(deptSODetailList.Count - 1); cbbStockOutType.Enabled = false; LockField(deptSODetailList.Count - 1, eventArgs.SelectedDepartmentStockOutDetail); } }
void deptStockOutView_FindByStockInIdEvent(object sender, DepartmentStockOutEventArgs e) { if (e.SelectedStockInIds.Count > 0) { ObjectCriteria objectCriteria = new ObjectCriteria(); objectCriteria.AddSearchInCriteria("DepartmentStockInDetailPK.StockInId", e.SelectedStockInIds); IList list = DepartmentStockInDetailLogic.FindAll(objectCriteria); IList stockOutList = new ArrayList(); foreach (DepartmentStockInDetail inDetail in list) { DepartmentStockOutDetail deptDetail = new DepartmentStockOutDetail(); deptDetail.CreateDate = DateTime.Now; deptDetail.UpdateDate = DateTime.Now; deptDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; //deptDetail. = new DepartmentStockInDetailPK(); deptDetail.Product = inDetail.Product; deptDetail.ProductMaster = inDetail.Product.ProductMaster; deptDetail.Quantity = inDetail.Quantity; deptDetail.GoodQuantity = inDetail.Quantity; stockOutList.Add(deptDetail); } IList stockList = GetRemainStockNumber(stockOutList); e.FoundDepartmentStockOutDetailList = stockOutList; e.DepartmentStockList = stockList; } EventUtility.fireEvent(CompletedFindByStockInEvent, this, e); }
private void btnSave_Click(object sender, EventArgs e) { ShowMessage("Đang lưu .... "); DialogResult result = MessageBox.Show(lblCommandDescription.Text +".Chắc chắn muốn lưu ?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if(result == System.Windows.Forms.DialogResult.No) { return; } // first remove all blank row int count = 0; int length = deptSODetailList.Count; for (int i = 0; i < length - count; i++) { DepartmentStockOutDetail detail = deptSODetailList[i]; if (string.IsNullOrEmpty(detail.Product.ProductMaster.ProductMasterId) && string.IsNullOrEmpty(detail.Product.ProductMaster.ProductName)) { deptSODetailList.RemoveAt(i - count); count++; } } if (deptSODetailList.Count == 0) { MessageBox.Show("Không có sản phẩm nào để nhập kho!!!!"); return; } // validate quantity int line = 1; foreach (DepartmentStockOutDetail detail in deptSODetailList) { foreach (DepartmentStock stock in departmentStockList) { if (detail.Product.ProductId.Equals(stock.Product.ProductId)) { // TEMP FIXING FOR EXPORT NEGATIVE STOCK if (!ClientSetting.NegativeExport) { if (detail.GoodQuantity <= 0 || detail.GoodQuantity > stock.GoodQuantity) { MessageBox.Show("Lỗi ở dòng " + line + " : Số lượng Xuất phải là số dương nhỏ hơn hoặc bằng " + stock.GoodQuantity); dgvDeptStockIn.CurrentCell = dgvDeptStockIn[7, line-1]; return; } } if (detail.LostQuantity < 0 || detail.LostQuantity > stock.LostQuantity) { MessageBox.Show("Lỗi ở dòng " + line + " : Số lượng Mất phải là số dương nhỏ hơn hoặc bằng " + stock.LostQuantity); dgvDeptStockIn.CurrentCell = dgvDeptStockIn[7, line-1]; return; } if (detail.DamageQuantity < 0 || detail.DamageQuantity > stock.DamageQuantity) { MessageBox.Show("Lỗi ở dòng " + line + " : Số lượng Lỗi phải là số dương nhỏ hơn hoặc bằng " + stock.DamageQuantity); dgvDeptStockIn.CurrentCell = dgvDeptStockIn[7, line-1]; return; } if (detail.ErrorQuantity < 0 || detail.ErrorQuantity > stock.ErrorQuantity) { MessageBox.Show("Lỗi ở dòng " + line + " : Số lượng Hư phải là số dương nhỏ hơn hoặc bằng " + stock.ErrorQuantity); dgvDeptStockIn.CurrentCell = dgvDeptStockIn[7, line-1]; return; } } } if ((detail.DefectStatus.DefectStatusId == 4 && detail.ErrorQuantity == 0) || (detail.DefectStatus.DefectStatusId == 6 && detail.DamageQuantity + detail.GoodQuantity + detail.ErrorQuantity == 0) || (detail.DefectStatus.DefectStatusId == 7 && detail.GoodQuantity == 0)) { MessageBox.Show("Lỗi ở dòng " + line + " : Số lượng xuất phải lớn hơn 0."); dgvDeptStockIn.CurrentCell = dgvDeptStockIn[0, line]; return; } line++; } if (deptSO == null) { deptSO = new DepartmentStockOut(); } bool isNeedClearData = deptSO.DepartmentStockOutPK == null || deptSO.DepartmentStockOutPK.StockOutId == 0; deptSO.StockOutDate = DateTime.Now; deptSO.DefectStatus = (StockDefectStatus)cbbStockOutType.SelectedItem; deptSO.OtherDepartmentId = ((Department)cboDepartment.SelectedItem).DepartmentId; deptSO.DepartmentStockOutDetails = new ArrayList(); foreach (DepartmentStockOutDetail outDetail in deptSODetailList) { deptSO.DepartmentStockOutDetails.Add(outDetail); } //deptSO.DepartmentStockOutDetails = deptSODetailList; //deptSO.ConfirmFlg = 3; foreach (DepartmentStockOutDetail outDetail in deptSO.DepartmentStockOutDetails) { if (rdoWholesale.Checked) // if ban si { outDetail.Description = "1"; } else { outDetail.Description = "0"; } } // deptSO.Description = txtDexcription.Text; var eventArgs = new DepartmentStockOutEventArgs(); eventArgs.DepartmentStockOut = deptSO; // confirm before save DialogResult isConfirmed = System.Windows.Forms.DialogResult.Cancel; if (!ClientSetting.ConfirmByEmployeeId) { LoginForm loginForm = GlobalUtility.GetFormObject<LoginForm>(FormConstants.CONFIRM_LOGIN_VIEW); loginForm.StartPosition = FormStartPosition.CenterScreen; isConfirmed = loginForm.ShowDialog(); } else { EmployeeCheckingForm employeeCheckingForm = GlobalUtility.GetFormObject<EmployeeCheckingForm>(FormConstants.EMPLOYEE_CHECKING_VIEW); employeeCheckingForm.StartPosition = FormStartPosition.CenterScreen; isConfirmed = employeeCheckingForm.ShowDialog(); } if(isConfirmed!= System.Windows.Forms.DialogResult.OK) { MessageBox.Show("Không xác nhận được nguoi gửi ....", "Lỗi",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } // continue stock out if(rdoFastStockOut.Checked) { ShowMessage("Đang truyền thông tin .... "); try { if(eventArgs.EventResult!=null) { //EventUtility.fireAsyncEvent(DispatchDepartmentStockOut, this, eventArgs, new AsyncCallback(EndEvent)); EventUtility.fireEvent(SaveStockOutEvent, this, eventArgs); EventUtility.fireEvent(DispatchDepartmentStockOut, this, eventArgs); } } catch (Exception) { lblInformation.ForeColor = Color.Red; lblInformation.Text = " Không kết nối được với máy cửa hàng! "; deptSO = new DepartmentStockOut(); deptSODetailList.Clear(); // txtDexcription.Text = ""; // txtPriceIn.Text = ""; // txtPriceOut.Text = ""; txtSumProduct.Text = ""; txtSumValue.Text = ""; return; } } if(rdoStockOut.Checked) { EventUtility.fireEvent(SaveStockOutEvent, this, eventArgs); if (eventArgs.DepartmentStockOut.DepartmentStockOutPK == null || eventArgs.DepartmentStockOut.DepartmentStockOutPK.StockOutId == 0) { ShowError(lblInformation, "Có lỗi phát sinh làm chương trình không in được. Liên hệ nhà quản trị."); } if (eventArgs.EventResult != null) { EventUtility.fireEvent(PrepareDepartmentStockOutForPrintEvent, this, eventArgs); // do printing DoPrinting(eventArgs.DepartmentStockOut); } } if (eventArgs.EventResult != null) { /*if(!rdoFastStockOut.Checked) {*/ lblInformation.Text = "Lưu thành công"; /*}*/ if (isNeedClearData) { lblInformation.ForeColor = Color.Blue; deptSO = new DepartmentStockOut(); deptSODetailList.Clear(); txtSumProduct.Text = ""; txtSumValue.Text = ""; ClearSelectionOnListBox(lstColor); ClearSelectionOnListBox(lstSize); } } else { //MessageBox.Show("Có lỗi khi lưu"); lblInformation.ForeColor = Color.Red; lblInformation.Text = "Lưu thất bại ..."; } if(LocalCache.Instance().PreviousUser !=null) { ClientInfo.getInstance().LoggedUser = LocalCache.Instance().PreviousUser; LocalCache.Instance().PreviousUser = null; } txtBarcode.Focus(); }
void deptStockOutView_LoadAllDepartments(object sender, DepartmentStockOutEventArgs e) { IList list = DepartmentLogic.FindAll(null); e.DepartmentsList = list; }
private void cboProductMasters_SelectedIndexChanged(object sender, EventArgs e) { ProductMaster proMaster = cboProductMasters.SelectedItem as ProductMaster; if (proMaster == null) { return; } string productName = proMaster.ProductName; BindingSource bindingSource = (BindingSource)cboProductMasters.DataSource; if (string.IsNullOrEmpty(productName)) { return; } var mainStockInEventArgs = new DepartmentStockOutEventArgs(); mainStockInEventArgs.SelectedDepartmentStockOutDetail = new DepartmentStockOutDetail(); mainStockInEventArgs.SelectedDepartmentStockOutDetail.DepartmentStockOutDetailPK = new DepartmentStockOutDetailPK { DepartmentId = CurrentDepartment.Get().DepartmentId }; mainStockInEventArgs.SelectedDepartmentStockOutDetail.Product = new Product { ProductMaster = new ProductMaster() }; mainStockInEventArgs.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductName = productName; EventUtility.fireEvent(LoadGoodsByNameEvent, this, mainStockInEventArgs); // clear the binding list colorBindingSource.Clear(); sizeBindingSource.Clear(); IList colorList = new ArrayList(); IList sizeList = new ArrayList(); foreach (ProductMaster productMaster in mainStockInEventArgs.FoundProductMasterList) { if (productMaster.ProductColor != null) { bool found = false; foreach (ProductColor color in colorList) { if (color.ColorId == productMaster.ProductColor.ColorId) { found = true; break; } } if (!found) { colorList.Add(productMaster.ProductColor); } } if (productMaster.ProductSize != null) { bool found = false; foreach (ProductSize size in sizeList) { if (size.SizeId == productMaster.ProductSize.SizeId) { found = true; break; } } if (!found) { sizeList.Add(productMaster.ProductSize); } } } colorBindingSource.DataSource = colorList; sizeBindingSource.DataSource = sizeList; productMasterList = mainStockInEventArgs.FoundProductMasterList; }
void deptStockOutView_PrepareDepartmentStockOutForPrintEvent(object sender, DepartmentStockOutEventArgs e) { Department destDept = DepartmentLogic.FindById(e.DepartmentStockOut.OtherDepartmentId); if (destDept != null) { foreach (DepartmentStockOutDetail detail in e.DepartmentStockOut.DepartmentStockOutDetails) { string prdMasterId = detail.Product.ProductMaster.ProductMasterId; DepartmentPricePK pricePk = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = prdMasterId }; detail.DepartmentPrice = DepartmentPriceLogic.FindById(pricePk); } } }
public void _departmentStockOutView_FillProductToComboEvent(object sender, DepartmentStockOutEventArgs e) { ComboBox comboBox = (ComboBox) sender; string originalText = comboBox.Text; if (e.IsFillToComboBox) { ProductMaster searchPM = e.SelectedDepartmentStockOutDetail.Product.ProductMaster; var criteria = new ObjectCriteria(true); criteria.AddEqCriteria("pm.DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("stock.DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddLikeCriteria("pm.ProductName", "%" + searchPM.ProductName + "%"); criteria.MaxResult = 50; IList list = DepartmentStockLogic.FindByQueryForDeptStock(criteria); if(list ==null || list.Count == 0) { return; } IList result = new ArrayList(); foreach (DepartmentStock stock in list) { result.Add(stock.Product.ProductMaster); } IList retlist = RemoveDuplicateName(result); result = new ArrayList(); int count = 0; foreach (var p in retlist) { if (count == 50) { break; } result.Add(p); count++; } var productMasters = new BindingList<ProductMaster>(); foreach (ProductMaster master in result) { productMasters.Add(master); } var bindingSource = new BindingSource(); bindingSource.DataSource = productMasters; comboBox.DataSource = bindingSource; comboBox.DisplayMember = "TypeAndName"; comboBox.ValueMember = e.ComboBoxDisplayMember; comboBox.DropDownWidth = 300; comboBox.DropDownHeight = 200; // keep the original text comboBox.Text = originalText; comboBox.MaxDropDownItems = 10; } }
private void FillProductToComboBox(object sender, string name) { var mainStockInEventArgs = new DepartmentStockOutEventArgs(); if (dgvDeptStockIn == null || dgvDeptStockIn.CurrentRow == null) { return; } int selectedIndex = dgvDeptStockIn.CurrentRow.Index; mainStockInEventArgs.SelectedIndex = selectedIndex; mainStockInEventArgs.SelectedDepartmentStockOutDetail = deptSODetailList[selectedIndex]; mainStockInEventArgs.IsFillToComboBox = true; if (name.Equals("columnProductName")) { mainStockInEventArgs.ComboBoxDisplayMember = "ProductName"; } if (name.Equals("columnProductId")) { mainStockInEventArgs.ComboBoxDisplayMember = "ProductMasterId"; } EventUtility.fireEvent<DepartmentStockOutEventArgs>(FillProductToComboEvent, sender, mainStockInEventArgs); }
public void _departmentStockOutView_GetSyncDataEvent(object sender, DepartmentStockOutEventArgs e) { // first process all timeline DepartmentTimelineLogic.ProcessPeriod(e.IsConfirmPeriod); // then get data e.SyncFromDepartmentToMain = DepartmentStockOutLogic.GetSyncData(e.IsConfirmPeriod,e.LastSyncTime); }
private void ImportByFile_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = false; fileDialog.CheckFileExists = true; fileDialog.CheckPathExists = true; fileDialog.Filter = "Text Files|*.txt"; DialogResult result = fileDialog.ShowDialog(); if (result == DialogResult.OK) { Dictionary<string, int> list = new Dictionary<string, int>(); string path = fileDialog.FileName; StreamReader fileReader = new StreamReader(File.OpenRead(path)); while (!fileReader.EndOfStream) { string line = fileReader.ReadLine(); string[] parseLines = line.Split(','); try { if (parseLines.Length == 2) { if (list.ContainsKey(parseLines[0].Trim())) { list[parseLines[0].Trim()] += Int32.Parse(parseLines[1].Trim()); } else { list.Add(parseLines[0].Trim(), Int32.Parse(parseLines[1].Trim())); } } else { if (list.ContainsKey(parseLines[0].Trim())) { list[parseLines[0].Trim()] += 1; } else { list.Add(parseLines[0].Trim(), 1); } } } catch (Exception) { if (_errorForm == null) { _errorForm = new ErrorForm(); _errorForm.Caption = "Lỗi"; _errorForm.ErrorString = "Các mã vạch bị lỗi khi nhập mã vạch từ file text"; } _errorForm.ErrorDetails.Add(line); continue; } } foreach (KeyValuePair<string, int> barCodeLine in list) { if (!string.IsNullOrEmpty(barCodeLine.Key) && barCodeLine.Key.Length == 12) { var eventArgs = new DepartmentStockOutEventArgs(); eventArgs.ProductId = barCodeLine.Key; EventUtility.fireEvent(FindBarcodeEvent, this, eventArgs); if (eventArgs.EventResult == null) { if (_errorForm == null) { _errorForm = new ErrorForm(); //_errorForm.Caption = "Lỗi"; _errorForm.ErrorString = "Các mã vạch bị lỗi khi nhập mã vạch từ file text"; } _errorForm.ErrorDetails.Add(barCodeLine.Key + "," + barCodeLine.Value); continue; } bool found = false; DepartmentStockOutDetail foundStockOutDetail = null; foreach (DepartmentStockOutDetail detail in deptSODetailList) { if (eventArgs.SelectedDepartmentStockOutDetail.Product.ProductId.Equals(detail.Product.ProductId)) { found = true; foundStockOutDetail = detail; break; } } if (found) { foundStockOutDetail.GoodQuantity += barCodeLine.Value; bdsStockIn.ResetBindings(false); dgvDeptStockIn.Refresh(); dgvDeptStockIn.Invalidate(); CalculateTotalStorePrice(); } else { // reset quantity to 1 eventArgs.SelectedDepartmentStockOutDetail.GoodQuantity = barCodeLine.Value; deptSODetailList.Add(eventArgs.SelectedDepartmentStockOutDetail); bdsStockIn.ResetBindings(false); dgvDeptStockIn.Refresh(); dgvDeptStockIn.Invalidate(); cbbStockOutType.Enabled = false; LockField(deptSODetailList.Count - 1, eventArgs.SelectedDepartmentStockOutDetail); CalculateTotalStorePrice(); } // process department stock if (eventArgs.DepartmentStock != null) { found = false; foreach (DepartmentStock detail in departmentStockList) { if (eventArgs.DepartmentStock.DepartmentStockPK.ProductId.Equals(detail.Product.ProductId)) { found = true; break; } } if (!found) { departmentStockList.Add(eventArgs.DepartmentStock); } } } } CalculateTotalStorePrice(); if (_errorForm != null) { _errorForm.ShowDialog(); _errorForm = null; } } }
public void _departmentStockOutView_LoadGoodsByNameEvent(object sender, DepartmentStockOutEventArgs e) { DepartmentStockOutDetail detail = e.SelectedDepartmentStockOutDetail; ObjectCriteria objectCriteria = new ObjectCriteria(); objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); objectCriteria.AddEqCriteria("ProductName", detail.Product.ProductMaster.ProductName); IList list = ProductMasterLogic.FindAll(objectCriteria); e.FoundProductMasterList = list; if (list == null || list.Count == 0) { return; } ProductMaster prodMaster = list[0] as ProductMaster; detail.Product.ProductMaster = prodMaster; e.SelectedDepartmentStockOutDetail = detail; IList detailList = new ArrayList(); detailList.Add(detail); // GetRemainStockNumber(detailList); }
private void PopulateGridByProductMaster(IList colorList, IList sizeList) { IList selectedProductMasterList = new ArrayList(); foreach (ProductColor color in colorList) { foreach (ProductSize size in sizeList) { foreach (ProductMaster productMaster in productMasterList) { // do not allow duplicate bool goOut = false; foreach (ProductMaster detail in selectedProductMasterList) { if (productMaster.ProductMasterId.Equals(detail.ProductMasterId)) { goOut = true; break; } } if (goOut) { continue; } if (productMaster.ProductColor != null && productMaster.ProductColor.ColorId == color.ColorId && productMaster.ProductSize != null && productMaster.ProductSize.SizeId == size.SizeId) { selectedProductMasterList.Add(productMaster); } } } } var eventArgs = new DepartmentStockOutEventArgs(); eventArgs.SelectedProductMasterList = selectedProductMasterList; EventUtility.fireEvent(LoadStockStatusEvent, this, eventArgs); if (eventArgs.FoundDepartmentStockOutDetailList != null && eventArgs.FoundDepartmentStockOutDetailList.Count > 0) { foreach (DepartmentStockOutDetail detail in eventArgs.FoundDepartmentStockOutDetailList) { bool found = false; foreach (DepartmentStockOutDetail detail1 in deptSODetailList) { if (detail.Product.ProductId.Equals(detail1.Product.ProductId)) { found = true; break; } } if (found) { // MessageBox.Show("Mã vạch đã được nhập"); // return; continue; } // DefectStatusId = 4, DefectStatusName = "Xuất tạm để sửa hàng" }); // DefectStatusId = 6, DefectStatusName = "Xuất trả về kho chính" }); // DefectStatusId = 7, DefectStatusName = "Xuất đi cửa hàng khác" }); StockDefectStatus defectStatus = (StockDefectStatus)cbbStockOutType.SelectedItem; if (defectStatus.DefectStatusId == 4) { // if xuattam, so we check error quantity if (detail.ErrorQuantity == 0) // = 0 , so we don't need to show it { continue; } } if (defectStatus.DefectStatusId == 7) { // if xuatdicuahangkhac, so we check good quantity if (detail.GoodQuantity == 0) // = 0 , so we don't need to show it { continue; } } detail.DefectStatus = defectStatus; detail.GoodQuantity = 1; deptSODetailList.Add(detail); deptSODetailList.EndNew(deptSODetailList.Count - 1); LockField(deptSODetailList.Count - 1, detail); } foreach (DepartmentStock def in eventArgs.DepartmentStockList) { bool found = false; foreach (DepartmentStock detail in departmentStockList) { if (def.Product.ProductId.Equals(detail.Product.ProductId)) { found = true; break; } } if (!found) { departmentStockList.Add(def); } } CalculateTotalStorePrice(); } }
public void _departmentStockOutView_LoadStockStatusEvent(object sender, DepartmentStockOutEventArgs e) { IList productMasterIds = new ArrayList(); foreach (ProductMaster master in e.SelectedProductMasterList) { productMasterIds.Add(master.ProductMasterId); } var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); //criteria.AddSearchInCriteria("Product.ProductMaster.ProductMasterId", productMasterIds); //criteria.AddSubCriteria("Product", new SubObjectCriteria("ProductMaster").AddSearchInCriteria("ProductMasterId", productMasterIds)); IList list = DepartmentStockLogic.FindAllInProductMasterId(productMasterIds); if (list.Count == 0) { return; } e.DepartmentStockList = new ArrayList(); e.FoundDepartmentStockOutDetailList = new ArrayList(); foreach (DepartmentStock stock in list) { DepartmentStockOutDetail detail = new DepartmentStockOutDetail(); detail.Product = stock.Product; detail.GoodQuantity = stock.GoodQuantity; detail.ErrorQuantity = stock.ErrorQuantity; detail.LostQuantity = stock.LostQuantity; detail.DamageQuantity = stock.DamageQuantity; detail.UnconfirmQuantity = stock.UnconfirmQuantity; detail.Quantity = stock.Quantity; e.DepartmentStockList.Add(stock); e.FoundDepartmentStockOutDetailList.Add(detail); } }
private void txtBarcode_TextChanged(object sender, EventArgs e) { lblInformation.ForeColor = Color.Blue; lblInformation.Text = "Chờ lệnh ..."; if(!string.IsNullOrEmpty(txtBarcode.Text) && txtBarcode.Text.Length == 12) { var eventArgs = new DepartmentStockOutEventArgs(); eventArgs.ProductId = txtBarcode.Text; EventUtility.fireEvent(FindBarcodeEvent, this, eventArgs); if (eventArgs.EventResult == null) { MessageBox.Show("Không tìm thấy mã vạch này"); txtBarcode.Text = ""; return; } bool found = false; int i = 0; DepartmentStockOutDetail foundStockOutDetail = null; foreach (DepartmentStockOutDetail detail in deptSODetailList) { if (eventArgs.SelectedDepartmentStockOutDetail.Product.ProductId.Equals(detail.Product.ProductId)) { found = true; foundStockOutDetail = detail; break; } i += 1; } if (found) { foundStockOutDetail.GoodQuantity += 1; bdsStockIn.ResetBindings(false); dgvDeptStockIn.Refresh(); dgvDeptStockIn.Invalidate(); dgvDeptStockIn.CurrentCell = dgvDeptStockIn[7, i]; CalculateTotalStorePrice(); txtBarcode.Text = ""; txtBarcode.Focus(); return; } if (eventArgs.DepartmentStock != null) { found = false; foreach (DepartmentStock detail in departmentStockList) { if (eventArgs.DepartmentStock.Product.ProductId.Equals(detail.Product.ProductId)) { found = true; break; } } if (!found) { departmentStockList.Add(eventArgs.DepartmentStock); } } // TEMP FIX FOR SALE /*if(eventArgs.SelectedDepartmentStockOutDetail.Quantity > 0 ) {*/ eventArgs.SelectedDepartmentStockOutDetail.GoodQuantity = 1; /*} else { MessageBox.Show("Mặt hàng này trong kho đã hết. Xin vui lòng kiểm tra lại."); txtBarcode.Text = ""; return; }*/ deptSODetailList.Add(eventArgs.SelectedDepartmentStockOutDetail); deptSODetailList.EndNew(deptSODetailList.Count - 1); cbbStockOutType.Enabled = false; LockField(deptSODetailList.Count - 1, eventArgs.SelectedDepartmentStockOutDetail); CalculateTotalStorePrice(); dgvDeptStockIn.CurrentCell = dgvDeptStockIn[7, deptSODetailList.Count - 1]; txtBarcode.Text = ""; txtBarcode.Focus(); if(rdoFastStockOut.Checked) { return; // do fast stock out in here // first remove all blank row } } }
public void _departmentStockOutView_SyncToMainEvent(object sender, DepartmentStockOutEventArgs e) { DepartmentStockOutLogic.SyncToMain(e.SyncFromDepartmentToMain); ClientUtility.Log(logger, e.SyncFromDepartmentToMain.ToString(), "Đồng bộ về kho"); e.EventResult = "Success"; }
public void _departmentStockOutView_FindBarcodeEvent(object sender, DepartmentStockOutEventArgs e) { var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId); criteria.AddEqCriteria("DepartmentStockPK.ProductId", e.ProductId); IList list = DepartmentStockLogic.FindAll(criteria); if (list.Count == 0) { throw new BusinessException("Mã vạch này không có trong kho ?!?! Đề nghị kiểm tra lại."); return; } DepartmentStock stock = list[0] as DepartmentStock; e.SelectedDepartmentStockOutDetail = new DepartmentStockOutDetail(); e.SelectedDepartmentStockOutDetail.DepartmentStockOutDetailPK = new DepartmentStockOutDetailPK { DepartmentId = CurrentDepartment.Get().DepartmentId }; e.SelectedDepartmentStockOutDetail.Product = stock.Product; e.SelectedDepartmentStockOutDetail.Quantity = stock.Quantity; e.SelectedDepartmentStockOutDetail.GoodQuantity = stock.Quantity; e.SelectedDepartmentStockOutDetail.ErrorQuantity = stock.ErrorQuantity; e.SelectedDepartmentStockOutDetail.LostQuantity = stock.LostQuantity; e.SelectedDepartmentStockOutDetail.DamageQuantity = stock.DamageQuantity; e.SelectedDepartmentStockOutDetail.UnconfirmQuantity = stock.UnconfirmQuantity; e.DepartmentStock = stock; e.EventResult = "Success"; }