private void FormAdjust_Load(object sender, System.EventArgs e) { 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; } } } textDateEntry.Text = AdjustmentCur.DateEntry.ToShortDateString(); textAdjDate.Text = AdjustmentCur.AdjDate.ToShortDateString(); textProcDate.Text = AdjustmentCur.ProcDate.ToShortDateString(); if (DefC.GetValue(DefCat.AdjTypes, AdjustmentCur.AdjType) == "+") //pos { textAmount.Text = AdjustmentCur.AdjAmt.ToString("F"); } else //neg { textAmount.Text = (-AdjustmentCur.AdjAmt).ToString("F"); //shows without the neg sign } for (int i = 0; i < ProviderC.ListShort.Count; i++) { comboProv.Items.Add(ProviderC.ListShort[i].GetLongDesc()); if (ProviderC.ListShort[i].ProvNum == AdjustmentCur.ProvNum) { comboProv.SelectedIndex = i; } } if (PrefC.GetBool(PrefName.EasyNoClinics)) { labelClinic.Visible = false; comboClinic.Visible = false; } else { comboClinic.Items.Add("none"); comboClinic.SelectedIndex = 0; for (int i = 0; i < Clinics.List.Length; i++) { comboClinic.Items.Add(Clinics.List[i].Description); if (Clinics.List[i].ClinicNum == AdjustmentCur.ClinicNum) { comboClinic.SelectedIndex = i + 1; } } } for (int i = 0; i < DefC.Short[1].Length; i++) //temp.AdjType { if (DefC.Short[1][i].ItemValue == "+") { PosIndex.Add(i); listTypePos.Items.Add(DefC.Short[1][i].ItemName); if (DefC.Short[1][i].DefNum == AdjustmentCur.AdjType) { listTypePos.SelectedIndex = PosIndex.Count - 1; } } else if (DefC.Short[1][i].ItemValue == "-") { NegIndex.Add(i); listTypeNeg.Items.Add(DefC.Short[1][i].ItemName); if (DefC.Short[1][i].DefNum == AdjustmentCur.AdjType) { listTypeNeg.SelectedIndex = NegIndex.Count - 1; } } } //this.listProvNum.SelectedIndex=(int)temp.ProvNum; this.textNote.Text = AdjustmentCur.AdjNote; }
private void butOK_Click(object sender, System.EventArgs e) { if (textAdjDate.errorProvider1.GetError(textAdjDate) != "" || textProcDate.errorProvider1.GetError(textProcDate) != "" || textAmount.errorProvider1.GetError(textAmount) != "" ) { MsgBox.Show(this, "Please fix data entry errors first."); return; } if (textAmount.Text == "") { MessageBox.Show(Lan.g(this, "Please enter an amount.")); return; } if (listTypeNeg.SelectedIndex == -1 && listTypePos.SelectedIndex == -1) { MsgBox.Show(this, "Please select a type first."); return; } if (IsNew) { //prevents backdating of initial adjustment if (!Security.IsAuthorized(Permissions.AdjustmentCreate, PIn.Date(textAdjDate.Text), true)) //Give message later. { if (!checkZeroAmount) //Let user create as long as Amount is zero and has edit zero permissions. This was checked on load. { MessageBox.Show(Lans.g("Security", "Not authorized for") + "\r\n" + GroupPermissions.GetDesc(Permissions.AdjustmentCreate)); return; } } } 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.AdjustmentEdit, PIn.Date(textAdjDate.Text))) { return; } } //DateEntry not allowed to change AdjustmentCur.AdjDate = PIn.Date(textAdjDate.Text); AdjustmentCur.ProcDate = PIn.Date(textProcDate.Text); if (comboProv.SelectedIndex == -1) //might be a hidden provider, so don't change. // AdjustmentCur.ProvNum=PatCur.PriProv; { } else { AdjustmentCur.ProvNum = ProviderC.ListShort[comboProv.SelectedIndex].ProvNum; } if (!PrefC.GetBool(PrefName.EasyNoClinics)) { if (comboClinic.SelectedIndex == 0) { AdjustmentCur.ClinicNum = 0; } else { AdjustmentCur.ClinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum; } } if (listTypePos.SelectedIndex != -1) { AdjustmentCur.AdjType = DefC.Short[(int)DefCat.AdjTypes][(int)PosIndex[listTypePos.SelectedIndex]].DefNum; } if (listTypeNeg.SelectedIndex != -1) { AdjustmentCur.AdjType = DefC.Short[(int)DefCat.AdjTypes][(int)NegIndex[listTypeNeg.SelectedIndex]].DefNum; } if (DefC.GetValue(DefCat.AdjTypes, AdjustmentCur.AdjType) == "+") //pos { AdjustmentCur.AdjAmt = PIn.Double(textAmount.Text); } else //neg { AdjustmentCur.AdjAmt = -PIn.Double(textAmount.Text); } if (checkZeroAmount) { if (AdjustmentCur.AdjAmt != 0) { MsgBox.Show(this, "Amount has to be 0.00 due to security permission."); return; } } AdjustmentCur.AdjNote = textNote.Text; try{ if (IsNew) { Adjustments.Insert(AdjustmentCur); } else { Adjustments.Update(AdjustmentCur); } } catch (Exception ex) { //even though it doesn't currently throw any exceptions MessageBox.Show(ex.Message); return; } if (IsNew) { SecurityLogs.MakeLogEntry(Permissions.AdjustmentCreate, AdjustmentCur.PatNum, Patients.GetLim(AdjustmentCur.PatNum).GetNameLF() + ", " + AdjustmentCur.AdjAmt.ToString("c")); } else { SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, AdjustmentCur.PatNum, Patients.GetLim(AdjustmentCur.PatNum).GetNameLF() + ", " + AdjustmentCur.AdjAmt.ToString("c")); } DialogResult = DialogResult.OK; }
private void FillGrid() { Recalls.Synch(PatNum); RecallList = Recalls.GetList(PatNum); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableRecallsPat", "Type"), 90); gridMain.Columns.Add(col); //col=new ODGridColumn(Lan.g("TableRecallsPat","Disabled"),60,HorizontalAlignment.Center); //gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRecallsPat", "PreviousDate"), 80); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRecallsPat", "Due Date"), 80); gridMain.Columns.Add(col); //col=new ODGridColumn(Lan.g("TableRecallsPat","Sched Date"),80); //gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRecallsPat", "Interval"), 70); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRecallsPat", "Status"), 80); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableRecallsPat", "Note"), 100); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; ODGridCell cell; IsPerio = false; butPerio.Text = Lan.g(this, "Set Perio"); string cellStr; for (int i = 0; i < RecallList.Count; i++) { if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallList[i].RecallTypeNum) { IsPerio = true; butPerio.Text = Lan.g(this, "Set Prophy"); } row = new ODGridRow(); row.Cells.Add(RecallTypes.GetDescription(RecallList[i].RecallTypeNum)); //if(RecallList[i].IsDisabled){ // row.Cells.Add("X"); //} //else{ // row.Cells.Add(""); //} if (RecallList[i].DatePrevious.Year < 1880) { row.Cells.Add(""); } else { row.Cells.Add(RecallList[i].DatePrevious.ToShortDateString()); } if (RecallList[i].DateDue.Year < 1880) { row.Cells.Add(""); } else { cell = new ODGridCell(RecallList[i].DateDue.ToShortDateString()); if (RecallList[i].DateDue < DateTime.Today) { cell.Bold = YN.Yes; cell.ColorText = Color.Firebrick; } row.Cells.Add(cell); } //row.Cells.Add("");//sched row.Cells.Add(RecallList[i].RecallInterval.ToString()); row.Cells.Add(DefC.GetValue(DefCat.RecallUnschedStatus, RecallList[i].RecallStatus)); cellStr = ""; if (RecallList[i].IsDisabled) { cellStr += Lan.g(this, "Disabled"); } if (RecallList[i].DisableUntilDate.Year > 1880) { if (cellStr != "") { cellStr += ", "; } cellStr += Lan.g(this, "Disabled until ") + RecallList[i].DisableUntilDate.ToShortDateString(); } if (RecallList[i].DisableUntilBalance > 0) { if (cellStr != "") { cellStr += ", "; } cellStr += Lan.g(this, "Disabled until balance ") + RecallList[i].DisableUntilBalance.ToString("c"); } if (RecallList[i].Note != "") { if (cellStr != "") { cellStr += ", "; } cellStr += RecallList[i].Note; } row.Cells.Add(cellStr); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }