Esempio n. 1
0
        ///<summary>Should run AllFieldsAreValid() first. This is called from the parent form to retrieve the data that the user entered.  Returns an arraylist.  For most fields, the length of the arraylist will be 0 or 1.</summary>
        public ArrayList GetCurrentValues(int item)
        {
            ArrayList retVal = new ArrayList();

            if (multInputItems[item].ValueType == FieldValueType.Boolean)
            {
                if (((CheckBox)inputs[item]).Checked)
                {
                    retVal.Add(true);
                }
            }
            else if (multInputItems[item].ValueType == FieldValueType.Date)
            {
                retVal.Add(PIn.PDate(inputs[item].Text));
            }
            else if (multInputItems[item].ValueType == FieldValueType.Def)
            {
                ComboBoxMulti comboBox = (ComboBoxMulti)inputs[item];
                for (int j = 0; j < comboBox.SelectedIndices.Count; j++)
                {
                    retVal.Add(
                        DefB.Short[(int)multInputItems[item].DefCategory]
                        [(int)comboBox.SelectedIndices[j]].DefNum);
                }
            }
            else if (multInputItems[item].ValueType == FieldValueType.Enum)
            {
                ComboBoxMulti comboBox = (ComboBoxMulti)inputs[item];
                Type          eType    = Type.GetType("OpenDental." + multInputItems[item].EnumerationType.ToString());
                for (int j = 0; j < comboBox.SelectedIndices.Count; j++)
                {
                    retVal.Add(
                        (int)(Enum.Parse(eType, Enum.GetNames(eType)[(int)comboBox.SelectedIndices[j]])));
                }
            }
            else if (multInputItems[item].ValueType == FieldValueType.Integer)
            {
                retVal.Add(PIn.PInt(inputs[item].Text));
            }
            else if (multInputItems[item].ValueType == FieldValueType.Number)
            {
                retVal.Add(PIn.PDouble(inputs[item].Text));
            }
            else if (multInputItems[item].ValueType == FieldValueType.String)
            {
                if (inputs[item].Text != "")
                {
                    //the text is first stripped of any ?'s
                    retVal.Add(Regex.Replace(inputs[item].Text, @"\?", ""));
                }
            }
            else if (multInputItems[item].ValueType == FieldValueType.YesNoUnknown)
            {
                retVal.Add(((ContrYN)inputs[item]).CurrentValue);
            }
            //MessageBox.Show(multInputItems[1].CurrentValues.Count.ToString());
            return(retVal);
        }
Esempio n. 2
0
        ///<summary></summary>
        public static string RunningSum(string groupBy, string addValue)
        {
            double num = PIn.PDouble(addValue);

            if (groupByVal == null || groupBy != groupByVal)        //if new or changed group
            {
                runningSum = 0;
            }
            groupByVal  = groupBy;
            runningSum += num;
            return(runningSum.ToString("F"));
        }
Esempio n. 3
0
        ///<summary>Once a dataTable has been set, this method can be run to get the summary value of this field.  It will still need to be formatted. It loops through all records to get this value.  This will be changed soon to refer to the ReportObject rather than the dataTable field when summarizing.</summary>
        public double GetSummaryValue(DataTable dataTable, int col)
        {
            //if(SummarizedField.FieldKind!=FieldDefKind.DataTableField){
            //	return 0;
            //}
            double retVal = 0;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                if (Operation == SummaryOperation.Sum)
                {
                    retVal += PIn.PDouble(dataTable.Rows[i][col].ToString());
                    //PIn.PDouble(Report.ReportTable.Rows[i][Report.DataFields.IndexOf(fieldObject.DataSource.Name)].ToString())
                }
                else if (Operation == SummaryOperation.Count)
                {
                    retVal++;
                }
            }
            return(retVal);
        }
