本文整理汇总了C#中Order.LoadByPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:C# Order.LoadByPrimaryKey方法的具体用法?C# Order.LoadByPrimaryKey怎么用?C# Order.LoadByPrimaryKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.LoadByPrimaryKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateOrder
public static Order GenerateOrder(int? orderID, int orderTypeID, int orderStatusID, int activityID, int paymentTypeID, string contactPerson, int? requestedBy, int userID, int? refNo = null)
{
var requisitionType = new RequisitionType();
int requisitionTypeID = Convert.ToInt32(requisitionType.LoadIDByCode("DMN")["RequisitionTypeID"]);
Order or = new Order();
if (orderID == null)
{
or.AddNew();
}
else
{
or.LoadByPrimaryKey(orderID.Value);
}
or.RefNo = refNo == null ? GetNextOrderReference() : refNo.ToString();
var oldOrderStatus = or.IsColumnNull("OrderStatusID") ? (int?)null : or.OrderStatusID;
or.OrderStatusID = orderStatusID;
// or.RequisitionTypeID = RequisitionType.CONSTANTS.DEMAND;
or.RequisitionTypeID = requisitionTypeID;
or.EurDate = or.Date = DateTimeHelper.ServerDateTime;
if (requestedBy != null)
{
or.RequestedBy = requestedBy.Value;
}
or.FilledBy = userID;
or.ContactPerson = contactPerson;
var activity = new Activity();
activity.LoadByPrimaryKey(activityID);
or.FromStore = activity.ModeID;
or.PaymentTypeID = paymentTypeID;
or.FiscalYearID = FiscalYear.Current.ID;
or.OrderTypeID = orderTypeID;
or.Save();
or.LogRequisitionStatus(or.ID, oldOrderStatus, orderStatusID, CurrentContext.UserId);
return or;
}
示例2: ComputeStockCalculationsForAnOrderDetail
/// <summary>
/// Computes the stock calculations for an order detail.
/// </summary>
/// <param name="currentMonth">The current month.</param>
/// <param name="currentYear">The current year.</param>
/// <param name="userID">The user ID.</param>
/// <param name="orderDetail">The order detail.</param>
/// <returns></returns>
public DataRow ComputeStockCalculationsForAnOrderDetail(int currentMonth, int currentYear, int userID, OrderDetail orderDetail)
{
if (!IsOrderDetailTableReady(orderDetail))
{
PrepareOrderDetailTable(orderDetail);
}
int? preferredManufacturer;
int? preferredPhysicalStoreID;
decimal usableStock;
decimal approved;
decimal availableQuantity;
Balance bal = new Balance();
ItemManufacturer imf = new ItemManufacturer();
int? unitid = null;
PriceSettings priceSettings = BLL.Settings.HandleDeliveryNotes ? PriceSettings.BOTH : PriceSettings.PRICED_ONLY;
BLL.Order parentOrder = new Order();
parentOrder.LoadByPrimaryKey(orderDetail.OrderID);
unitid = orderDetail.UnitID;
preferredManufacturer = orderDetail.IsColumnNull("PreferredManufacturerID") ? null : new int?(orderDetail.PreferredManufacturerID);
preferredPhysicalStoreID = orderDetail.IsColumnNull("PreferredPhysicalStoreID") ? null : new int?(orderDetail.PreferredPhysicalStoreID);
if (orderDetail.IsColumnNull("StoreID"))
{
orderDetail.StoreID = BLL.Activity.GetActivityUsingFEFO(this.FromStore, orderDetail.ItemID, orderDetail.UnitID);
orderDetail.Save();
}
Activity storeObject = new Activity();
availableQuantity = storeObject.LoadOptionsForOrderDetail(userID, orderDetail.ID, priceSettings, bal, false, out usableStock, out approved);
orderDetail.SetColumn("AvailableStores", storeObject.DefaultView);
if (storeObject.RowCount == 1)
{
orderDetail.StoreID = storeObject.ID;
// Avoid error if the column IsDeliveryNote doesn't exsit at all.
orderDetail.DeliveryNote = storeObject.DefaultView.Table.Columns.IndexOf("IsDeliveryNote") >= 0 &&
!storeObject.IsColumnNull("IsDeliveryNote") &&
Convert.ToBoolean(storeObject.GetColumn("IsDeliveryNote"));
availableQuantity = Convert.ToDecimal(storeObject.GetColumn("AvailableSKU"));
}
else if (storeObject.RowCount > 1)
{
//TOCLEAN: Lord have mercy.
//
// check if the default activity is selected
// if it has been selected, then do a good job and select it.
storeObject.Rewind();
while (
!storeObject.EOF
&&
(
(
storeObject.ID == orderDetail.StoreID
&& !orderDetail.IsColumnNull("DeliveryNote")
&& orderDetail.DeliveryNote
&& !Convert.ToBoolean(storeObject.GetColumn("IsDeliveryNote"))
)
||
storeObject.ID != orderDetail.StoreID
)
)
{
storeObject.MoveNext();
}
// the selected store is found, don't worry.
if (!storeObject.EOF)
{
availableQuantity = Convert.ToDecimal(storeObject.GetColumn("AvailableSKU"));
}
else
{
// the selected store is not found, please do select the first store.
storeObject.Rewind();
orderDetail.StoreID = storeObject.ID;
orderDetail.DeliveryNote = (storeObject.DefaultView.Table.Columns.IndexOf("IsDeliveryNote") >= 0 &&
!storeObject.IsColumnNull("IsDeliveryNote") &&
Convert.ToBoolean(storeObject.GetColumn("IsDeliveryNote")));
availableQuantity = Convert.ToDecimal(storeObject.GetColumn("AvailableSKU"));
}
}
orderDetail.SetColumn("HasStores", (storeObject.RowCount > 1) ? "*" : "");
// Precaution ... to hide -ve available quantity.
if (availableQuantity < 0)
{
availableQuantity = 0;
//.........这里部分代码省略.........
示例3: IsItAnOnlineOrder
public static bool IsItAnOnlineOrder(int orderID)
{
var order = new Order();
order.LoadByPrimaryKey(orderID);
order.Query.Load();
return order.RowCount > 0;
}
示例4: ReorganizeDataViewForSTVPrint_Program
/// <summary>
/// Reorganizes the data view for STV print_ program.
/// </summary>
/// <param name="dv">The dv.</param>
/// <param name="refNo">The ref no.</param>
/// <param name="pickListId">The pick list id.</param>
/// <param name="userID">The user ID.</param>
/// <param name="stvLogID">The STV log ID.</param>
/// <param name="convertDNtoSTV">if set to <c>true</c> [convert D nto STV].</param>
/// <param name="generateNewPrintID">if set to <c>true</c> [generate new print ID].</param>
/// <param name="hasInsurance">if set to <c>true</c> [has insurance].</param>
/// <returns></returns>
public static DataTable ReorganizeDataViewForSTVPrint_Program(DataView dv, int orderID, int pickListId, int userID, int? stvLogID, bool convertDNtoSTV, bool generateNewPrintID, bool hasInsurance)
{
BLL.Order order = new Order();
order.LoadByPrimaryKey(orderID);
int? paymentTypeID = null;
if (order.PaymentTypeID == PaymentType.Constants.CASH || order.PaymentTypeID == PaymentType.Constants.CREDIT || order.PaymentTypeID == PaymentType.Constants.STV)
{
paymentTypeID = order.PaymentTypeID;
}
// This is just to make the delivery notes print a separate series of numbers.
// This section completely asks for a re-write.
if (dv.Count > 0 && (dv[0]["Cost"] == DBNull.Value || Convert.ToDecimal(dv[0]["Cost"]) == 0M))
{
paymentTypeID = PaymentType.Constants.DELIVERY_NOTE;
}
else if (stvLogID != null)
{
Issue issue = new Issue();
issue.LoadByPrimaryKey(stvLogID.Value);
if (!issue.IsColumnNull("IsDeliveryNote") && issue.IsDeliveryNote && !convertDNtoSTV)
{
paymentTypeID = PaymentType.Constants.DELIVERY_NOTE;
}
}
// prepare the pick list for printing.
// this method only merges the items that come in different rows but ...
// that have same price same item.
DataTable dtbl = dv.Table.Clone();
if (!dtbl.Columns.Contains("Supplier"))
{
dtbl.Columns.Add("Supplier");
}
if (!dtbl.Columns.Contains("SupplierID"))
{
dtbl.Columns.Add("SupplierID");
}
dtbl.Columns.Add("STVNumber");
dtbl.Columns.Add("StoreName");
dtbl.Columns.Add("ContactPerson");
dtbl.Columns.Add("PhysicalStoreType"); //The virtual store (The grouping for the stores) for the display on the stv
dtbl.Clear();
foreach (DataRowView drv in dv)
{
if (dtbl.Rows.Count == 0)
{
dtbl.ImportRow(drv.Row);
}
else
{
//check if items with same expiry exists in the table
//TOFIX: Add the supplier in this mix
string qItemID = "", qbatchNumberID = "", qUnitPriceID = "", qPhysicalStoreName = "", qStoreID = "";
qItemID = string.Format("ItemID={0} and UnitID={1}", drv["ItemID"].ToString(), drv["UnitID"]);
if (drv["BatchNumber"] != DBNull.Value)
qbatchNumberID = string.Format(" and BatchNumber='{0}'", drv["BatchNumber"].ToString());
if (drv["UnitPrice"] != DBNull.Value)
qUnitPriceID = string.Format(" and UnitPrice = {0} ", drv["UnitPrice"].ToString());
if (drv["PhysicalStoreName"] != DBNull.Value)
qPhysicalStoreName = string.Format(" and PhysicalStoreName= '{0}'",
drv["PhysicalStoreName"].ToString());
if (drv["StoreID"] != DBNull.Value)
qStoreID = string.Format(" and StoreID= '{0}'", drv["StoreID"].ToString());
string query = string.Format("{0}{1}{2}{3}{4}", qItemID, qbatchNumberID, qUnitPriceID,
qPhysicalStoreName, qStoreID);
DataRow[] ar = dtbl.Select(query);
if (ar.Length > 0)
{
//
foreach (var dataRow in ar)
{
dataRow["SKUPICKED"] = Convert.ToInt32(dataRow["SKUPICKED"]) +
Convert.ToInt32(drv["SKUPICKED"]);
dataRow["Cost"] = (dataRow["Cost"] != DBNull.Value ? Convert.ToDouble(dataRow["Cost"]) : 0) +
(drv["Cost"] != DBNull.Value ? Convert.ToDouble(drv["Cost"]) : 0);
dataRow["IssueDocID"] = dataRow["IssueDocID"].ToString() + ',' +
drv["IssueDocID"].ToString();
//.........这里部分代码省略.........
示例5: GetInsuranceValue
/// <summary>
/// Gets the insurance value.
/// </summary>
/// <param name="orderID">The order ID.</param>
/// <param name="TotalValue">The total value.</param>
/// <returns></returns>
public static double GetInsuranceValue(int orderID, double TotalValue)
{
BLL.Order order = new Order();
order.LoadByPrimaryKey(orderID);
if (order.FromStore == Mode.Constants.HEALTH_PROGRAM)
return 0;
double STVvalue = TotalValue;
string insuranceformula = BLL.Settings.InsuranceFormula;
string Formula = String.Format(insuranceformula, STVvalue);
System.Data.DataTable dt = new System.Data.DataTable();
double Insurance = Convert.ToDouble(dt.Compute(Formula, ""));
return Insurance;
}
示例6: GetPalletLocationChoice
/// <summary>
/// Generate the pick list
/// </summary>
/// <param name="orderId">The order id.</param>
/// <param name="bgWorker">The bg worker.</param>
/// <returns></returns>
public DataView GetPalletLocationChoice(int userID, int orderId, BackgroundWorker bgWorker)
{
var order = new Order();
// Load the order
order.LoadByPrimaryKey(orderId);
//TODO: check if the order is already approved or not.
// if not please return from here
// Load the order details
var orderDetail = new OrderDetail();
orderDetail.LoadAllByOrderID(orderId);
orderDetail.AddColumn("ActivityConcat", typeof(string));
// prepare the pick list data table with the proper fields
_pickList = GetPickListTable();
_replenishmentList = new DataTable();
_replenishmentList.Columns.Add("ItemID", typeof(int));
_replenishmentList.Columns.Add("StoreID", typeof(int));
int count = 0;
// iterate through the order detail and make the pick list
while (!orderDetail.EOF)
{
DateTime startTime = DateTime.Now;
System.Console.WriteLine("Processing - " + orderDetail.ItemID);
// check if there are enough priced items of the same or more quantity in the store
int? unitID = null;
if (!orderDetail.IsColumnNull("UnitID"))
{
unitID = orderDetail.UnitID;
}
if (!orderDetail.IsColumnNull("StockedOut") && (!orderDetail.StockedOut ||(orderDetail.ApprovedQuantity > 0 && orderDetail.Quantity > orderDetail.ApprovedQuantity)))
{
DateTime? preferredExpiry = new DateTime();
if (orderDetail.IsColumnNull("PreferredManufacturerID"))
orderDetail.PreferredManufacturerID = -1;
if (orderDetail.IsColumnNull("PreferredPhysicalStoreID"))
orderDetail.PreferredPhysicalStoreID = -1;
if (orderDetail.IsColumnNull("PreferredExpiryDate"))
preferredExpiry = null;
else
{
preferredExpiry = orderDetail.PreferredExpiryDate;
}
if (!orderDetail.IsColumnNull("ApprovedQuantity") && (orderDetail.ApprovedQuantity > 0 && !orderDetail.IsColumnNull("StoreID")))
{
AddToPickListFor(userID, orderDetail.ID, orderDetail.ItemID, unitID, orderDetail.ApprovedQuantity, orderDetail.StoreID,
orderDetail.PreferredManufacturerID, orderDetail.PreferredPhysicalStoreID,
!orderDetail.IsColumnNull("DeliveryNote") && orderDetail.DeliveryNote,
preferredExpiry);
}
}
System.Console.WriteLine(string.Format("Took - {0}:{1} for Item ID = {2}", DateTime.Now.Subtract(startTime).Minutes, DateTime.Now.Subtract(startTime).Seconds, orderDetail.ItemID));
orderDetail.MoveNext();
count++;
bgWorker.ReportProgress(count, null);
}
// A quick hack just to show the pallet location on the order form
var pl = new PalletLocation();
var im = new ItemManufacturer();
foreach (DataRowView drv in _pickList.DefaultView)
{
int plid = Convert.ToInt32(drv["PalletLocationID"]);
pl.LoadByPrimaryKey(plid);
drv["PalletLocation"] = pl.FullName;
im.LoadIMbyLevel(Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]),
Convert.ToInt32(drv["BoxLevel"]));
drv["QtyInSKU"] = im.RowCount > 0
? Convert.ToDecimal(drv["Pack"]) * im.QuantityInSku
: Convert.ToDecimal(drv["Pack"]);
drv["BoxSizeDisplay"] = im.RowCount > 0 ? im.LevelView2 : ""; //im.RightName;
drv["WarehouseName"] = pl.WarehouseName;
drv["PhysicalStoreName"] = pl.PhysicalStoreName;
var activity = new Activity();
activity.LoadByPrimaryKey(Convert.ToInt32(drv["StoreID"]));
drv["ActivityConcat"] = activity.FullActivityName;
drv["AccountName"] = activity.AccountName;
}
//foreach (DataRowView v in _pickList.DefaultView)
//{
//}
return _pickList.DefaultView;
}
示例7: SavePickList
/// <summary>
/// Saves issue order details
/// </summary>
/// <param name="orderID"></param>
/// <param name="dvPickListMakeup"></param>
public void SavePickList(int orderID, DataView dvPickListMakeup, int userID)
{
//~ Check if This Order has a previous Printed Picklist with detail: Note a header only doesnt affect us! //
var pickList = new PickList();
pickList.LoadByOrderID(orderID);
if(pickList.RowCount>0)
{
var pldetail = new PickListDetail();
pldetail.LoadByPickListID(pickList.ID);
if (pldetail.RowCount > 0)
{
RemoveFakePartialCommitPickListDetails(orderID);
var pickL = new PickList();
pickL.LoadByOrderID(orderID);
if (pickL.RowCount > 0)
{
throw new Exception("Picklist has already been printed for this Order ");
// This error has been apprearing for the last one year so funny! I hope it won't come again! day: 10/21/2014 @yido //
}
}
}
// Create a pick list entry
Order ord = new Order();
ord.LoadByPrimaryKey(orderID);
PickList pl = new PickList();
PalletLocation plocation = new PalletLocation();
plocation.LoadByPrimaryKey(Convert.ToInt32(dvPickListMakeup[0]["PalletLocationID"]));
pl.AddNew();
pl.OrderID = orderID;
pl.PickType = "Pick";
pl.PickedBy = userID;
pl.IsConfirmed = false;
pl.IssuedDate = DateTimeHelper.ServerDateTime;
pl.SavedDate = DateTimeHelper.ServerDateTime;
pl.PickedDate = DateTimeHelper.ServerDateTime;
pl.IsWarehouseConfirmed = 0;
pl.WarehouseID = plocation.WarehouseID;
pl.Save();
PickListDetail pld = new PickListDetail();
ReceivePallet rp = new ReceivePallet();
ReceiveDoc rd = new ReceiveDoc();
PickFace pf = new PickFace();
foreach (DataRowView drv in dvPickListMakeup)
{
pld.AddNew();
pld.PickListID = pl.ID;
pld.OrderDetailID = Convert.ToInt32(drv["OrderDetailID"]);
pld.ItemID = Convert.ToInt32(drv["ItemID"]);
pld.BatchNumber = (drv["BatchNo"].ToString());
if (drv["ExpDate"] != DBNull.Value)
{
pld.ExpireDate = Convert.ToDateTime(drv["ExpDate"]);
}
pld.ManufacturerID = Convert.ToInt32(drv["ManufacturerID"]);
pld.BoxLevel = Convert.ToInt32(drv["BoxLevel"]);
pld.QtyPerPack = Convert.ToInt32(drv["QtyPerPack"]);
pld.Packs = Convert.ToDecimal(drv["Pack"]);
pld.PalletLocationID = Convert.ToInt32(drv["PalletLocationID"]);
pld.QuantityInBU = Convert.ToDecimal(drv["QtyInBU"]);
pld.ReceiveDocID = Convert.ToInt32(drv["ReceiveDocID"]);
pld.ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]);
if (drv["CalculatedCost"] != DBNull.Value)
pld.Cost = Convert.ToDouble(drv["CalculatedCost"]);
if (drv["UnitPrice"] != DBNull.Value)
pld.UnitPrice = Convert.ToDouble(drv["UnitPrice"]);
int ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]);
rp.LoadByPrimaryKey(ReceivePalletID);
pld.StoreID = Convert.ToInt32(drv["StoreID"]);
if (drv["DeliveryNote"] != null)
pld.DeliveryNote = Convert.ToBoolean(drv["DeliveryNote"]);
else
pld.DeliveryNote = false;
if (rp.IsColumnNull("ReservedStock"))
{
rp.ReservedStock = Convert.ToDecimal(pld.QuantityInBU);
}
else
{
rp.ReservedStock += Convert.ToDecimal(pld.QuantityInBU);
}
if (drv["UnitID"] != DBNull.Value)
{
pld.UnitID = Convert.ToInt32(drv["UnitID"]);
}
plocation.LoadByPrimaryKey(Convert.ToInt32(drv["PalletLocationID"]));
pld.PhysicalStoreID = plocation.PhysicalStoreID;
rp.Save();
//.........这里部分代码省略.........
示例8: RemoveFakePartialCommitPickListDetails
/// <summary>
/// This happes when there is plenty of transaction at the same time
/// and will result a partial commit.
/// This fake rows should be deleted from DB.
/// </summary>
/// <param name="orderID"></param>
private void RemoveFakePartialCommitPickListDetails(int orderID)
{
var order = new Order();
order.LoadByPrimaryKey(orderID);
if (order.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED)
{
var pickList = new PickList();
pickList.LoadByOrderID(order.ID);
if (pickList.RowCount == 0) //~ If there is no picklist, there is nothing to delete. ~//
return;
var picklistDetail = new PickListDetail();
picklistDetail.LoadByPickListID(pickList.ID);
picklistDetail.Rewind();
while (!picklistDetail.EOF)
{
PickListDetailDeleted.AddNewLog(picklistDetail, CurrentContext.UserId);
picklistDetail.MarkAsDeleted();
picklistDetail.MoveNext();
}
picklistDetail.Save();
pickList.MarkAsDeleted();
pickList.Save();
}
}
示例9: CommitAccountToAccountTransfer
/// <summary>
/// Commits the account to account transfer.
/// </summary>
/// <param name="orderID">The order ID.</param>
/// <param name="userID">The user ID.</param>
/// <param name="convertedEthDate">The converted eth date.</param>
public void CommitAccountToAccountTransfer(int orderID, int userID, DateTime convertedEthDate)
{
int? supplierID = null;
BLL.Transfer transfer = new Transfer();
transfer.LoadByOrderID(orderID);
if (transfer.RowCount == 0)
return;
int newStoreID, newPhysicalStoreID;
newStoreID = transfer.ToStoreID;
newPhysicalStoreID = transfer.ToPhysicalStoreID;
PhysicalStore toPhysicalStore = new PhysicalStore();
toPhysicalStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID);
BLL.PickList picklist = new PickList();
picklist.LoadByOrderID(orderID);
BLL.PickListDetail pld = new PickListDetail();
pld.LoadByPickListIDWithStvlogID(picklist.ID);
BLL.ReceiveDoc rdOriginal = new ReceiveDoc();
rdOriginal.LoadByPrimaryKey(pld.ReceiveDocID);
BLL.Order order=new Order();
order.LoadByPrimaryKey(orderID);
if(order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
{
var activity = new Activity();
activity.LoadByPrimaryKey(newStoreID);
supplierID = activity.SupplierID;
}
else if(order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)
{
var activity = new Activity();
activity.LoadByPrimaryKey(newPhysicalStoreID);
supplierID = activity.SupplierID;
}
PO po = PO.CreatePOforStandard( (int) order.GetColumn("OrderTypeID"),transfer.ToStoreID,supplierID,"Transfer",CurrentContext.LoggedInUser.ID);
int IDPrinted = Convert.ToInt32(pld.GetColumn("IDPrinted"));
int receiptTypeID = order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER
? ReceiptType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER
:order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER
? ReceiptType.CONSTANTS.STORE_TO_STORE_TRANSFER
: order.OrderTypeID == OrderType.CONSTANTS.ERROR_CORRECTION_TRANSFER
? ReceiptType.CONSTANTS.ERROR_CORRECTION:ReceiptType.CONSTANTS.STANDARD_RECEIPT;
Receipt receipt = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID,po.ID,toPhysicalStore.PhysicalStoreTypeID,IDPrinted,userID);
var mergedPickLists = MergePickListsOfSameInfo(pld); // Picklists of the same info means: Based on all constraints we have on receiveDoc(Batch,Exp,ItemID,UnitID...): should be merged with summed quantity.
pld.Rewind();
while (!pld.EOF)
{
if(IDPrinted != Convert.ToInt32(pld.GetColumn("IDPrinted")))
{
IDPrinted = Convert.ToInt32(pld.GetColumn("IDPrinted"));
receipt = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID,po.ID, toPhysicalStore.PhysicalStoreTypeID, IDPrinted, userID);
}
var rDoc = new ReceiveDoc();
if (!mergedPickLists.ContainsKey(pld.ID))
{
pld.MoveNext();
continue;
}
rDoc.SaveNewReceiveDocEntryFromPicklistDetail(pld, userID, newStoreID, newPhysicalStoreID,
convertedEthDate,receipt.ID,supplierID);
pld.MoveNext();
}
}
示例10: CancelOrderWithPickList
/// <summary>
/// Undo pick list that has been printed
/// </summary>
/// <param name="orderID">The order ID.</param>
public void CancelOrderWithPickList(int orderID)
{
// Create a pick list entry
Order ord = new Order();
PickList pl = new PickList();
PickListDetail pld = new PickListDetail();
ReceivePallet rp = new ReceivePallet();
ReceiveDoc rd = new ReceiveDoc();
PickFace pf = new PickFace();
PalletLocation palletLocation = new PalletLocation();
ord.LoadByPrimaryKey(orderID);
pl.LoadByOrderID(orderID);
pld.LoadByPickListID(pl.ID);
while (!pld.EOF)
{
rp.LoadByPrimaryKey(pld.ReceivePalletID);
rp.ReservedStock -= Convert.ToInt32(pld.QuantityInBU);
if (rp.ReservedStock < 0)
rp.ReservedStock = 0; //If there has been no reservation, allow to cancel the picklist too. No need for it to be blocked by the constraint.
rp.Save();
palletLocation.LoadByPrimaryKey(pld.PalletLocationID);
if (palletLocation.StorageTypeID.ToString() == StorageType.PickFace)
{
pf.LoadByPalletLocation(pld.PalletLocationID);
pf.Balance += Convert.ToInt32(pld.QuantityInBU);
pf.Save();
}
//Delete from picklistDetail and add to pickListDetailDeleted
PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId);
pld.MarkAsDeleted();
pld.MoveNext();
}
pld.Save();
ord.ChangeStatus(OrderStatus.Constant.CANCELED,CurrentContext.UserId);
pl.MarkAsDeleted();
pl.Save();
}
示例11: LoadOptionsForOrderDetail
/// <summary>
/// The code supports manufacturer preference here too but we choose not to prefer manufacturers when looking into the stores.
/// </summary>
/// <param name="userID"></param>
/// <param name="orderDetailID"></param>
/// <param name="pricedUnpricedBoth"></param>
/// <param name="bal"> </param>
/// <param name="markStockoutBit"> </param>
/// <param name="usableStock"> </param>
/// <param name="approved"> </param>
public decimal LoadOptionsForOrderDetail(int userID, int orderDetailID, PriceSettings pricedUnpricedBoth, Balance bal, bool markStockoutBit, out decimal usableStock, out decimal approved)
{
decimal avQuantity = 0;
BLL.OrderDetail orderDetail = new OrderDetail();
orderDetail.LoadByPrimaryKey(orderDetailID);
BLL.Order order = new Order();
order.LoadByPrimaryKey(orderDetail.OrderID);
Institution ru = new Institution();
ru.LoadByPrimaryKey(order.RequestedBy);
int month = EthiopianDate.EthiopianDate.Now.Month;
int year = EthiopianDate.EthiopianDate.Now.Year;
decimal availableQty = 0;
usableStock = 0;
approved = 0;
int? manufacturerPrefrence = null, unitID = null;
if (!orderDetail.IsColumnNull("PreferredManufacturerID"))
{
manufacturerPrefrence = orderDetail.PreferredManufacturerID;
}
DateTime? expPreferrence = null;
if(!orderDetail.IsColumnNull("PreferredExpiryDate"))
{
expPreferrence = orderDetail.PreferredExpiryDate;
}
int? preferredPhysicalStoreID = null;
if (!orderDetail.IsColumnNull("PreferredPhysicalStoreID"))
{
preferredPhysicalStoreID = orderDetail.PreferredPhysicalStoreID;
}
//--------------------------------------------------------------------------
//manufacturerPrefrence = null; //We are overriding the manufacturer preference.
//expPreferrence = null;
//--------------------------------------------------------------------------
if (!orderDetail.IsColumnNull("UnitID"))
{
unitID = orderDetail.UnitID;
}
BLL.UserActivity userStore = new UserActivity();
// Definitely a danger zone
userStore.LoadByUserIDAndStoreType(userID, order.FromStore, orderDetail.ItemID, unitID.Value);
while (!userStore.EOF)
{
var activity = new Activity();
activity.LoadByPrimaryKey(userStore.ActivityID);
if(order.FromStore == Mode.Constants.RDF && !BLL.Settings.IsCenter && !BLL.Settings.PrivateCanGetFromMDGAndPBS && ru.Ownership == OwnershipType.Constants.Private && activity.IsSubsidized ){
userStore.MoveNext();
continue;
}
// Load the Activity Selection that has PRiced Commodities.
Balance balance = new Balance();
if (pricedUnpricedBoth == PriceSettings.PRICED_ONLY || pricedUnpricedBoth == PriceSettings.BOTH)
{
BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.PRICED_ONLY, orderDetail,
userStore.ActivityID, orderDetail.ItemID, order, balance, unitID,
manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved,
out availableQty, markStockoutBit);
avQuantity += availableQty;
if (availableQty > 0)
{
this.AddNew();
this.ID = userStore.ActivityID;
this.Name = string.Format("{0} ({1})", activity.FullActivityName, availableQty.ToString("#,##0"));
PrepareColumnsForApproval();
this.SetColumn("AvailableSKU", availableQty);
this.SetColumn("IsDeliveryNote", false);
this.SetColumn("TextID",string.Format("N{0}",this.ID));
}
}
// Load Activity Selections for Delivery Note Items.
if (pricedUnpricedBoth == PriceSettings.DELIVERY_NOTE_ONLY || pricedUnpricedBoth == PriceSettings.BOTH)
{
BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.DELIVERY_NOTE_ONLY, orderDetail,
userStore.ActivityID, orderDetail.ItemID, order, balance, unitID,
manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved,
out availableQty, markStockoutBit);
//.........这里部分代码省略.........
示例12: gridViewReferences_FocusedRowChanged
/// <summary>
/// Handles the FocusedRowChanged event of the gridViewReferences control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs" /> instance containing the event data.</param>
private void gridViewReferences_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
if (e != null && e.PrevFocusedRowHandle < -1)
return;
dtDate.Value = DateTimeHelper.ServerDateTime;
_reprintId = null;
DataRow dr = gridViewReferences.GetFocusedDataRow();
if (dr == null)
{
return;
}
string[] referenceNo = new string[2];
referenceNo[0] = dr["RefNo"].ToString();
if (Convert.ToBoolean(dr["isConvertedDN"]))
{
_isConvertedDn = true;
_stvLogIdChosen = (int?)dr["IsReprintOf"];
}
else if (dr != null && dr["ID"] != DBNull.Value)
{
_isConvertedDn = false;
_stvLogIdChosen = (int?)dr["ID"];
}
UpdateReprintedNumbers(dr);
// Enable and disable STV reprint
// STV SHouldn't be reprinted off a reprint.
if (dr["IsReprintOf"] != DBNull.Value && !Convert.ToBoolean(dr["isConvertedDN"]))
{
btnExport.Enabled = btnReprint.Enabled = false;
var permission = (BLL.Settings.UseNewUserManagement) ? this.HasPermission("Print") : true;
btnPrint.Enabled = permission;
_reprintId = _stvLogIdChosen;
_stvLogIdChosen = Convert.ToInt32(dr["IsReprintOf"]);
}
else if (dr["IsDeliveryNote"] != DBNull.Value && Convert.ToBoolean(dr["IsDeliveryNote"]))
{
btnExport.Enabled = false;
btnReprint.Enabled = (BLL.Settings.UseNewUserManagement) ? this.HasPermission("Re-Print") : true;
btnPrint.Enabled = false;
}
else
{
btnPrint.Enabled = this.HasPermission("Print");
btnReprint.Enabled = this.HasPermission("Re-Print");
btnExport.Enabled = this.HasPermission("Export");
}
if (_stvLogIdChosen != null)
{
Issue log = new Issue();
log.LoadByPrimaryKey(_stvLogIdChosen.Value);
Institution rus = new Institution();
IssueDoc iss = new IssueDoc();
if (!log.IsColumnNull("ReceivingUnitID"))
{
rus.LoadByPrimaryKey(log.ReceivingUnitID);
//FacilityName.Text = rus.Name;
HeaderSection.Text = rus.Name;
var activity = new Activity();
activity.LoadByPrimaryKey(log.StoreID);
lblActivity.Text = activity.Name;
lblSubAccount.Text = activity.SubAccountName;
lblMode.Text = activity.ModeName;
lblAccount.Text = activity.AccountName;
lblRegion.Text = rus.RegionName;
lblWoreda.Text = rus.WoredaName;
lblZone.Text = rus.ZoneName;
lblInstType.Text = rus.InstitutionTypeName;
var ownership = new OwnershipType();
ownership.LoadByPrimaryKey(rus.Ownership);
lblOwnership.Text = ownership.Name;
lblVoidConDate.Text = (dr["approvalDate"]) != DBNull.Value ? Convert.ToDateTime(dr["approvalDate"]).ToShortDateString(): "-";
lblIssueType.Text = (string)dr["OrderType"];
User user = new User();
if (dr["approvedBy"] != DBNull.Value)
{
user.LoadByPrimaryKey(Convert.ToInt32(dr["approvedBy"]));
lblConfirmedBy.Text = user.FullName;
}
else
{
lblConfirmedBy.Text = "-";
}
//.........这里部分代码省略.........
示例13: RePrintSTV
/// <summary>
/// Re print STV.
/// </summary>
/// <param name="dv">The dv.</param>
/// <param name="orderId">The order id.</param>
/// <param name="pl">The pl.</param>
/// <param name="stvLogID">The STV log ID.</param>
/// <param name="isConversion">if set to <c>true</c> [is conversion].</param>
/// <param name="generateNewPrintID">if set to <c>true</c> [generate new print ID].</param>
//public XtraReport RePrintSTV(DataView dv,int orderId, PickList pl,int? stvLogID, bool isConversion, bool generateNewPrintID = true)
//{
// var includeInsurance =XtraMessageBox.Show("Include insurance?", "Insurance",MessageBoxButtons.YesNo,MessageBoxIcon.Question)== DialogResult.Yes;
// var ord = new Order();
// ord.LoadByPrimaryKey(orderId);
// var order = new Order();
// order.LoadByPrimaryKey(orderId);
// if (!order.IsPaymentTypeValid())
// {
// //TODO: This needs to be handled well.
// throw new Exception(
// string.Format("PaymentTypeID has a problem. The order has a payment type id of {0}",
// ord.PaymentTypeID));
// }
// var stores = new Activity();
// stores.LoadByPrimaryKey(order.FromStore);
// var textDeliveryNote = "";
// var sendToString = GetReceivingUnitName(order);
// if (stvLogID != null)
// {
// var stvLog = new Issue();
// stvLog.LoadByPrimaryKey(stvLogID.Value);
// if (!stvLog.IsColumnNull("IsDeliveryNote") && stvLog.IsDeliveryNote && isConversion)
// {
// textDeliveryNote = stvLog.IDPrinted.ToString("00000");
// }
// }
// if (PaymentType.Constants.CASH == ord.PaymentTypeID)
// {
// var rus = new Institution();
// rus.LoadByPrimaryKey(order.RequestedBy);
// var stvReport = new HCMIS.Desktop.Reports.CashInvoice(CurrentContext.LoggedInUserName);
// pl.LoadByOrderID(orderId);
// PrepareTheReport(stvReport);
// stvReport.DeliveryNoteNo.Text = textDeliveryNote;
// stvReport.DataSource = Order.ReorganizeDataViewForSTVPrint_Program(dv, ord.ID, pl.ID, CurrentContext.UserId, stvLogID, isConversion, generateNewPrintID, includeInsurance);
// stvReport.From.Text = GeneralInfo.Current.HospitalName;
// stvReport.To.Text = sendToString;
// stvReport.TIN.Text = rus.TinNo;
// stvReport.VAT.Text = rus.VATNo;
// stvReport.Town.Text = rus.Town;
// stvReport.Woreda.Text = rus.WoredaText;
// stvReport.Zone.Text = rus.ZoneText;
// stvReport.Region.Text = rus.Region;
// stvReport.License.Text = (!rus.IsColumnNull("Ownership") && rus.IsPrivatelyOwned) ? rus.LicenseNo : (!ord.IsColumnNull("LetterNo")) ? ord.LetterNo : "";
// //stvReport.Program.Text = stores.StoreName;
// DateTimePickerEx dtDate = new DateTimePickerEx();
// dtDate.Value = DateTimeHelper.ServerDateTime;
// stvReport.Date.Text = dtDate.Text;
// return stvReport;
// }
// else if (PaymentType.Constants.CREDIT == ord.PaymentTypeID)
// {
// var rus = new Institution();
// rus.LoadByPrimaryKey(order.RequestedBy);
// HCMIS.Desktop.Reports.CreditInvoice stvReport =
// new HCMIS.Desktop.Reports.CreditInvoice(CurrentContext.LoggedInUserName);
// pl.LoadByOrderID(orderId);
// PrepareTheReport(stvReport);
// stvReport.DeliveryNoteNo.Text = textDeliveryNote;
// stvReport.DataSource = Order.ReorganizeDataViewForSTVPrint_Program(dv, ord.ID, pl.ID,
// CurrentContext.UserId, stvLogID, isConversion, generateNewPrintID, includeInsurance);
// stvReport.From.Text = GeneralInfo.Current.HospitalName;
// stvReport.To.Text = sendToString;
// //stvReport.Region.Text = rus.Woreda;
// stvReport.Zone.Text = rus.Town;
// stvReport.Letter.Text = ord.LetterNo;
// //stvReport.Program.Text = stores.StoreName;
// DateTimePickerEx dtDate = new DateTimePickerEx();
// dtDate.Value = DateTimeHelper.ServerDateTime;
// stvReport.Date.Text = dtDate.Text;
// }
//}
/// <summary>
/// Re print STV.
/// </summary>
/// <param name="dv">The dv.</param>
/// <param name="orderId">The order id.</param>
/// <param name="pl">The pl.</param>
/// <param name="stvLogID">The STV log ID.</param>
/// <param name="isConversion">if set to <c>true</c> [is conversion].</param>
/// <param name="generateNewPrintID">if set to <c>true</c> [generate new print ID].</param>
public XtraReport RePrintSTV(DataView dv, int orderId, PickList pl, int? stvLogID, bool isConversion, bool generateNewPrintID = true)
{
HCMIS.Core.Distribution.Services.PrintLogService pLogService = new HCMIS.Core.Distribution.Services.PrintLogService();
pLogService.StartPrintingSession();
includeInsurance = XtraMessageBox.Show("Include insurance?", "Insurance", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
var ord = new Order();
ord.LoadByPrimaryKey(orderId);
//.........这里部分代码省略.........
示例14: MarkAsDispatched
/// <summary>
/// Marks as dispatched.
/// </summary>
/// <param name="userID">The user ID.</param>
/// <param name="prePrintedSTV">The pre printed STV.</param>
/// <returns></returns>
public bool MarkAsDispatched(int userID, int? prePrintedSTV)
{
if (!this.IsColumnNull("VoidRequest"))
{
if ((this.VoidRequest && this.IsColumnNull("VoidApprovedByUserID"))) //If the approver hasn't acted on the void request.
{
return false;
}
}
//Mark the NoOfPackIssued equal to the NoOfPack. Discrepancies are supposed to be saved after this function has finished running.
var query = HCMIS.Repository.Queries.Issue.UpdateMarkAsDispatched(userID, this.ID);
var queryConfirmIssue = HCMIS.Repository.Queries.Issue.UpdateMarkAsDispatched(this.ID);
if (prePrintedSTV.HasValue)
{
this.PrePrintedInvoiceNo = prePrintedSTV.Value;
this.Save();
}
BLL.Issue s = new Issue();
s.LoadFromRawSql(query);
s.LoadFromRawSql(queryConfirmIssue);
BLL.IssueDoc isDoc = new IssueDoc();
isDoc.Where.STVID.Value = this.ID;
isDoc.Query.Load();
if (isDoc.RowCount > 0)
{
int orderID = isDoc.OrderID;
BLL.Order ord = new Order();
ord.LoadByPrimaryKey(orderID);
if (ord.RowCount > 0)
{
ord.ChangeStatus(OrderStatus.Constant.DISPATCH_CONFIRMED,CurrentContext.UserId);
ord.Save();
}
}
return true;
}
示例15: HandleReceiveDocDeleting
private static void HandleReceiveDocDeleting(int receiveDocID, int userID, ReceiveDoc rd)
{
//Check if there is a Related Picklists
var pld = new PickListDetail();
pld.LoadByReceiveDocID(receiveDocID);
pld.Rewind();
if(pld.RowCount > 0)
{
var pl = new PickList();
pl.LoadByPrimaryKey(pld.PickListID);
var order = new Order();
order.LoadByPrimaryKey(pl.OrderID);
string printedIDs = "";
var stvs = new BLL.Issue();
stvs.Where.PickListID.Value = pl.ID;
stvs.Query.Load();
stvs.Rewind();
while (!stvs.EOF)
{
printedIDs += stvs.IDPrinted.ToString(CultureInfo.InvariantCulture) + " ,";
stvs.MoveNext();
}
printedIDs = printedIDs.Remove(printedIDs.Length - 1, 1);
throw new Exception(
string.Format("Please cancel/void the following Stvs: Ref No = {0} With PrintedIDs : {1}",
order.RefNo,printedIDs));
}
// Add new record on ReceiveDocDeleted
var recDel = ReceiveDocDeleted.AddNewLog(rd, userID);
// Delete related ReceivePallet
var receivePallet = new BLL.ReceivePallet();
receivePallet.LoadByReceiveDocID(receiveDocID);
receivePallet.Rewind();
while(!receivePallet.EOF)
{
receivePallet.MarkAsDeleted();
receivePallet.MoveNext();
}
// Delete related ReceivePriceConfirmation
var receivePriceConfirmation = new ReceivePriceConfirmation();
receivePriceConfirmation.LoadByReceiveDocID(rd.ID);
receivePriceConfirmation.MarkAsDeleted();
// Delete related ReceiveDocShortage
var rdShr = new ReceiveDocShortage();
rdShr.Where.ReceiveDocID.Value = rd.ID;
rdShr.Query.Load();
rdShr.Rewind();
while(!rdShr.EOF)
{
rdShr.MarkAsDeleted();
rdShr.MoveNext();
}
// Delete related ReceiveDocConfirmation
var rdConf = new ReceiveDocConfirmation();
rdConf.Where.ReceiveDocID.Value = rd.ID;
rdConf.Query.Load();
rdConf.Rewind();
while(!rdConf.EOF)
{
rdConf.MarkAsDeleted();
rdConf.MoveNext();
}
rd.MarkAsDeleted();
var transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
transaction.BeginTransaction();
try
{
receivePallet.Save();
receivePriceConfirmation.Save();
rdShr.Save();
rdConf.Save();
recDel.Save();
rd.Save();
transaction.CommitTransaction();
}
catch (Exception exception)
{
transaction.RollbackTransaction();
throw;
}
}