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(); } }