Exemple #1
0
 private void SaveSignature()
 {
     if (SigChanged)
     {
         string keyData = GetSignatureKey();
         CommlogCur.Signature  = signatureBoxWrapper.GetSignature(keyData);
         CommlogCur.SigIsTopaz = signatureBoxWrapper.GetSigIsTopaz();
     }
 }
        private bool TryToSaveData()
        {
            if (!butOK.Enabled)             //if the OK button is not enabled, user does not have permission.
            {
                return(true);
            }
            if (textShowInTerminal.errorProvider1.GetError(textShowInTerminal) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            DateTime dateTimeSheet = DateTime.MinValue;

            try{
                dateTimeSheet = DateTime.Parse(textDateTime.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            SheetCur.DateTimeSheet  = dateTimeSheet;
            SheetCur.Description    = textDescription.Text;
            SheetCur.InternalNote   = textNote.Text;
            SheetCur.ShowInTerminal = PIn.Byte(textShowInTerminal.Text);
            FillFieldsFromControls();            //But SheetNums will still be 0 for a new sheet.
            bool isNew = SheetCur.IsNew;

            if (isNew)
            {
                Sheets.Insert(SheetCur);
            }
            else
            {
                Sheets.Update(SheetCur);
            }
            List <SheetField> drawingList = new List <SheetField>();

            foreach (SheetField fld in SheetCur.SheetFields)
            {
                if (fld.FieldType == SheetFieldType.SigBox)
                {
                    continue;                    //done in a separate step
                }
                if (fld.FieldType == SheetFieldType.Image ||
                    fld.FieldType == SheetFieldType.Rectangle ||
                    fld.FieldType == SheetFieldType.Line)
                {
                    if (!fld.IsNew)
                    {
                        continue;                        //it only saves them when the sheet is first created because user can't edit anyway.
                    }
                }
                fld.SheetNum = SheetCur.SheetNum;              //whether or not isnew
                if (fld.FieldType == SheetFieldType.Drawing)
                {
                    fld.IsNew = true;
                    drawingList.Add(fld);
                }
                else
                {
                    if (fld.IsNew)
                    {
                        SheetFields.Insert(fld);
                    }
                    else
                    {
                        SheetFields.Update(fld);
                    }
                }
            }
            if (drawingsAltered)
            {
                //drawings get saved as a group rather than with the other fields.
                SheetFields.SetDrawings(drawingList, SheetCur.SheetNum);
            }
            if (isNew)
            {
                Sheets.SaveParameters(SheetCur);
            }
            //SigBoxes must come after ALL other types in order for the keyData to be in the right order.
            SheetField field;

            foreach (Control control in panelMain.Controls)
            {
                if (control.GetType() != typeof(OpenDental.UI.SignatureBoxWrapper))
                {
                    continue;
                }
                if (control.Tag == null)
                {
                    continue;
                }
                field = (SheetField)control.Tag;
                OpenDental.UI.SignatureBoxWrapper sigBox = (OpenDental.UI.SignatureBoxWrapper)control;
                if (sigBox.GetSigChanged())
                {
                    //refresh the fields so they are in the correct order
                    SheetFields.GetFieldsAndParameters(SheetCur);
                    bool   sigIsTopaz = sigBox.GetSigIsTopaz();
                    string keyData    = Sheets.GetSignatureKey(SheetCur);
                    string signature  = sigBox.GetSignature(keyData);
                    field.FieldValue = "";
                    if (signature != "")
                    {
                        if (sigIsTopaz)
                        {
                            field.FieldValue += "1";
                        }
                        else
                        {
                            field.FieldValue += "0";
                        }
                        field.FieldValue += signature;
                    }
                }
                field.SheetNum = SheetCur.SheetNum; //whether or not isnew
                if (isNew)                          //is this really testing the proper object?
                {
                    SheetFields.Insert(field);
                }
                else
                {
                    SheetFields.Update(field);
                }
            }
            return(true);
        }