private Order GenerateOrder() { var or = new Order(); if (OrderID == null) or.AddNew(); else or.LoadByPrimaryKey(OrderID.Value); or.RefNo = Order.GetNextOrderReference(); txtRefNo.Text = or.RefNo; var oldOrderStatus = or.IsColumnNull("OrderStatusID") ? (int?)null : or.OrderStatusID; or.OrderStatusID = OrderStatus.Constant.PICK_LIST_GENERATED; //or.Remark = txtRemark.Text; or.EurDate = or.Date = DateTimeHelper.ServerDateTime; //Both fields are assigned dates. if (TransferTypeID == 1) or.RequestedBy = Convert.ToInt32(lkForHub.EditValue); or.FilledBy = CurrentContext.UserId; or.ContactPerson = txtContactPerson.Text; var activity = new Activity(); activity.LoadByPrimaryKey(Convert.ToInt32(lkAccountType.EditValue)); or.FromStore = activity.ModeID; if (BLL.Settings.IsCenter) { //What the Hell is this? or.PaymentTypeID = PaymentType.Constants.STV; } else { or.PaymentTypeID = PaymentType.Constants.STV; } or.FiscalYearID = FiscalYear.Current.ID; or.Save(); or.LogRequisitionStatus(or.ID, oldOrderStatus, OrderStatus.Constant.PICK_LIST_GENERATED,CurrentContext.UserId); return or; }