public JsonResult ConfirmPO(int pId) { PurchaseOrderData.setStatus(pId, "confirmed"); object new_amount = new { }; return(Json(new_amount, JsonRequestBehavior.AllowGet)); }
/////////////////////////////////////////////////////////////////////////ReOrder features public ActionResult TobeReOrderList() { ItemData.SetSupplier(); List <Item> listItem = ItemData.FindAll(); //Get all items which is in process of reOrder List <Item> listinprocess = PurchaseOrderData.GetItemsInProcess(); //Get all items whose stockbalance is below reorderLevel List <Item> listreorder = listItem.Where(x => x.ReorderLevel > StockCardData.GetStockBalanceByItem(x)).ToList(); //Screen out items in process listinprocess.ForEach(x => listreorder.Remove(x)); Dictionary <int, int> selectedsupplier = new Dictionary <int, int>(); foreach (Item item in listreorder) { int itId = item.Id; int suId = item.Supplier1.supplier.Id; selectedsupplier.Add(item.Id, item.Supplier1.supplier.Id); } Session["selectedsupplier"] = selectedsupplier; ViewBag.Rlist = listreorder; return(View()); }
public JsonResult RejectPO(int pId) { //Link to send email to supplier PurchaseOrderData.setStatus(pId, "rejected"); object new_amount = new { }; return(Json(new_amount, JsonRequestBehavior.AllowGet)); }
public override global::System.Data.DataSet Clone() { PurchaseOrderData cln = ((PurchaseOrderData)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { PurchaseOrderData ds = new PurchaseOrderData(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public async Task WebThreeState_ShouldAdd_FormDataObjectToSTate() { var formData = new PurchaseOrderData() { Approver = "I approve", Title = "NewTestFormTitle", DeliveryDate = DateTime.Now, Department = "DepartMentData", Item_Code = "ITem Code Data", Item_Discount = 42, Item_Name = "TEst ITem Name", Item_Price = "Item_Price data", Item_Qty = 42, Item_Total = 42, Notes = "Here are some notes", Requester = "The Request is success" }; string MutableDataTestString = "Mutable Data Test Words With a Full Model"; var SendFormInfo = new AddFormDataToStateAction() { FormObjectValues = formData, MutableDataString = MutableDataTestString }; WebThreeState SendFormDataResponse = await Mediator.Send(SendFormInfo); SendFormDataResponse.ImmutableObject.Title.ShouldBe("NewTestFormTitle"); SendFormDataResponse.MutableDataString.ShouldBe("Mutable Data Test Words With a Full Model"); WebThreeState ControlWebThreeState = Store.GetState <WebThreeState>(); ControlWebThreeState.ImmutableObject.Title.ShouldBe("NewTestFormTitle"); ControlWebThreeState.ImmutableObject.GetProperty("Approver").GetValue(ControlWebThreeState.ImmutableObject).ShouldBe("I approve"); ControlWebThreeState.ImmutableObject.GetProperty("Item_Total").GetValue(ControlWebThreeState.ImmutableObject).ShouldBe(42); //ImmutableObjectBase ControlImmutableObj = ControlWebThreeState.ImmutableObject; //ImmutableObjectBase TestedImmutableObj = SendFormDataResponse.ImmutableObject; //ControlWebThreeState.ImmutableObject.Title.ShouldBe("Mutable Data Test Words With a Full Model"); //System.Reflection.PropertyInfo[] Control_ImmutableObjectParams = ControlWebThreeState.ImmutableObject.GetType().GetProperties(); //foreach (System.Reflection.PropertyInfo prop in Control_ImmutableObjectParams) //{ // var testValue = //} //static object GetValue(System.Reflection.PropertyInfo PropName, object TargetObj) //{ // return PropName.GetValue(TargetObj); //} }
/// <summary> /// Creates a connection using token. /// </summary> /// <param name="companyId">Company context</param> /// <param name="token">The predefined token from Visma.net</param> /// <param name="branchId">Branch ID to work with in the Visma.net Company (optional)</param> public VismaNet(int companyId, string token, int branchId = 0) { if (string.IsNullOrEmpty(token)) { throw new InvalidArgumentsException("Token is missing"); } Auth = new VismaNetAuthorization { Token = token, CompanyId = companyId, BranchId = branchId }; Attribute = new AttributeData(Auth); Customer = new CustomerData(Auth); Currency = new CurrencyData(Auth); CustomerInvoice = new CustomerInvoiceData(Auth); Supplier = new SupplierData(Auth); SupplierInvoice = new SupplierInvoiceData(Auth); CashSale = new CashSaleData(Auth); CustomerDocument = new CustomerDocumentData(Auth); Dimension = new DimensionData(Auth); Discount = new DiscountData(Auth); Inventory = new InventoryData(Auth); JournalTransaction = new JournalTransactionData(Auth); GeneralLedgerTransaction = new GeneralLedgerTransactionData(Auth); GeneralLedgerBalance = new GeneralLedgerBalanceData(Auth); Account = new FinAccountData(Auth); FinancialPeriod = new FinancialPeriodData(Auth); Employee = new EmployeeData(Auth); Shipment = new ShipmentData(Auth); Contact = new ContactData(Auth); Project = new ProjectData(Auth); #pragma warning disable CS0618 // Type or member is obsolete SalesOrder = new SalesOrderData(Auth); #pragma warning restore CS0618 // Type or member is obsolete Branch = new BranchData(Auth); Warehouse = new WarehouseData(Auth); Location = new LocationData(Auth); Subaccount = new SubaccountData(Auth); CustomerPayment = new CustomerPaymentData(Auth); Dynamic = new VismaNetDynamicEndpoint(null, Auth); Resources = new VismaNetDynamicEndpoint(null, Auth, true); SupplierDocument = new SupplierDocumentData(Auth); InventoryIssue = new InventoryIssueData(Auth); InventoryReceipt = new InventoryReceiptData(Auth); PurchaseReceipt = new PurchaseReceiptData(Auth); CustomerSalesPrice = new CustomerSalesPriceData(Auth); CustomerCreditNote = new CustomerCreditNoteData(Auth); PurchaseOrder = new PurchaseOrderData(Auth); CashTransaction = new CashTransactionData(Auth); }
public void FullSerializeDeSerializeWithData_InPoDataType() { byte[] BolSerializedByteArray = Serializer.Serialize(TestObject); string byteArraytoBase64String = Convert.ToBase64String(BolSerializedByteArray); byte[] serializedObjectBase64StringBackToByteArray = Convert.FromBase64String(byteArraytoBase64String); PurchaseOrderData restoredFromBase64String = Serializer.Deserialize <PurchaseOrderData>(serializedObjectBase64StringBackToByteArray, options); restoredFromBase64String.ShouldBeOfType <PurchaseOrderData>(); //restoredFromBase64String.MutableDataString.ShouldBe(TestObject.MutableDataString); restoredFromBase64String.Item_Price.ShouldBe(TestObject.Item_Price); restoredFromBase64String.Approver.ShouldBe(TestObject.Approver); }
public JsonResult CheckInPO(int pId) { PurchaseOrder po = PurchaseOrderData.GetPOById(pId); //Add record to stock card foreach (Item item in po.items.Select(x => x.item).ToList()) { int balance = StockCardData.GetStockBalanceByItem(item); StockCardData.AddToStock(item, DateTime.Today, po.items.FirstOrDefault().supplier.Id, po.items.Select(x => x.UnitPrice).FirstOrDefault(), po.items.Select(x => x.item.ReorderQty).FirstOrDefault(), balance); } PurchaseOrderData.setStatus(pId, "delivered"); object new_amount = new { }; return(Json(new_amount, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存采购订单 /// </summary> /// <param name="data">前端传回的订单数据,如lineGuid存在则更新,不存在则添加</param> /// <returns></returns> public static bool SavePurchaseOrder(PurchaseOrderData data) { try { if (data.lines == null || data.lines.Count == 0) { return(false); } CompanyAddress company = Common.CompanyHelper.GetCompanyAddress(data.companyGuid); if (company == null) { throw new Exception("Aden.BLL.Common.CompanyHelper.GetCompanyAddress doesn't exist companyGuid:" + data.companyGuid); } string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); var query1 = data.lines.Where(l => !string.IsNullOrEmpty(l.lineGuid)); if (query1.Any()) { factory.UpdatePurchaseOrder(query1.ToList(), data.userGuid, now); } var query2 = data.lines.Where(l => string.IsNullOrEmpty(l.lineGuid) && l.qty.ToDouble() > 0); if (query2.Any()) { string date = DateTime.Parse(data.orderDate).ToString("yyyy-MM-dd"); string description = string.Empty; if (data.costCenterCode.Length >= 6) { description = "PO-" + data.costCenterCode.Substring(3, 3) + "(" + date + ")"; } else { description = "PO-" + data.costCenterCode + "(" + date + ")"; } factory.AddPurchaseOrder(query2.ToList(), company.erpCode, date, data.warehouseCode, data.costCenterCode, description, "001", data.userGuid, now); } return(true); } catch (Exception ex) { LogHelper.WriteLog(new Log() { message = ex.Message }, "SavePurchaseOrder"); return(true); } }
public List <PurchaseOrderData> PurchaseOrderList() { List <PurchaseOrderData> purchaseOrderList = new List <PurchaseOrderData>(); this.Open(); int recordCount = this.RetrieveRecords(); this.MoveFirst(); for (int x = 1; x <= recordCount; x++) { PurchaseOrderData purchaseOrderData = new PurchaseOrderData(this, x); purchaseOrderList.Add(purchaseOrderData); } return(purchaseOrderList); }
private void DeserializeAndAddData(TokenBase aOwnedToken, string aDataString) { if (aOwnedToken.TemplateData.NftId == 1) { byte[] serializedImmutableData = Convert.FromBase64String(aDataString); PurchaseOrderData aDeserializedObject = Serializer.Deserialize <PurchaseOrderData>(serializedImmutableData, options); // options == 0 aOwnedToken.PurchaseOrderData = aDeserializedObject; // Add to StateList TokenDataList.Add(aOwnedToken); } else { aOwnedToken.Data = aDataString; TokenDataList.Add(aOwnedToken); } }
public Response SaveOrder(string token, [FromBody] PurchaseOrderData orderData) { Response response = new Response(); if (string.IsNullOrEmpty(token) || !token.Equals(_token)) { response.code = "404"; response.message = "Invild token"; } else { bool status = PurchaseHelper.SavePurchaseOrder(orderData); if (status) response.code = "200"; else { response.code = "500"; response.message = "process failed"; } } return response; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); PurchaseOrderData ds = new PurchaseOrderData(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "potblDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public ActionResult ManagePO() { //Get all PO in process List <PurchaseOrder> pendingpo = PurchaseOrderData.GetPendingPO(); List <PurchaseOrder> sentpo = PurchaseOrderData.GetSentPO(); List <PurchaseOrder> confirmedpo = PurchaseOrderData.GetConfirmedPO(); Dictionary <PurchaseOrder, List <Item> > ppo = new Dictionary <PurchaseOrder, List <Item> >(); Dictionary <PurchaseOrder, List <Item> > spo = new Dictionary <PurchaseOrder, List <Item> >(); Dictionary <PurchaseOrder, List <Item> > cpo = new Dictionary <PurchaseOrder, List <Item> >(); foreach (PurchaseOrder po in pendingpo) { List <Item> li = new List <Item>(); foreach (ItemSupplier rr in po.items) { if (ppo.ContainsKey(po)) { ppo[po].Add(rr.item); } else { li.Add(rr.item); ppo.Add(po, li); } } } foreach (PurchaseOrder po in sentpo) { List <Item> li = new List <Item>(); foreach (ItemSupplier rr in po.items) { if (spo.ContainsKey(po)) { spo[po].Add(rr.item); } else { li.Add(rr.item); spo.Add(po, li); } } } foreach (PurchaseOrder po in confirmedpo) { List <Item> li = new List <Item>(); foreach (ItemSupplier rr in po.items) { if (cpo.ContainsKey(po)) { cpo[po].Add(rr.item); } else { li.Add(rr.item); cpo.Add(po, li); } } } ViewBag.Plist = ppo; ViewBag.Slist = spo; ViewBag.Clist = cpo; return(View()); }
public JsonResult GeneratePendingPO() { List <PurchaseOrder> listPO = new List <PurchaseOrder>(); Dictionary <int, int> selectedsupplier = new Dictionary <int, int>(); if (Session["selectedsupplier"] != null) { selectedsupplier = (Dictionary <int, int>)Session["selectedsupplier"]; } else { throw new Exception("please log in"); } //Group the reorder demand by selected supplier Dictionary <int, List <int> > itemsforeachsupplier = new Dictionary <int, List <int> >(); var supplierIdset = new HashSet <int>(selectedsupplier.Values); foreach (int supId in supplierIdset) { List <int> itemlist = new List <int>(); foreach (int itemId in selectedsupplier.Keys) { if (selectedsupplier[itemId] == supId) { if (itemsforeachsupplier.ContainsKey(supId)) { itemsforeachsupplier[supId].Add(itemId); } else { itemlist.Add(itemId); itemsforeachsupplier.Add(supId, itemlist); } } } } //Create PO foreach (int supId in itemsforeachsupplier.Keys) { List <ItemSupplier> lrr = new List <ItemSupplier>(); foreach (int itemId in itemsforeachsupplier[supId]) { ItemSupplier its = ItemSupplierData.GetByItemIdAndSupplierId(itemId, supId); int itId = its.Id; int suId = its.supplier.Id; lrr.Add(its); //ReOrderRecordData.CreateReOrderRocord(its); } PurchaseOrderData.CreatePO(lrr); } ViewBag.reorderrecordgroupbysupplier = itemsforeachsupplier; Session.Remove("selectedsupplier"); object new_amount = new { }; return(Json(new_amount, JsonRequestBehavior.AllowGet)); }
public PurchaseOrder(PurchaseOrderData data) { Load(data); }
private void Load(PurchaseOrderData data) { if (data != null) { Init(); PurchaseOrderID = data.purchase_order_id; VendorID = data.vendor_id; PurchaseOrderTypeLUID = data.purchase_order_type_luid; OrganizationID = data.organization_id; CreatedByUserID = data.created_by; ModifiedByUserID = data.modified_by; DateCreated = data.date_created; DateModified = data.date_modified; Active = data.active; if (data.date_ordered != null) { DateOrdered = (DateTime)data.date_ordered; } if (data.ordered_by != null) { OrderedByID = (int)data.ordered_by; } StatusLUID = data.status_luid; if (data.ship_to_name != null) { ShipToName = data.ship_to_name; } if (data.ship_to_attention != null) { ShipToAttn = data.ship_to_attention; } if (data.ship_to_address != null) { ShipToAddress = new Helpers.Address(data.ship_to_address); } if (data.date_received != null) { DateReceived = (DateTime)data.date_received; } if (data.date_closed != null) { DateClosed = (DateTime)data.date_closed; } if (data.shipping_charge != null) { ShippingCharge = (decimal)data.shipping_charge; } if (data.other_charge != null) { OtherCharge = (decimal)data.other_charge; } HasBeenBilled = data.has_been_billed; Terms = data.terms; if (data.default_payment_method_id != null) { DefaultPaymentMethodID = (int)data.default_payment_method_id; } } }
public void Save(string uid) { try { if (string.IsNullOrEmpty(uid)) { throw new ArgumentNullException("UID", "User Name is required."); } Dictionary <string, string> ValErrors = Validate(); if (ValErrors.Count > 0) { throw new RequisitionNotValidException("Purchase Order is not valid.", ValErrors); } using (PurchasingContext Context = ContextHelper.GetDBContext()) { Enums.HistoryType ChangeType; PurchaseOrder Original = null; PurchaseOrderData data = null; if (PurchaseOrderID > 0) { ChangeType = Enums.HistoryType.UPDATE; data = Context.PurchaseOrderDatas.FirstOrDefault(x => x.purchase_order_id == PurchaseOrderID); Original = new PurchaseOrder(data); } else { ChangeType = Enums.HistoryType.ADD; data = new PurchaseOrderData(); data.created_by = uid; data.date_created = DateTime.Now; } data.vendor_id = VendorID; data.purchase_order_type_luid = PurchaseOrderTypeLUID; data.organization_id = OrganizationID; if (DateOrdered > DateTime.MinValue) { data.date_ordered = DateOrdered; } else { data.date_ordered = null; } if (OrderedByID > 0) { data.ordered_by = OrderedByID; } else { data.ordered_by = null; } data.status_luid = StatusLUID; if (DateReceived > DateTime.MinValue) { data.date_received = DateReceived; } else { data.date_received = null; } if (DateClosed > DateTime.MinValue) { data.date_closed = DateClosed; } else { data.date_closed = null; } if (!String.IsNullOrEmpty(ShipToName)) { data.ship_to_name = ShipToName; } else { data.ship_to_name = null; } if (!String.IsNullOrEmpty(ShipToAttn)) { data.ship_to_attention = ShipToAttn; } else { data.ship_to_attention = null; } if (ShipToAddress != null && ShipToAddress.IsValid()) { data.ship_to_address = ShipToAddress.ToArenaFormat(); } else { data.ship_to_address = null; } if (ShippingCharge != 0) { data.shipping_charge = ShippingCharge; } else { data.shipping_charge = null; } if (OtherCharge != 0) { data.other_charge = OtherCharge; } else { data.other_charge = null; } if (DefaultPaymentMethodID > 0) { data.default_payment_method_id = DefaultPaymentMethodID; } else { data.default_payment_method_id = null; } data.modified_by = uid; data.date_modified = DateTime.Now; data.active = Active; if (!String.IsNullOrEmpty(Terms)) { data.terms = Terms.Trim(); } else { data.terms = null; } data.has_been_billed = HasBeenBilled; if (PurchaseOrderID <= 0) { Context.PurchaseOrderDatas.InsertOnSubmit(data); } Context.SubmitChanges(); Load(data); SaveHistory(ChangeType, Original, uid); } } catch (Exception ex) { throw new RequisitionException("An error has occurred while saving purchase order.", ex); } }