private void frmItemDiscount_FormClosing(object sender, FormClosingEventArgs e) { decimal value = 0; bool ischange = false; decimal.TryParse(txtDiscount.Text, out value); ischange = saleLineItem.Discount != value; saleLineItem.Discount = value; decimal.TryParse(txtSpecialDiscount.Text, out value); ischange = ischange || saleLineItem.SpecialDiscount != value; saleLineItem.SpecialDiscount = value; decimal.TryParse(txtVolumeDiscount.Text, out value); ischange = ischange || saleLineItem.VolumeDiscount != value; saleLineItem.VolumeDiscount = value; if (ischange) { frmChangeType changeType = new frmChangeType(); changeType.FormClosed += ChangeType_FormClosed; changeType.Show(); e.Cancel = true; } }
private void ChangeType_FormClosed(object sender, FormClosedEventArgs e) { frmChangeType changeType = sender as frmChangeType; decimal discount; decimal.TryParse(txtDiscount.Text, out discount); decimal specialDiscount; decimal.TryParse(txtSpecialDiscount.Text, out specialDiscount); DataRow dr = StagingData.ItemList.Select("ItemCode=" + saleLineItem.ItemCode).FirstOrDefault(); if (dr != null) { dr["SpecialDiscountRecieved"] = specialDiscount; } decimal volumeDiscount; decimal.TryParse(txtVolumeDiscount.Text, out volumeDiscount); if (changeType.ChangeType != PharmaBusinessObjects.Common.Enums.SaleEntryChangeType.TemporaryChange) { applicationFacade.UpdateSaleDiscount(changeType.ChangeType, discount, specialDiscount, volumeDiscount, saleLineItem.ItemCode, customerCode); } this.Close(); }