コード例 #1
0
ファイル: FormClaimPayEdit.cs プロジェクト: nampn/ODental
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDate.Text == "")
     {
         MsgBox.Show(this, "Please enter a date.");
         return;
     }
     if (textCarrierName.Text == "")
     {
         MsgBox.Show(this, "Please enter a carrier.");
         return;
     }
     if (textDate.errorProvider1.GetError(textDate) != "" ||
         textAmount.errorProvider1.GetError(textAmount) != "" ||
         textDateIssued.errorProvider1.GetError(textDateIssued) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (PIn.Double(textAmount.Text) == 0)
     {
         MsgBox.Show(this, "Please enter an amount.");
         return;
     }
     if (IsNew)
     {
         //prevents backdating of initial check
         if (!Security.IsAuthorized(Permissions.InsPayCreate, PIn.Date(textDate.Text)))
         {
             return;
         }
         //prevents attaching claimprocs with a date that is older than allowed by security.
     }
     else
     {
         //Editing an old entry will already be blocked if the date was too old, and user will not be able to click OK button.
         //This catches it if user changed the date to be older.
         if (!Security.IsAuthorized(Permissions.InsPayEdit, PIn.Date(textDate.Text)))
         {
             return;
         }
     }
     if (!PrefC.GetBool(PrefName.EasyNoClinics))
     {
         if (comboClinic.SelectedIndex == 0)
         {
             ClaimPaymentCur.ClinicNum = 0;
         }
         else
         {
             ClaimPaymentCur.ClinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum;
         }
     }
     ClaimPaymentCur.CheckDate   = PIn.Date(textDate.Text);
     ClaimPaymentCur.DateIssued  = PIn.Date(textDateIssued.Text);
     ClaimPaymentCur.CheckAmt    = PIn.Double(textAmount.Text);
     ClaimPaymentCur.CheckNum    = textCheckNum.Text;
     ClaimPaymentCur.BankBranch  = textBankBranch.Text;
     ClaimPaymentCur.CarrierName = textCarrierName.Text;
     ClaimPaymentCur.Note        = textNote.Text;
     try{
         if (IsNew)
         {
             ClaimPayments.Insert(ClaimPaymentCur);                    //error thrown if trying to change amount and already attached to a deposit.
         }
         else
         {
             ClaimPayments.Update(ClaimPaymentCur);                    //error thrown if trying to change amount and already attached to a deposit.
         }
     }
     catch (ApplicationException ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     ClaimProcs.SynchDateCP(ClaimPaymentCur.ClaimPaymentNum, ClaimPaymentCur.CheckDate);
     DialogResult = DialogResult.OK;
 }