예제 #1
0
        private void butEdit_Click(object sender, EventArgs e)
        {
            ODDataRow       gridRow = (ODDataRow)gridMain.Rows[gridMain.GetSelectedIndex()].Tag;
            FormRequestEdit FormR   = new FormRequestEdit();

            FormR.RequestId   = PIn.Long(gridRow["RequestId"]);
            FormR.IsAdminMode = isAdminMode;
            FormR.ShowDialog();
            //The user could have voted towards this request or done something else and we need to refresh the grid.
            //If the user had sorted the grid by a specific column, this call will lose their column sort and put it back to the default.
            FillGrid();
        }
예제 #2
0
        private void butEdit_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select a feature request.");
                return;
            }
            ODDataRow       gridRow = (ODDataRow)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
            FormRequestEdit FormR   = new FormRequestEdit();

            FormR.RequestId   = PIn.Long(gridRow["RequestId"]);
            FormR.IsAdminMode = isAdminMode;
            FormR.ShowDialog();
            //The user could have voted towards this request or done something else and we need to refresh the table and the grid.
            //If the user had sorted the grid by a specific column, this call will lose their column sort and put it back to the default.
            RefreshRequestTable();
            FillGrid();
        }
예제 #3
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            ODDataRow gridRow = (ODDataRow)gridMain.Rows[e.Row].Tag;

            if (IsSelectionMode)
            {
                SelectedFeatureNum = PIn.Long(gridRow["RequestId"]);
                DialogResult       = DialogResult.OK;
                return;
            }
            FormRequestEdit FormR = new FormRequestEdit();

            FormR.RequestId   = PIn.Long(gridRow["RequestId"]);
            FormR.IsAdminMode = isAdminMode;
            FormR.ShowDialog();
            //The user could have voted towards this request or done something else and we need to refresh the grid.
            //If the user had sorted the grid by a specific column, this call will lose their column sort and put it back to the default.
            FillGrid();
        }
