Logo Search packages:      
Sourcecode: yahtzeesharp version File versions  Download package

virtual void YahtzeeSharp::dlgOpen::OnBtnDeleteClicked ( object  sender,
System.EventArgs  e 
) [inline, protected, virtual]

a function to delete a game from the game data grid

Definition at line 230 of file dlgOpen.cs.

            {
                        try
                        {
                              string GameID = null;
                              string UserName = null;
                              TreeModel model;
                              TreeIter mIter; 
                              int i = 0;
                              
                              if(gvOpen.Selection.GetSelected (out model, out mIter)) 
                              {
                                    i = gvOpen.Model.GetPath(mIter).Indices[0]; 
                                    UserName = gvOpen.Model.GetValue(mIter, 1).ToString();
                                    GameID = gvOpen.Model.GetValue(mIter, 0).ToString();
                              } 
                              
                              MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Question,  ButtonsType.YesNo, "Are you sure you want to delete\n\r the game for " + UserName + "?", "DELETE?");
                              ResponseType result = (ResponseType)md.Run ();
                              if (result == ResponseType.Yes)
                  {
                        // remove the game from the game data file
                        DataRow dr = ds.Tables["dtGameData"].Rows[i];
                        dr.Delete();
                        
                        ds.WriteXml(SavePath + "GameData.xml");
                        
                        // remove the scorecard data from the saves folder
                        string SaveFile =  SavePath +  @"/saves/g" + GameID.ToString() + ".xml";
                        if(File.Exists(SaveFile))
                              File.Delete(SaveFile);
                              
                        gvOpen.Model = LoadTree();
                  }                       
                              md.Destroy();
                        
                              
                  }
                   catch(System.Exception ex)
                        {
                              frmError eForm = new frmError(ex.ToString());
                              eForm.Show();
                        }
            }

Generated by  Doxygen 1.6.0   Back to index