Пример #1
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         if (_listSplitsForAdjustment.Count > 0)
         {
             MsgBox.Show(this, "Cannot delete adjustment while a payment split is attached.");
             return;
         }
         bool isAttachedToPayPlan = PayPlanLinks.GetForFKeyAndLinkType(_adjustmentCur.AdjNum, PayPlanLinkType.Adjustment).Count > 0;
         if (isAttachedToPayPlan)
         {
             MsgBox.Show(this, "Cannot delete adjustment that is attached to a dynamic payment plan");
             return;
         }
         if (_listSplitsForAdjustment.Count > 0 &&
             !MsgBox.Show(this, MsgBoxButtons.YesNo, "There are payment splits associated to this adjustment.  Do you want to continue deleting?"))
         {                //There are splits for this adjustment
             return;
         }
         SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, _adjustmentCur.PatNum
                                   , "Delete for patient: " + _patCur.GetNameLF() + ", " + _adjustmentCur.AdjAmt.ToString("c"), 0, _adjustmentCur.SecDateTEdit);
         Adjustments.Delete(_adjustmentCur);
         DialogResult = DialogResult.OK;
     }
 }
Пример #2
0
        private void FormAdjust_Load(object sender, System.EventArgs e)
        {
            if (AvaTax.IsEnabled())
            {
                //We do not want to allow the user to make edits or delete SalesTax and SalesTaxReturn Adjustments.  Popup if no permission so user knows why disabled.
                if (AvaTax.IsEnabled() &&
                    (_adjustmentCur.AdjType == AvaTax.SalesTaxAdjType || _adjustmentCur.AdjType == AvaTax.SalesTaxReturnAdjType) &&
                    !Security.IsAuthorized(Permissions.SalesTaxAdjEdit))
                {
                    DisableForm(textNote, butCancel);
                    textNote.ReadOnly = true;                  //This will allow the user to copy the note if desired.
                }
            }
            if (IsNew)
            {
                if (!Security.IsAuthorized(Permissions.AdjustmentCreate, true))                //Date not checked here.  Message will show later.
                {
                    if (!Security.IsAuthorized(Permissions.AdjustmentEditZero, true))          //Let user create an adjustment of zero if they have this perm.
                    {
                        MessageBox.Show(Lans.g("Security", "Not authorized for") + "\r\n" + GroupPermissions.GetDesc(Permissions.AdjustmentCreate));
                        DialogResult = DialogResult.Cancel;
                        return;
                    }
                    //Make sure amount is 0 after OK click.
                    _checkZeroAmount = true;
                }
            }
            else
            {
                if (!Security.IsAuthorized(Permissions.AdjustmentEdit, _adjustmentCur.AdjDate))
                {
                    butOK.Enabled     = false;
                    butDelete.Enabled = false;
                    //User can't edit but has edit zero amount perm.  Allow delete only if date is today.
                    if (Security.IsAuthorized(Permissions.AdjustmentEditZero, true) &&
                        _adjustmentCur.AdjAmt == 0 &&
                        _adjustmentCur.DateEntry.Date == MiscData.GetNowDateTime().Date)
                    {
                        butDelete.Enabled = true;
                    }
                }
                bool isAttachedToPayPlan = PayPlanLinks.GetForFKeyAndLinkType(_adjustmentCur.AdjNum, PayPlanLinkType.Adjustment).Count > 0;
                _listSplitsForAdjustment = PaySplits.GetForAdjustments(new List <long>()
                {
                    _adjustmentCur.AdjNum
                });
                if (_listSplitsForAdjustment.Count > 0 || isAttachedToPayPlan)
                {
                    butAttachProc.Enabled     = false;
                    butDetachProc.Enabled     = false;
                    labelProcDisabled.Visible = true;
                }
                //Do not let the user change the adjustment type if the current adjustment is a "discount plan" adjustment type.
                if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "dp")
                {
                    labelAdditions.Text       = Lan.g(this, "Discount Plan") + ": " + Defs.GetName(DefCat.AdjTypes, _adjustmentCur.AdjType);
                    labelSubtractions.Visible = false;
                    listTypePos.Visible       = false;
                    listTypeNeg.Visible       = false;
                }
            }
            textDateEntry.Text = _adjustmentCur.DateEntry.ToShortDateString();
            textAdjDate.Text   = _adjustmentCur.AdjDate.ToShortDateString();
            textProcDate.Text  = _adjustmentCur.ProcDate.ToShortDateString();
            if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "+")         //pos
            {
                textAmount.Text = _adjustmentCur.AdjAmt.ToString("F");
            }
            else if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "-")    //neg
            {
                textAmount.Text = (-_adjustmentCur.AdjAmt).ToString("F");              //shows without the neg sign
            }
            else if (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "dp")   //Discount Plan (neg)
            {
                textAmount.Text = (-_adjustmentCur.AdjAmt).ToString("F");              //shows without the neg sign
            }
            comboClinic.SelectedClinicNum = _adjustmentCur.ClinicNum;
            comboProv.SetSelectedProvNum(_adjustmentCur.ProvNum);
            FillComboProv();
            if (_adjustmentCur.ProcNum != 0 && PrefC.GetInt(PrefName.RigorousAdjustments) == (int)RigorousAdjustments.EnforceFully)
            {
                comboProv.Enabled   = false;
                butPickProv.Enabled = false;
                comboClinic.Enabled = false;
                if (Security.IsAuthorized(Permissions.Setup, true))
                {
                    labelEditAnyway.Visible = true;
                    butEditAnyway.Visible   = true;
                }
            }
            //prevents FillProcedure from being called too many times.  Event handlers hooked back up after the lists are filled.
            listTypeNeg.SelectedIndexChanged -= listTypeNeg_SelectedIndexChanged;
            listTypePos.SelectedIndexChanged -= listTypePos_SelectedIndexChanged;
            List <Def> adjCat = Defs.GetDefsForCategory(DefCat.AdjTypes, true);

            //Positive adjustment types
            _listAdjPosCats = adjCat.FindAll(x => x.ItemValue == "+");
            _listAdjPosCats.ForEach(x => listTypePos.Items.Add(x.ItemName));
            listTypePos.SelectedIndex = _listAdjPosCats.FindIndex(x => x.DefNum == _adjustmentCur.AdjType);        //can be -1
            //Negative adjustment types
            _listAdjNegCats = adjCat.FindAll(x => x.ItemValue == "-");
            _listAdjNegCats.ForEach(x => listTypeNeg.Items.Add(x.ItemName));
            listTypeNeg.SelectedIndex         = _listAdjNegCats.FindIndex(x => x.DefNum == _adjustmentCur.AdjType);//can be -1
            listTypeNeg.SelectedIndexChanged += listTypeNeg_SelectedIndexChanged;
            listTypePos.SelectedIndexChanged += listTypePos_SelectedIndexChanged;
            FillProcedure();
            textNote.Text = _adjustmentCur.AdjNote;
        }