private void simpleButton1_Click(object sender, EventArgs e) { var dt = (DataView)gridView1.DataSource; dt.RowFilter = "Requested >0"; if (dt == null) { return; } var po = new PO(); po.AddNew(); var serverDateTime = DateTimeHelper.ServerDateTime; po.PODate = serverDateTime; po.DateOfEntry = serverDateTime; po.PurchaseType = POType.INTERNAL; po.PaymentTypeID = PaymentType.Constants.STV; po.TermOfPayement = TermOfPayment.List[6].ID; po.PurchaseOrderStatusID = 9; //PurchaseOrderStatus ==> Processed po.SavedbyUserID = CurrentContext.LoggedInUser.ID; po.Save(); var purchaseOrderDetail = new PurchaseOrderDetail(); foreach (DataRowView dr in dt) { var itemUnit = new ItemUnitBase(); itemUnit.LoadByPrimaryKey(Convert.ToInt32(dr["UnitID"])); purchaseOrderDetail.AddNew(); purchaseOrderDetail.ItemID = Convert.ToInt32(dr["ItemID"]); purchaseOrderDetail.UnitOfIssueID = itemUnit.UnitOfIssueID; purchaseOrderDetail.Quantity = Convert.ToInt32(dr["Requested"]); purchaseOrderDetail.PurchaseOrderID = po.ID; purchaseOrderDetail.Rowguid = Guid.NewGuid(); purchaseOrderDetail.ApprovedQuantity = 0; } purchaseOrderDetail.Save(); lookUpEdit1_EditValueChanged(null, null); }
private void btnSaveOrder_Click(object sender, EventArgs e) { if (dxValidation.Validate()) { var po = new PO(); if (PoID != 0) { po.LoadByPrimaryKey(PoID); } else { po.AddNew(); } if (PoID == 0 && po.DoesPONumberExists(txtOrderInformation.Text)) { XtraMessageBox.Show(string.Format(@"There is an existing Order with the same OrderNo as {0}. Please try to use another OrderNo!", txtOrderInformation.Text), "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (PoID == 0) { po.PONumber = txtOrderInformation.Text; } po.TotalValue = Convert.ToDouble(txtTotalValue.EditValue); po.Insurance = Convert.ToDouble(txtInsurance.EditValue); po.OtherExpense = Convert.ToDouble(txtInsuredSum.EditValue); po.NBE = Convert.ToDouble(txtNBEServiceCharge.EditValue); po.SupplierID = Convert.ToInt32(lkSupplier.EditValue); po.SavedbyUserID = CurrentContext.LoggedInUser.ID; //Make PurchaseType Default Value to Internale ID = 8 //po.PurchaseType = Convert.ToInt32(gridLkEditOrderType.EditValue) == 0 || Convert.ToInt32(gridLkEditOrderType.EditValue) == null ? POType.GetAllPOTypes().Find(pot=>pot.ID == POType.INTERNAL).ID : Convert.ToInt32(gridLkEditOrderType.EditValue); po.PurchaseType = Convert.ToInt32(gridLkEditOrderType.EditValue); po.StoreID = Convert.ToInt32(grdLkEditAccounts.EditValue); po.ExhangeRate = Convert.ToDouble(txtExchangeRate.EditValue); po.RefNo = txtRefNo.EditValue.ToString(); po.Delivery = txtDelivery.EditValue != null?txtDelivery.EditValue.ToString() : ""; if (txtFreight.EditValue != null) { po.AirFreight = Convert.ToDouble(txtFreight.EditValue); } po.Description = txtDescription.EditValue != null?txtDescription.EditValue.ToString() : ""; var serverDateTime = DateTimeHelper.ServerDateTime; po.PODate = serverDateTime; po.DateOfEntry = serverDateTime; po.LCID = Convert.ToInt32(lkCurrencyLCID.EditValue); //Make TermOfPayment Default to Internal , ID = 7, //po.TermOfPayement = Convert.ToInt32(lkTermOfPayement.EditValue) == 0 || Convert.ToInt32(lkTermOfPayement.EditValue) == null ? TermOfPayment.List[6].ID : Convert.ToInt32(lkTermOfPayement.EditValue); po.TermOfPayement = Convert.ToInt32(lkTermOfPayement.EditValue) == 0 || Convert.ToInt32(lkTermOfPayement.EditValue) == null ? PaymentTerm.Internal : Convert.ToInt32(lkTermOfPayement.EditValue); po.PaymentTypeID = PaymentType.Constants.STV; po.PurchaseOrderStatusID = PurchaseOrderStatus.Processed; //PurchaseOrderStatus ==> Processed po.IsElectronic = false; po.POFinalized = false; po.Rowguid = Guid.NewGuid(); po.Identifier = "00000"; var acc = new Activity(); acc.LoadByPrimaryKey(po.StoreID); po.ModeID = acc.ModeID; po.Save(); this.LogActivity("Save-PO", po.ID); this.DialogResult = DialogResult.Yes; this.Close(); } }