예제 #4
0
 ///<summary>Only called when user clicks Delete or OK.  Not called repeatedly when adding discussions.</summary>
 private bool SaveChangesToDb(bool doDelete)
 {
     #region validation
     //validate---------------------------------------------------------------------------------------------------------
     int    difficulty = 0;
     int    myPoints   = 0;
     double myPledge   = 0;
     double bounty     = 0;
     if (!doDelete)
     {
         if (textDescription.Text == "")
         {
             MsgBox.Show(this, "Description cannot be blank.");
             return(false);
         }
         try{
             difficulty = int.Parse(textDifficulty.Text);
         }
         catch {
             MsgBox.Show(this, "Difficulty is invalid.");
             return(false);
         }
         if (difficulty < 0 || difficulty > 10)
         {
             MsgBox.Show(this, "Difficulty is invalid.");
             return(false);
         }
         if (IsAdminMode)
         {
             try {
                 bounty = PIn.Int(textBounty.Text);
             }
             catch {
                 MsgBox.Show(this, "Bounty is invalid.");
                 return(false);
             }
         }
         if (!IsAdminMode)
         {
             try{
                 myPoints = PIn.Int(textMyPoints.Text);                      //handles "" gracefully
             }
             catch {
                 MsgBox.Show(this, "Points is invalid.");
                 return(false);
             }
             if (difficulty < 0 || difficulty > 100)
             {
                 MsgBox.Show(this, "Points is invalid.");
                 return(false);
             }
             //still need to validate that they have enough points.
             if (textMyPledge.Text == "")
             {
                 myPledge = 0;
             }
             else
             {
                 try{
                     myPledge = double.Parse(textMyPledge.Text);
                 }
                 catch {
                     MsgBox.Show(this, "Pledge is invalid.");
                     return(false);
                 }
             }
             if (myPledge < 0)
             {
                 MsgBox.Show(this, "Pledge is invalid.");
                 return(false);
             }
         }
         double myPointsRemain = PIn.Double(textMyPointsRemain.Text);
         if (myPointsRemain < 0)
         {
             MsgBox.Show(this, "You have gone over your allotted points.");
             return(false);
         }
     }
     //end of validation------------------------------------------------------------------------------------------------
     #endregion validation
     //if user has made no changes, then exit out-------------------------------------------------------------------------
     bool changesMade = false;
     if (doDelete)
     {
         changesMade = true;
     }
     if (tableObj == null || tableObj.Rows.Count == 0)        //new
     {
         changesMade = true;
     }
     else
     {
         ODDataRow row = tableObj.Rows[0];
         if (textDescription.Text != row["Description"])
         {
             changesMade = true;
         }
         if (textDetail.Text != row["Detail"])
         {
             changesMade = true;
         }
         if (textDifficulty.Text != row["Difficulty"])
         {
             changesMade = true;
         }
         int approval = PIn.Int(row["Approval"]);
         if (comboApproval.SelectedIndex != approval)
         {
             changesMade = true;
         }
         if (groupMyVotes.Visible)
         {
             if (textMyPoints.Text != row["myPoints"] ||
                 checkIsCritical.Checked != PIn.Bool(row["IsCritical"]) ||
                 textMyPledge.Text != row["myPledge"])
             {
                 changesMade = true;
             }
         }
         try {
             if (textBounty.Text != row["Bounty"])
             {
                 changesMade = true;
             }
         }
         catch { }
     }
     if (!changesMade)
     {
         //temporarily show me which ones shortcutted out
         //MessageBox.Show("no changes made");
         return(true);
     }
     Cursor = Cursors.WaitCursor;
     //prepare the xml document to send--------------------------------------------------------------------------------------
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Indent      = true;
     settings.IndentChars = ("    ");
     StringBuilder strbuild = new StringBuilder();
     using (XmlWriter writer = XmlWriter.Create(strbuild, settings)){
         writer.WriteStartElement("FeatureRequestSubmitChanges");
         //regkey
         writer.WriteStartElement("RegistrationKey");
         writer.WriteString(PrefC.GetString(PrefName.RegistrationKey));
         writer.WriteEndElement();
         //requestId
         writer.WriteStartElement("RequestId");
         writer.WriteString(RequestId.ToString());                //this will be zero for a new request.
         writer.WriteEndElement();
         if (doDelete)
         {
             //delete
             writer.WriteStartElement("Delete");
             writer.WriteString("true");                    //all the other elements will be ignored.
             writer.WriteEndElement();
         }
         else
         {
             if (!textDescription.ReadOnly)
             {
                 //description
                 writer.WriteStartElement("Description");
                 writer.WriteString(textDescription.Text);
                 writer.WriteEndElement();
             }
             if (!textDetail.ReadOnly)
             {
                 //detail
                 writer.WriteStartElement("Detail");
                 writer.WriteString(textDetail.Text);
                 writer.WriteEndElement();
             }
             if (IsAdminMode ||
                 RequestId == 0)                         //This allows the initial difficulty of 5 to get saved.
             {
                 //difficulty
                 writer.WriteStartElement("Difficulty");
                 writer.WriteString(difficulty.ToString());
                 writer.WriteEndElement();
             }
             if (IsAdminMode)
             {
                 //Bounty
                 writer.WriteStartElement("Bounty");
                 writer.WriteString(bounty.ToString());
                 writer.WriteEndElement();
             }
             //approval
             writer.WriteStartElement("Approval");
             writer.WriteString(comboApproval.SelectedIndex.ToString());
             writer.WriteEndElement();
             if (!IsAdminMode)
             {
                 //mypoints
                 writer.WriteStartElement("MyPoints");
                 writer.WriteString(myPoints.ToString());
                 writer.WriteEndElement();
                 //iscritical
                 writer.WriteStartElement("IsCritical");
                 if (checkIsCritical.Checked)
                 {
                     writer.WriteString("1");
                 }
                 else
                 {
                     writer.WriteString("0");
                 }
                 writer.WriteEndElement();
                 //mypledge
                 writer.WriteStartElement("MyPledge");
                 writer.WriteString(myPledge.ToString("f2"));
                 writer.WriteEndElement();
             }
         }
         writer.WriteEndElement();
     }
                 #if DEBUG
     OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
                 #else
     OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
     updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
                 #endif
     //Send the message and get the result-------------------------------------------------------------------------------------
     string result = "";
     try {
         result = updateService.FeatureRequestSubmitChanges(strbuild.ToString());
     }
     catch (Exception ex) {
         Cursor = Cursors.Default;
         MessageBox.Show("Error: " + ex.Message);
         return(false);
     }
     //textConnectionMessage.Text=Lan.g(this,"Connection successful.");
     //Application.DoEvents();
     Cursor = Cursors.Default;
     //MessageBox.Show(result);
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(result);
     //Process errors------------------------------------------------------------------------------------------------------------
     XmlNode node = doc.SelectSingleNode("//Error");
     if (node != null)
     {
         //textConnectionMessage.Text=node.InnerText;
         MessageBox.Show(node.InnerText, "Error");
         return(false);
     }
     return(true);
 }