Esempio n. 4
0
        ///<summary>Prints some rows of the details section at the specified x and y position on the page.  The math to decide how many rows to print is done ahead of time.  The number of rows printed so far is kept global so that it can be used in calculating the layout of this section.</summary>
        private void PrintDetailsSection(Graphics g, Section section, int xPos, int yPos, int rowsToPrint)
        {
            ReportObject textObject;
            ReportObject fieldObject;
            //LineObject lineObject;
            //BoxObject boxObject;
            StringFormat strFormat;            //used each time text is drawn to handle alignment issues
            string       rawText         = ""; //the raw text for a given field as taken from the database
            string       displayText     = ""; //The formatted text to print
            string       prevDisplayText = ""; //The formatted text of the previous row. Used to test suppress dupl.

            //loop through each row in the table
            for (int i = rowsPrinted; i < rowsPrinted + rowsToPrint; i++)
            {
                foreach (ReportObject reportObject in MyReport.ReportObjects)
                {
                    //todo later: check for lines and boxes that span multiple sections.
                    if (reportObject.SectionName != section.Name)
                    {
                        //skip any reportObjects that are not in this section
                        continue;
                    }
                    if (reportObject.ObjectKind == ReportObjectKind.TextObject)
                    {
                        //not typical to print textobject in details section, but allowed
                        textObject = reportObject;
                        strFormat  = ReportObject.GetStringFormat(textObject.TextAlign);
                        RectangleF layoutRect = new RectangleF(xPos + textObject.Location.X
                                                               , yPos + textObject.Location.Y
                                                               , textObject.Size.Width, textObject.Size.Height);
                        g.DrawString(textObject.StaticText, textObject.Font
                                     , new SolidBrush(textObject.ForeColor), layoutRect, strFormat);
                    }
                    else if (reportObject.ObjectKind == ReportObjectKind.FieldObject)
                    {
                        fieldObject = reportObject;
                        strFormat   = ReportObject.GetStringFormat(fieldObject.TextAlign);
                        RectangleF layoutRect = new RectangleF(xPos + fieldObject.Location.X, yPos + fieldObject.Location.Y, fieldObject.Size.Width, fieldObject.Size.Height);
                        if (fieldObject.FieldKind == FieldDefKind.DataTableField)
                        {
                            rawText = MyReport.ReportTable.Rows
                                      [i][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString();
                            displayText = rawText;
                            if (fieldObject.ValueType == FieldValueType.Age)
                            {
                                displayText = Shared.AgeToString(Shared.DateToAge(PIn.PDate(MyReport.ReportTable.Rows[i][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString())));                              //(fieldObject.FormatString);
                            }
                            else if (fieldObject.ValueType == FieldValueType.Boolean)
                            {
                                displayText = PIn.PBool(MyReport.ReportTable.Rows[i][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString();                              //(fieldObject.FormatString);
                                if (i > 0 && fieldObject.SuppressIfDuplicate)
                                {
                                    prevDisplayText = PIn.PBool(MyReport.ReportTable.Rows[i - 1][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString();
                                }
                            }
                            else if (fieldObject.ValueType == FieldValueType.Date)
                            {
                                displayText = PIn.PDateT(MyReport.ReportTable.Rows[i][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString(fieldObject.FormatString);
                                if (i > 0 && fieldObject.SuppressIfDuplicate)
                                {
                                    prevDisplayText = PIn.PDateT(MyReport.ReportTable.Rows[i - 1][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString(fieldObject.FormatString);
                                }
                            }
                            else if (fieldObject.ValueType == FieldValueType.Integer)
                            {
                                displayText = PIn.PInt(MyReport.ReportTable.Rows[i][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString(fieldObject.FormatString);
                                if (i > 0 && fieldObject.SuppressIfDuplicate)
                                {
                                    prevDisplayText = PIn.PInt(MyReport.ReportTable.Rows[i - 1][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString(fieldObject.FormatString);
                                }
                            }
                            else if (fieldObject.ValueType == FieldValueType.Number)
                            {
                                displayText = PIn.PDouble(MyReport.ReportTable.Rows[i][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString(fieldObject.FormatString);
                                if (i > 0 && fieldObject.SuppressIfDuplicate)
                                {
                                    prevDisplayText = PIn.PDouble(MyReport.ReportTable.Rows[i - 1][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString()).ToString(fieldObject.FormatString);
                                }
                            }
                            else if (fieldObject.ValueType == FieldValueType.String)
                            {
                                displayText = rawText;
                                if (i > 0 && fieldObject.SuppressIfDuplicate)
                                {
                                    prevDisplayText = MyReport.ReportTable.Rows[i - 1][MyReport.DataFields.IndexOf(fieldObject.DataField)].ToString();
                                }
                            }
                            //suppress if duplicate:
                            if (i > 0 && fieldObject.SuppressIfDuplicate && displayText == prevDisplayText)
                            {
                                displayText = "";
                            }
                        }
                        else if (fieldObject.FieldKind == FieldDefKind.FormulaField)
                        {
                            //can't do formulas yet
                        }
                        else if (fieldObject.FieldKind == FieldDefKind.SpecialField)
                        {
                        }
                        else if (fieldObject.FieldKind == FieldDefKind.SummaryField)
                        {
                        }
                        g.DrawString(displayText, fieldObject.Font
                                     , new SolidBrush(fieldObject.ForeColor), layoutRect, strFormat);
                    }
                    //incomplete: else if lines
                    //incomplete: else if boxes.
                }        //foreach reportObject
                yPos += section.Height;
            }            //for i rows
            rowsPrinted += rowsToPrint;
        }
        /// <summary>
        ///  Creates an object of type <typeparamref name="T"/> based on a <see cref="DataRow"/>.
        ///  The fields of the <see cref="DataRow"/> can be either of the corresponding type, or of the
        ///  <see cref="String"/> type. In the case of a <see cref="String"/>, conversion will be done using
        ///  the <see cref="PIn"/> data class.
        /// </summary>
        /// <param name="row">
        ///  A <see cref="DataRow"/> containing rows corresponding to objects of type <typeparamref name="T"/>.
        /// </param>
        /// <returns>
        ///  An objects of type <typeparamref name="T"/>.
        /// </returns>
        /// <remarks>
        ///  <para>
        ///  This method is for compatibility purposes only.
        ///  </para>
        ///  <para>
        ///  This method needs to be tested.
        ///  </para>
        /// </remarks>
        public static T CreateObject(DataRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }

            Collection <T>             values     = new Collection <T>();
            Collection <DataFieldInfo> dataFields = DataObjectInfo <T> .GetDataFields();

            T value = new T();

            foreach (DataFieldInfo dataField in dataFields)
            {
                if (dataField.WriteOnly)
                {
                    continue;
                }

                // Retrieve the value and its type, both in the database and code.
                object dataValue = row[dataField.DatabaseName];
                Type   dataType  = row.Table.Columns[dataField.DatabaseName].DataType;
                Type   codeType  = dataField.Field.FieldType;

                if (codeType != typeof(string) && dataType == typeof(string))
                {
                    // If the type in the dataset is "string", but the type in the code
                    // object isn't "string", we use the PIn class.
                    if (dataType == typeof(Bitmap))
                    {
                        dataValue = PIn.PBitmap((string)dataValue);
                    }
                    else if (dataType == typeof(bool))
                    {
                        dataValue = PIn.PBool((string)dataValue);
                    }
                    else if (dataType == typeof(Byte))
                    {
                        dataValue = PIn.PByte((string)dataValue);
                    }
                    else if (dataType == typeof(DateTime))
                    {
                        // NOTE: Is there any difference between PIn.PDate and PIn.PDateT?
                        dataValue = PIn.PDate((string)dataValue);
                    }
                    else if (dataType == typeof(double))
                    {
                        dataValue = PIn.PDouble((string)dataValue);
                    }
                    else if (dataType == typeof(float))
                    {
                        dataValue = PIn.PFloat((string)dataValue);
                    }
                    else if (dataType == typeof(int))
                    {
                        dataValue = PIn.PInt((string)dataValue);
                    }
                    else
                    {
                        // NOTE: Support for "Sound" is not here yet. Maybe it should be exported
                        // to a byte[] type and then saved, don't know.
                        throw new NotSupportedException(Resources.DataTypeNotSupportedByPIn);
                    }
                }
                else
                {
                    // The object is stored in it's "true" type in the DataSet as well (no conversions to
                    // string types have been done). We can, normally, directly use it, except for a couple
                    // of special cases.

                    if (codeType == typeof(bool))
                    {
                        // Booleans are sometimes stored as TINYINT(3), to enable conversion to
                        // Enums if required. Hence, we need to do an explicit conversion.
                        dataField.Field.SetValue(value, Convert.ToBoolean(dataValue));
                    }
                    else if (codeType == typeof(DateTime))
                    {
                        // DateTime fields can have various minimum or default values depending on
                        // the database type. In MySql, for example, it is 00-00-00, which is not supported
                        // by .NET. So for now, we catch a cast exception and set it to DateTime.MinValue.
                        try {
                            dataField.Field.SetValue(value, DateTime.Parse(dataValue.ToString()));
                        }
                        catch {
                            dataField.Field.SetValue(value, DateTime.MinValue);
                        }
                    }
                    else
                    {
                        dataField.Field.SetValue(value, dataValue);
                    }
                }
            }

            return(value);
        }
        /*
         * ///<summary></summary>
         * public void AddInputItem(string myPromptingText,ParamValueType myValueType,ArrayList myCurrentValues,EnumType myEnumerationType,DefCat myDefCategory,ReportFKType myFKType){
         *      MultInput2.AddInputItem(myPromptingText,myValueType,myCurrentValues,myEnumerationType,myDefCategory,myFKType);
         * }*/

        /*
         * ///<summary>After this form closes, use this method to retrieve the data that the user entered.</summary>
         * public ArrayList GetCurrentValues(int itemIndex){
         *      return MultInput2.GetCurrentValues(itemIndex);
         * }*/

        //private void contrParamInput_SizeChanged(object sender, System.EventArgs e) {
        //	Height=contrParamInput.Bottom+90;
        //	Refresh();//this should trigger another layout
        //}

        private void butOK_Click(object sender, System.EventArgs e)
        {
            //make sure all entries are valid
            for (int i = 0; i < Parameters.Count; i++)
            {
                if (Parameters[i].ValueType == ParamValueType.Date)
                {
                    if (((ValidDate)inputs[i]).errorProvider1.GetError(inputs[i]) != "")
                    {
                        MessageBox.Show("Please fix data entry errors first.");
                        return;
                    }
                }
                if (Parameters[i].ValueType == ParamValueType.Integer)
                {
                    if (((ValidNumber)inputs[i]).errorProvider1.GetError(inputs[i]) != "")
                    {
                        MessageBox.Show("Please fix data entry errors first.");
                        return;
                    }
                }
                if (Parameters[i].ValueType == ParamValueType.Number)
                {
                    if (((ValidDouble)inputs[i]).errorProvider1.GetError(inputs[i]) != "")
                    {
                        MessageBox.Show("Please fix data entry errors first.");
                        return;
                    }
                }
            }
            //then fill the current values and output value.  For most fields, the length of CurrentValues will be 0 or 1.
            for (int i = 0; i < Parameters.Count; i++)
            {
                Parameters[i].CurrentValues = new ArrayList();
                if (Parameters[i].ValueType == ParamValueType.Boolean)
                {
                    if (((CheckBox)inputs[i]).Checked)
                    {
                        Parameters[i].CurrentValues.Add(true);
                    }
                }
                else if (Parameters[i].ValueType == ParamValueType.Date)
                {
                    Parameters[i].CurrentValues.Add(PIn.PDate(inputs[i].Text));
                }

                /*else if(Parameters[i].ValueType==ParamValueType.Def){
                 *      ComboBoxMulti comboBox=(ComboBoxMulti)inputs[i];
                 *      for(int j=0;j<comboBox.SelectedIndices.Count;j++){
                 *              retVal.Add(
                 *                      Defs.Short[(int)Parameters[i].DefCategory]
                 *                      [(int)comboBox.SelectedIndices[j]].DefNum);
                 *      }
                 * }*/
                else if (Parameters[i].ValueType == ParamValueType.Enum)
                {
                    ComboBoxMulti comboBox = (ComboBoxMulti)inputs[i];
                    Type          eType    = Type.GetType("ODR." + Parameters[i].EnumerationType.ToString());
                    for (int j = 0; j < comboBox.SelectedIndices.Count; j++)
                    {
                        Parameters[i].CurrentValues.Add((int)(Enum.Parse(eType, Enum.GetNames(eType)[(int)comboBox.SelectedIndices[j]])));
                    }
                }
                else if (Parameters[i].ValueType == ParamValueType.Integer)
                {
                    Parameters[i].CurrentValues.Add(PIn.PInt(inputs[i].Text));
                }
                else if (Parameters[i].ValueType == ParamValueType.Number)
                {
                    Parameters[i].CurrentValues.Add(PIn.PDouble(inputs[i].Text));
                }
                else if (Parameters[i].ValueType == ParamValueType.String)
                {
                    if (inputs[i].Text != "")
                    {
                        //the text is first stripped of any ?'s
                        Parameters[i].CurrentValues.Add(inputs[i].Text.Replace("?", ""));                       //Regex.Replace(inputs[i].Text,@"\?",""));
                    }
                }
                Parameters[i].FillOutputValue();
                //MessageBox.Show(multInputItems[1].CurrentValues.Count.ToString());
                //return retVal;
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 7
0
        ///<summary>Returns the number of plans updated.</summary>
        private static int ProcessTrojanPlan(string trojanPlan)
        {
            //MessageBox.Show(trojanPlan);
            string[] lines = trojanPlan.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            //MessageBox.Show(lines[0]);
            //MessageBox.Show(lines.Length.ToString());
            string line;

            string[] fields;
            int      percent;

            string[]  splitField;                   //if a field is a sentence with more than one word, we can split it for analysis
            InsPlan   plan         = new InsPlan(); //many fields will be absent.  This is a conglomerate.
            Carrier   carrier      = new Carrier();
            ArrayList benefitList  = new ArrayList();
            bool      usesAnnivers = false;
            Benefit   ben;

            for (int i = 0; i < lines.Length; i++)
            {
                line   = lines[i];
                fields = line.Split(new char[] { '\t' });
                if (fields.Length != 3)
                {
                    continue;
                }
                //remove any trailing or leading spaces:
                fields[0] = fields[0].Trim();
                fields[1] = fields[1].Trim();
                fields[2] = fields[2].Trim();
                if (fields[2] == "")
                {
                    continue;
                }
                else                 //as long as there is data, add it to the notes
                {
                    if (plan.BenefitNotes != "")
                    {
                        plan.BenefitNotes += "\r\n";
                    }
                    plan.BenefitNotes += fields[1] + ": " + fields[2];
                }
                switch (fields[0])
                {
                //default://for all rows that are not handled below
                case "TROJANID":
                    plan.TrojanID = fields[2];
                    break;

                case "ENAME":
                    plan.EmployerNum = Employers.GetEmployerNum(fields[2]);
                    break;

                case "PLANDESC":
                    plan.GroupName = fields[2];
                    break;

                case "ELIGPHONE":
                    carrier.Phone = fields[2];
                    break;

                case "POLICYNO":
                    plan.GroupNum = fields[2];
                    break;

                case "ECLAIMS":
                    if (fields[2] == "YES")                           //accepts eclaims
                    {
                        carrier.NoSendElect = false;
                    }
                    else
                    {
                        carrier.NoSendElect = true;
                    }
                    break;

                case "PAYERID":
                    carrier.ElectID = fields[2];
                    break;

                case "MAILTO":
                    carrier.CarrierName = fields[2];
                    break;

                case "MAILTOST":
                    carrier.Address = fields[2];
                    break;

                case "MAILCITYONLY":
                    carrier.City = fields[2];
                    break;

                case "MAILSTATEONLY":
                    carrier.State = fields[2];
                    break;

                case "MAILZIPONLY":
                    carrier.Zip = fields[2];
                    break;

                case "PLANMAX":                        //eg $3000 per person per year
                    if (!fields[2].StartsWith("$"))
                    {
                        break;
                    }
                    fields[2] = fields[2].Remove(0, 1);
                    fields[2] = fields[2].Split(new char[] { ' ' })[0];
                    if (CovCatB.ListShort.Length > 0)
                    {
                        ben             = new Benefit();
                        ben.BenefitType = InsBenefitType.Limitations;
                        ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
                        ben.MonetaryAmt = PIn.PDouble(fields[2]);
                        ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                        benefitList.Add(ben.Copy());
                    }
                    break;

                case "PLANYR":                        //eg Calendar year or Anniversary year
                    if (fields[2] != "Calendar year")
                    {
                        usesAnnivers = true;
                        //MessageBox.Show("Warning.  Plan uses Anniversary year rather than Calendar year.  Please verify the Plan Start Date.");
                    }
                    break;

                case "DEDUCT":                        //eg There is no deductible
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Deductible;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    if (!fields[2].StartsWith("$"))
                    {
                        ben.MonetaryAmt = 0;
                    }
                    else
                    {
                        fields[2]       = fields[2].Remove(0, 1);
                        fields[2]       = fields[2].Split(new char[] { ' ' })[0];
                        ben.MonetaryAmt = PIn.PDouble(fields[2]);
                    }
                    benefitList.Add(ben.Copy());
                    break;

                case "PREV":                        //eg 100%
                    splitField = fields[2].Split(new char[] { ' ' });
                    if (splitField.Length == 0 || !splitField[0].EndsWith("%"))
                    {
                        break;
                    }
                    splitField[0] = splitField[0].Remove(splitField[0].Length - 1, 1);                       //remove %
                    percent       = PIn.PInt(splitField[0]);
                    if (percent < 0 || percent > 100)
                    {
                        break;
                    }
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    break;

                case "BASIC":
                    splitField = fields[2].Split(new char[] { ' ' });
                    if (splitField.Length == 0 || !splitField[0].EndsWith("%"))
                    {
                        break;
                    }
                    splitField[0] = splitField[0].Remove(splitField[0].Length - 1, 1);                       //remove %
                    percent       = PIn.PInt(splitField[0]);
                    if (percent < 0 || percent > 100)
                    {
                        break;
                    }
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Restorative).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Endodontics).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Periodontics).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    break;

                case "MAJOR":
                    splitField = fields[2].Split(new char[] { ' ' });
                    if (splitField.Length == 0 || !splitField[0].EndsWith("%"))
                    {
                        break;
                    }
                    splitField[0] = splitField[0].Remove(splitField[0].Length - 1, 1);                       //remove %
                    percent       = PIn.PInt(splitField[0]);
                    if (percent < 0 || percent > 100)
                    {
                        break;
                    }
                    ben             = new Benefit();
                    ben.BenefitType = InsBenefitType.Percentage;
                    ben.CovCatNum   = CovCats.GetForEbenCat(EbenefitCategory.Prosthodontics).CovCatNum;
                    ben.Percent     = percent;
                    ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                    benefitList.Add(ben.Copy());
                    //does prosthodontics include crowns?
                    break;
                }        //switch
            }            //for
            //now, save this all to the database.
            //carrier
            if (carrier.CarrierName == null || carrier.CarrierName == "")
            {
                //if, for some reason, carrier is absent from the file, we can't do a thing with it.
                return(0);
            }
            //Carriers.Cur=carrier;
            Carriers.GetCurSame(carrier);
            //set calendar vs serviceyear
            if (usesAnnivers)
            {
                for (int i = 0; i < benefitList.Count; i++)
                {
                    ((Benefit)benefitList[i]).TimePeriod = BenefitTimePeriod.ServiceYear;
                }
            }
            //plan
            plan.CarrierNum = carrier.CarrierNum;
            string    command = "SELECT PlanNum FROM insplan WHERE TrojanID='" + POut.PString(plan.TrojanID) + "'";
            DataTable table   = General.GetTable(command);
            int       planNum;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                planNum = PIn.PInt(table.Rows[i][0].ToString());
                //update plan
                command = "UPDATE insplan SET "
                          + "EmployerNum='" + POut.PInt(plan.EmployerNum) + "', "
                          + "GroupName='" + POut.PString(plan.GroupName) + "', "
                          + "GroupNum='" + POut.PString(plan.GroupNum) + "', "
                          + "CarrierNum='" + POut.PInt(plan.CarrierNum) + "', "
                          + "BenefitNotes='" + POut.PString(plan.BenefitNotes) + "' "
                          + "WHERE PlanNum=" + POut.PInt(planNum);
                General.NonQ(command);
                //clear benefits
                command = "DELETE FROM benefit WHERE PlanNum=" + POut.PInt(planNum);
                General.NonQ(command);
                //benefitList
                for (int j = 0; j < benefitList.Count; j++)
                {
                    ((Benefit)benefitList[j]).PlanNum = planNum;
                    Benefits.Insert((Benefit)benefitList[j]);
                }
                InsPlans.ComputeEstimatesForPlan(planNum);
            }
            return(table.Rows.Count);
            //MessageBox.Show(plan.BenefitNotes);
        }