コード例 #1
0
        private void buttonAddViews_Click(object sender, EventArgs e)
        {
            try
            {
                AddNewViewSheetsRequestData requestData = CreateRequestData();

                if (requestData != null)
                {
                    AddNewViewSheetsRequestHandler handler = new AddNewViewSheetsRequestHandler(requestData);
                    ExternalEvent exEvent = ExternalEvent.Create(handler);
                    exEvent.Raise();


                    this.Close();
                    this.Dispose();
                }
                else
                {
                    TaskDialog.Show("Info", "requestData == null");
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #2
0
 public AddNewViewSheetsRequestHandler(AddNewViewSheetsRequestData requestData)
 {
     this.requestData = requestData;
 }
コード例 #3
0
        private AddNewViewSheetsRequestData CreateRequestData()
        {
            AddNewViewSheetsRequestData requestData = new AddNewViewSheetsRequestData();


            for (int r = 0; r < this.dataGridViewSheets.Rows.Count; r++)
            {
                DataGridViewRow curViewRow = this.dataGridViewSheets.Rows[r];

                string[] mainItems = new string[5];
                for (int c = 0; c < 5; c++)
                {
                    DataGridViewCell curCell = curViewRow.Cells[c] as DataGridViewCell;
                    if (curCell.Value != null)
                    {
                        mainItems[c] = curCell.Value.ToString();
                    }
                    else
                    {
                        TaskDialog.Show("Error", "Value is null for cell: " + c.ToString());
                        mainItems[c] = "";
                    }
                }

                requestData.viewSheetsInfo.Add(new Tuple <string, string, string, string, string>(mainItems[0], mainItems[1], mainItems[2], mainItems[3], mainItems[4]));
            }


            if (requestData != null)
            {
                HashSet <string> allSheetsNumbers = new HashSet <string>();
                HashSet <string> allSheetsNames   = new HashSet <string>();
                HashSet <string> allViewsNames    = new HashSet <string>();

                for (int m = 0; m < requestData.viewSheetsInfo.Count; m++)
                {
                    Tuple <string, string, string, string, string> curViewSheetInfo = requestData.viewSheetsInfo[m];

                    if (allSheetsNames.Contains(curViewSheetInfo.Item1))
                    {
                        TaskDialog.Show("Error", "More than one sheet has number: " + curViewSheetInfo.Item1 + " please rename");
                        return(null);
                    }
                    else
                    {
                        allSheetsNames.Add(curViewSheetInfo.Item1);
                    }

                    if (allSheetsNames.Contains(curViewSheetInfo.Item2))
                    {
                        TaskDialog.Show("Error", "More than one sheet has name: " + curViewSheetInfo.Item2 + " please rename");
                        return(null);
                    }
                    else
                    {
                        allSheetsNames.Add(curViewSheetInfo.Item2);
                    }
                }
            }

            return(requestData);
        }