private void btnSave_Click(object sender, EventArgs e) { LogReceiptChange change = new LogReceiptChange(rDoc); if (txtBatchNo.EditValue != null) { rDoc.BatchNo = txtBatchNo.Text; } if (dtExpiry.EditValue != null) { rDoc.ExpDate = dtExpiry.DateTime; } else { rDoc.SetColumnNull("ExpDate"); } if (txtPrice.EditValue != null) { rDoc.Cost = Convert.ToDouble(txtPrice.EditValue); } if(lkAccount.EditValue!=null) { rDoc.StoreID = Convert.ToInt32(lkAccount.EditValue); //TODO:Edit other tables as well. } if(lkUnit.EditValue!=null) { int unitID = Convert.ToInt32(lkUnit.EditValue); if (rDoc.UnitID != unitID) { rDoc.UnitID = Convert.ToInt32(lkUnit.EditValue); BLL.ItemUnit itemUnit = new ItemUnit(); itemUnit.LoadByPrimaryKey(rDoc.UnitID); rDoc.QtyPerPack = itemUnit.QtyPerUnit; rDoc.Quantity = rDoc.NoOfPack * rDoc.QtyPerPack; rDoc.QuantityLeft = rDoc.Quantity; BLL.ReceivePallet rp = new ReceivePallet(); rp.LoadByReceiveDocID(rDoc.ID); rp.Balance = rDoc.QuantityLeft; rp.ReceivedQuantity = rDoc.Quantity; rDoc.Save(); rp.Save(); } } // decide to save the quantity or not //Lord have mercy, this is not a proper way to do it, decimal quantity = Convert.ToDecimal(txtQuanitity.EditValue.ToString().Replace(",", "")); if (txtQuanitity.Enabled && !rDoc.HasTransactions() && rDoc.Quantity != rDoc.QtyPerPack * quantity) { // now find the receive pallets ReceivePallet receivePallet = new ReceivePallet(); receivePallet.LoadNonZeroRPByReceiveID(rDoc.ID); if (receivePallet.RowCount > 1) { // XtraMessageBox.Show( "This Item is stored in more than one location and chaning the quanitity is not implemented. try to consolidate it and try again"); } else { rDoc.NoOfPack = quantity; receivePallet.Balance = receivePallet.ReceivedQuantity = rDoc.QuantityLeft = rDoc.Quantity = quantity * rDoc.QtyPerPack; rDoc.Save(); receivePallet.Save(); } } else if (rDoc.Quantity != quantity * rDoc.QtyPerPack) { XtraMessageBox.Show("The Quantity was not edited because there was an issue transaction on it."); } rDoc.RefNo = txtGrvNo.EditValue.ToString(); //rDoc.SupplierID = Convert.ToInt32(lkSupplier.EditValue); if (lkManufacturer.EditValue != null) rDoc.ManufacturerId = Convert.ToInt32(lkManufacturer.EditValue); this.DialogResult = System.Windows.Forms.DialogResult.OK; rDoc.Save(); change.SaveChangeLog(rDoc, CurrentContext.UserId); this.LogActivity("Save-Receipt-Change", rDoc.ID); this.Close(); }