private void btnSave_Click(object sender, EventArgs e) { if (btnSave.Text == "Update") { var inventory = new Inventory(); inventory.LoadByPrimaryKey(Convert.ToInt32(_dr["ID"])); inventory.UnitID = Convert.ToInt32(lkUnit.EditValue); inventory.ManufacturerID = Convert.ToInt32(lkManufacturer.EditValue); inventory.ExpiryDate = Convert.ToDateTime(dtExpiryDate.EditValue); inventory.BatchNo = txtBatchNo.Text; inventory.InventorySoundQuantity = Convert.ToDecimal(txtSoundQty.EditValue); inventory.InventoryDamagedQuantity = Convert.ToDecimal(txtDamagedQty.EditValue); inventory.InventoryExpiredQuantity = Convert.ToDecimal(txtExpiredQty.EditValue); inventory.Save(); this.Close(); } else { if (dxValidationProvider1.Validate() && validateBatchandExpiryDate() && validateExpiryQuantity() && ValidateQuantity()) { var inventory = new Inventory(); inventory.AddNew(); inventory.InventoryPeriodID = _inventoryPeriodID; inventory.PhysicalStoreID = _physicalStoreID; inventory.ActivityID = _activityID; inventory.ItemID = Convert.ToInt32(lkItem.EditValue); inventory.UnitID = Convert.ToInt32(lkUnit.EditValue); inventory.ManufacturerID = Convert.ToInt32(lkManufacturer.EditValue); if (txtBatchNo.EditValue != null) { inventory.BatchNo = txtBatchNo.EditValue.ToString(); } if (dtExpiryDate.EditValue != null) { inventory.ExpiryDate = Convert.ToDateTime(dtExpiryDate.EditValue); } inventory.InventorySoundQuantity = Convert.ToDecimal(txtSoundQty.EditValue); inventory.InventoryDamagedQuantity = Convert.ToDecimal(txtDamagedQty.EditValue); inventory.InventoryExpiredQuantity = Convert.ToDecimal(txtExpiredQty.EditValue); inventory.RecordedDate = DateTimeHelper.ServerDateTime; inventory.RecordedBy = CurrentContext.UserId; inventory.IsDraft = true; inventory.Remarks = "New Entry"; inventory.Save(); if (Duplicate.CheckState == CheckState.Checked) { ClearValues(); } else { this.Close(); } } } }
public static void SaveInventoryRow(DataRow dataRow) { if (dataRow["ID"] != DBNull.Value) { Inventory inv = new Inventory(); inv.LoadByPrimaryKey(Convert.ToInt32(dataRow["ID"])); inv.SetColumn("InventoryDamagedQuantity", dataRow["InventoryDamagedQuantity"]); inv.SetColumn("InventorySoundQuantity", dataRow["InventorySoundQuantity"]); inv.SetColumn("InventoryExpiredQuantity", dataRow["InventoryExpiredQuantity"]); inv.SetColumn("Remarks", dataRow["Remarks"]); if (dataRow["PalletLocationID"] != DBNull.Value) { inv.PalletLocationID = Convert.ToInt32(dataRow["PalletLocationID"]); } if (dataRow["DamagedPalletLocationID"] != DBNull.Value) { inv.DamagedPalletLocationID = Convert.ToInt32(dataRow["DamagedPalletLocationID"]); } inv.IsDraft = true; inv.Save(); } else { Inventory inv = new Inventory(); inv.AddNew(); inv.InventoryPeriodID = Convert.ToInt32(dataRow["InventoryPeriodID"]); inv.PhysicalStoreID = Convert.ToInt32(dataRow["PhysicalStoreID"]); inv.ActivityID = Convert.ToInt32(dataRow["ActivityID"]); inv.ItemID = Convert.ToInt32(dataRow["ItemID"]); inv.UnitID = Convert.ToInt32(dataRow["UnitID"]); inv.ManufacturerID = Convert.ToInt32(dataRow["ManufacturerID"]); inv.SetColumn("BatchNo", dataRow["BatchNo"]); inv.SetColumn("ExpiryDate", dataRow["ExpiryDate"]); inv.SetColumn("InventoryDamagedQuantity", dataRow["InventoryDamagedQuantity"]); inv.SetColumn("InventorySoundQuantity", dataRow["InventorySoundQuantity"]); inv.SetColumn("InventoryExpiredQuantity", dataRow["InventoryExpiredQuantity"]); inv.RecordedDate = DateTimeHelper.ServerDateTime; inv.RecordedBy = CurrentContext.UserId; inv.IsDraft = true; inv.Remarks = "Stock out"; inv.Save(); } }
public static void CommitSingle(int inventoryId,DateTime ethiopianDate,int userId) { Inventory inventory = new Inventory(); inventory.LoadByPrimaryKey(inventoryId); if(!inventory.IsColumnNull("isDraft") && !inventory.IsDraft) { throw new Exception("This inventory has been commited already,you are not allow to commit again."); } try { var physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(inventory.PhysicalStoreID); inventory.InitializeCommit(userId,physicalStore.PhysicalStoreTypeID); inventory.Commit(ethiopianDate); inventory.FinishCommit(); } catch (Exception exp) { inventory.CancelCommit(exp); } }
public static void CommitSingle(int inventoryId, DateTime ethiopianDate, int userId) { Inventory inventory = new Inventory(); inventory.LoadByPrimaryKey(inventoryId); if (!inventory.IsColumnNull("isDraft") && !inventory.IsDraft) { throw new Exception("This inventory has been commited already,you are not allow to commit again."); } try { var physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(inventory.PhysicalStoreID); inventory.InitializeCommit(userId, physicalStore.PhysicalStoreTypeID); inventory.Commit(ethiopianDate); inventory.FinishCommit(); } catch (Exception exp) { inventory.CancelCommit(exp); } }