예제 #5
0
        private void GetOneFromServer()
        {
            //get a table with data
            Cursor = Cursors.WaitCursor;
            //prepare the xml document to send--------------------------------------------------------------------------------------
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, settings)){
                writer.WriteStartElement("FeatureRequestGetOne");
                writer.WriteStartElement("RegistrationKey");
                writer.WriteString(PrefC.GetString(PrefName.RegistrationKey));
                writer.WriteEndElement();
                writer.WriteStartElement("RequestId");
                writer.WriteString(RequestId.ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
                        #if DEBUG
            OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
                        #else
            OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
            updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
                        #endif
            //Send the message and get the result-------------------------------------------------------------------------------------
            string result = "";
            try {
                result = updateService.FeatureRequestGetOne(strbuild.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show("Error: " + ex.Message);
                return;
            }
            //textConnectionMessage.Text=Lan.g(this,"Connection successful.");
            //Application.DoEvents();
            Cursor = Cursors.Default;
            //MessageBox.Show(result);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(result);
            //Process errors------------------------------------------------------------------------------------------------------------
            XmlNode node = doc.SelectSingleNode("//Error");
            if (node != null)
            {
                //textConnectionMessage.Text=node.InnerText;
                MessageBox.Show(node.InnerText, "Error");
                DialogResult = DialogResult.Cancel;
                return;
            }
            //Process a valid return value------------------------------------------------------------------------------------------------
            node     = doc.SelectSingleNode("//ResultTable");
            tableObj = new ODDataTable(node.InnerXml);
            ODDataRow row = tableObj.Rows[0];
            textDescription.Text = row["Description"];
            string detail = row["Detail"];
            detail              = detail.Replace("\n", "\r\n");
            textDetail.Text     = detail;
            checkIsMine.Checked = PIn.Bool(row["isMine"]);
            textDifficulty.Text = row["Difficulty"];
            int approval = PIn.Int(row["Approval"]);
            if (IsAdminMode)
            {
                textSubmitter.Text = row["submitter"];
            }
            comboApproval.SelectedIndex = approval;
            //textApproval gets set automatically due to comboApproval_SelectedIndexChanged.
            if (!IsAdminMode && PIn.Bool(row["isMine"]))            //user editing their own request
            {
                if ((ApprovalEnum)approval == ApprovalEnum.New ||
                    (ApprovalEnum)approval == ApprovalEnum.NeedsClarification ||
                    (ApprovalEnum)approval == ApprovalEnum.NotARequest ||
                    (ApprovalEnum)approval == ApprovalEnum.Redundant ||
                    (ApprovalEnum)approval == ApprovalEnum.TooBroad)
                //so user not allowed to edit if Approved,AlreadyDone,Obsolete, or InProgress.
                {
                    textDescription.BackColor = Color.White;
                    textDescription.ReadOnly  = false;
                    textDetail.BackColor      = Color.White;
                    textDetail.ReadOnly       = false;
                    if ((ApprovalEnum)approval != ApprovalEnum.New)
                    {
                        butResubmit.Visible = true;
                    }
                    butDelete.Visible = true;
                }
            }
            if ((ApprovalEnum)approval != ApprovalEnum.Approved)
            {
                //only allowed to vote on Approved features.
                //All others should always have zero votes, except InProgress and Complete
                groupMyVotes.Visible = false;
            }
            if ((ApprovalEnum)approval == ApprovalEnum.Approved ||
                (ApprovalEnum)approval == ApprovalEnum.InProgress ||
                (ApprovalEnum)approval == ApprovalEnum.Complete)
            {            //even administrators should not be able to change things at this point
                textDescription.BackColor = colorDisabled;
                textDescription.ReadOnly  = true;
                textDetail.BackColor      = colorDisabled;
                textDetail.ReadOnly       = true;
            }
            myPointsUsed = PIn.Int(row["myPointsUsed"]);
            try {
                myPointsAllotted = PIn.Int(row["myPointsAllotted"]);
            }
            catch {
                myPointsAllotted = 100;
            }
            //textMyPointsRemain.Text=;this will be filled automatically when myPoints changes
            textMyPoints.Text = row["myPoints"];
            RecalcMyPoints();
            checkIsCritical.Checked = PIn.Bool(row["IsCritical"]);
            textMyPledge.Text       = row["myPledge"];
            textTotalPoints.Text    = row["totalPoints"];
            textTotalCritical.Text  = row["totalCritical"];
            textTotalPledged.Text   = row["totalPledged"];
            textWeight.Text         = row["Weight"];
            try {
                textBounty.Text = row["Bounty"];
            }
            catch { }
        }
예제 #6
0
 ///<summary>Used to sort feature requests for user to the top of the list.</summary>
 private int FeatureRequestSort(ODDataRow x, ODDataRow y)
 {
     if (isAdminMode)
     {
         //Sorting order
         //	1) Complete items to the bottom
         //	2) New features
         //	3) Status
         //	4) Weight
         //	5) Request ID if all else fails
         //Part 1
         int xIdx = _arrayApprovalEnumStrings.FindIndex(e => e == x["approval"].ToString());
         int yIdx = _arrayApprovalEnumStrings.FindIndex(e => e == y["approval"].ToString());
         if (xIdx != yIdx && (xIdx == 9 || yIdx == 9))         // 9=="complete"
         {
             return((xIdx == 9).CompareTo(yIdx == 9));
         }
         //Part 2
         if (xIdx != yIdx && (xIdx == 0 || yIdx == 0))         // 0="new"
         {
             return(-((xIdx == 0).CompareTo(yIdx == 0)));
         }
         //Part 3
         if (xIdx != yIdx)
         {
             return(xIdx.CompareTo(yIdx));
         }
         //Part 4
         if (x["Weight"].ToString() != y["Weight"].ToString())
         {
             return(-(PIn.Double(x["Weight"].ToString()).CompareTo(PIn.Double(y["Weight"].ToString()))));                   //Larger number of votes go to the top
         }
         //Part 5
         return(PIn.Long(x["RequestId"].ToString()).CompareTo(PIn.Long(y["RequestId"].ToString())));
     }
     else               //Typical sorting order for all users (non-HQ)
                        //Sorting order
                        //  1) Complete items to the bottom
                        //  2) Status - this enum is already ordered by importance.  e.g. NeedsClarification HAS to be towards the top (2nd in enum after new).
                        //  3) Personal requests to top
                        //  4) Personal requests sorted by weight
                        //  5) Group by "Mine"
                        //  6) Weight by magnitude
                        //  7) Request ID by magnitude
                        //Part 1
     {
         int xIdx = _arrayApprovalEnumStrings.FindIndex(e => e == x["approval"].ToString());
         int yIdx = _arrayApprovalEnumStrings.FindIndex(e => e == y["approval"].ToString());
         if (xIdx != yIdx && (xIdx == 9 || yIdx == 9))         // 9=="complete"
         {
             return((xIdx == 9).CompareTo(yIdx == 9));
         }
         //Part 2
         if (xIdx != yIdx)
         {
             return(xIdx.CompareTo(yIdx));
         }
         //Part 3
         bool xIsPersonal = false;
         bool yIsPersonal = false;
         xIsPersonal = x["personalVotes"].ToString() != "0" || x["personalCrit"].ToString() != "0" || x["personalPledged"].ToString() != "0";
         yIsPersonal = y["personalVotes"].ToString() != "0" || y["personalCrit"].ToString() != "0" || y["personalPledged"].ToString() != "0";
         if (xIsPersonal != yIsPersonal)
         {
             return(-xIsPersonal.CompareTo(yIsPersonal));                   //negative comparison to move personal items to top.
         }
         //Part 4
         if (xIsPersonal && yIsPersonal)
         {
             if (x["Weight"].ToString() != y["Weight"].ToString())
             {
                 return(-(PIn.Double(x["Weight"].ToString()).CompareTo(PIn.Double(y["Weight"].ToString()))));                       //Larger number of votes go to the top
             }
         }
         //Part 5; Sort "Mine" entries above non-"Mine" entries.  "Mine" means any feature that this office has submitted.
         if (x["isMine"].ToString() != y["isMine"].ToString())                    //One is the customer's, the other isn't.
         {
             return(-(x["isMine"].ToString().CompareTo(y["isMine"].ToString()))); //It will either be "" or X, and "X" goes to the top
         }
         //Part 6
         if (x["Weight"].ToString() != y["Weight"].ToString())
         {
             return(-(PIn.Double(x["Weight"].ToString()).CompareTo(PIn.Double(y["Weight"].ToString()))));                   //Larger number of votes go to the top
         }
         //Part 7
         return(PIn.Long(x["RequestId"].ToString()).CompareTo(PIn.Long(y["RequestId"].ToString())));
     }
 }