protected void RadToolBarCreditMemoPayoutHistory_OnButtonClick(object sender, RadToolBarEventArgs e) { switch (e.Item.Text) { case "Add Payout": if (RadGridCreditMemoPayout.SelectedValue != null) { RunClientScript("ShowPayoutHistoryPop('" + RadGridCreditMemoPayout.SelectedValue + "', '0');"); } break; case "Payout Reverse": if (RadGridCreditMemoPayoutHistory.SelectedValue != null) { var creditMemoPayoutHistory = new CCreditMemoPayoutHistory().Get(Convert.ToInt32(RadGridCreditMemoPayoutHistory.SelectedValue)); if (creditMemoPayoutHistory.PayoutAmount > 0) { var cNewCreditMemoPayoutHistory = new CCreditMemoPayoutHistory(); var newCreditMemoPayoutHistory = new Erp2016.Lib.CreditMemoPayoutHistory(); CGlobal.Copy(creditMemoPayoutHistory, newCreditMemoPayoutHistory); newCreditMemoPayoutHistory.PayoutAmount *= -1; newCreditMemoPayoutHistory.OriginalCreditMemoPayoutHistoryId = creditMemoPayoutHistory.CreditMemoPayoutHistoryId; cNewCreditMemoPayoutHistory.Add(newCreditMemoPayoutHistory); RadGridCreditMemoPayout.Rebind(); RadGridCreditMemoPayoutHistory.Rebind(); } else { ShowMessage("Negative price can't reverse"); } } break; } }
protected void RadToolBar_ButtonClick(object sender, RadToolBarEventArgs e) { switch (e.Item.Text) { case "Save": if (IsValid) { var cC = new CCreditMemoPayoutHistory(); var c = new Erp2016.Lib.CreditMemoPayoutHistory(); //// new //if (Request["type"] == "0") //{ //c = new Erp2016.Lib.CreditMemoPayoutHistory(); c.CreatedId = CurrentUserId; c.CreatedDate = DateTime.Now; c.CreditMemoPayoutId = Id; //} //// modify //else //{ // c = cC.Get(Id); //} c.PayoutAmount = (decimal)RadNumericTextBoxAmount.Value; c.PayoutDate = (DateTime)RadDatePickerDate.SelectedDate; c.CheckNo = RadTextBoxCheckNo.Text; c.WireTransferNo = RadTextBoxWireTransferNo.Text; c.Remark = RadTextBoxRemark.Text; //// new //if (Request["type"] == "0") //{ decimal availableAmount = new CCreditMemoPayout().GetAvailablePayoutAmount(Id); if (availableAmount >= c.PayoutAmount) { cC.Add(c); RunClientScript("Close();"); } else { ShowMessage("paid amount is bigger than available payout amount"); } //} //// modify //else //{ // c.UpdatedId = CurrentUserId; // c.UpdatedDate = DateTime.Now; // cC.Update(c); // creditMemoPayoutId = c.CreditMemoPayoutId; //} } break; case "Close": RunClientScript("Close();"); break; } }