private void acceptChangesButton_Click(object sender, EventArgs e)
        {
            foreach (TabPage currentListBoxItem in tabControlPolls.TabPages)
            {
                var _newCommonRow = pollsDataSet.POLLSCOMMON.NewPOLLSCOMMONRow();
                _newCommonRow.NUM = Convert.ToDecimal(maskedTextBoxNumber.Text);
                _newCommonRow.RDAY = dateTimePicker.Value;
                _newCommonRow.TYPE = currentListBoxItem.Name;
                _newCommonRow.FILIAL = Convert.ToDecimal(comboBoxRegion.SelectedValue);
                _newCommonRow.BRANCH = Convert.ToDecimal(comboBoxStructUnite.SelectedValue);
                _newCommonRow.RKC = Convert.ToDecimal(comboBoxRKC.SelectedValue);
                _newCommonRow.SEX = comboBoxSex.SelectedValue.ToString();
                _newCommonRow.AGE = numericUpDown1.Value;
                _newCommonRow.LASTCHANGE = DateTime.Now;
                _newCommonRow.REFUSER = _user.Id_user;

                if(
                currentListBoxItem.Name == "TRANS")
                {
                    //var panelTrans = new Panel();
                    //_transComboBox=new ComponentsComboBox();
                    //_transComboBox.label.Text = "Тип перевода:";
                    //_transComboBox.comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                    //var transTypeBinding = new BindingSource();
                    //transTypeBinding.DataSource = pollsDataSet;
                    //transTypeBinding.DataMember = "TransTypes";
                    //_transComboBox.comboBox.DataSource = transTypeBinding;
                    //_transComboBox.comboBox.DisplayMember = "NameTransType";
                    //_transComboBox.comboBox.ValueMember = "IdTransType";
                    _newCommonRow.TYPETRANS = _transComboBox.comboBox.SelectedValue.ToString();
                }
                var typesPoll = new TYPEPOLLSTableAdapter();
                typesPoll.Fill(pollsDataSet.TYPEPOLLS);
                var splitQI = (SplitContainer) currentListBoxItem.Controls["SplitQI"];
                var qPollRadioTable = (PollRadioTable) splitQI.Panel1.Controls["QTABLE"];
                var iPollRadioTable = (PollRadioTable) splitQI.Panel2.Controls["ITABLE"];
                pollsDataSet.POLLSCOMMON.AddPOLLSCOMMONRow(_newCommonRow);
                var pollsCommonAdapter = new POLLSCOMMONTableAdapter();
                pollsCommonAdapter.Update(pollsDataSet.POLLSCOMMON);
                pollsDataSet.POLLSCOMMON.AcceptChanges();

                //c => c.TYPE == currentListBoxItem.Name/*"TYPE="+currentListBoxItem.Name*/)
                foreach (PollsDataSet.TYPEPOLLSRow curCrit in pollsDataSet.TYPEPOLLS.Where(c=>c.TYPE==currentListBoxItem.Name))
                {
                    var qCurRadioRow = (GroupeRow)qPollRadioTable.tableLayoutPanel.Controls["R" + curCrit.IDQUEST];
                    var iCurRadioRow = (GroupeRow)iPollRadioTable.tableLayoutPanel.Controls["R" + curCrit.IDQUEST];
                    int markQ = 3;
                    int markI = 3;
                    for (int i = 1; i <= 5; i++)
                    {
                        var rbQ = (RadioButton) qCurRadioRow.tableLayoutPanel.Controls["Mark" + i];
                        if (rbQ.Checked)
                            markQ = i;
                        var rbI = (RadioButton)iCurRadioRow.tableLayoutPanel.Controls["Mark" + i];
                        if (rbI.Checked)
                            markI = i;

                    }
                    var newPollsDataRow = pollsDataSet.POLLSDATA.NewPOLLSDATARow();
                    newPollsDataRow.IDQUEST = curCrit.IDQUEST;
                    newPollsDataRow.BRANCH = _newCommonRow.BRANCH;
                    newPollsDataRow.RKC = _newCommonRow.RKC;
                    newPollsDataRow.NUM = _newCommonRow.NUM;
                    newPollsDataRow.RDAY = _newCommonRow.RDAY;
                    newPollsDataRow.TYPE = _newCommonRow.TYPE;
                    newPollsDataRow.QUALITY = markQ;
                    newPollsDataRow.IMPOTANCE = markI;
                    pollsDataSet.POLLSDATA.AddPOLLSDATARow(newPollsDataRow);

                    //Console.WriteLine(qCurRadioRow.Name+ "  "+markQ);
                }
                var pollsDataAdapter = new POLLSDATATableAdapter();
                pollsDataAdapter.Update(pollsDataSet.POLLSDATA);
                pollsDataSet.POLLSDATA.AcceptChanges();

            }
            Owner.InitializePollsGridView();
            tabControlPolls.TabPages.Clear();
            LoadControls();
        }
Ejemplo n.º 2
0
        private void GetGridRow()
        {
            var pollscommonTableAdapter=new POLLSCOMMONTableAdapter();
            quarter = (decimal) _selectionAnketControl.comboBoxQuarter.SelectedValue;
            year = (decimal) _selectionAnketControl.comboBoxYear.SelectedValue;
            region = (decimal) _selectionAnketControl.comboBoxRegion.SelectedValue;
            type = _selectionAnketControl.comboBoxPollType.SelectedValue.ToString();
            //int countColumns = Convert.ToInt32(
            //                   pollscommonTableAdapter.CountPolls(quarter, year
            //                                                      , region
            //                                                      , type
            //                       ));
            var structTableAdapter = new STRUCT_UNITTableAdapter();
            structTableAdapter.Fill(pollsDataSet.STRUCT_UNIT, DateTime.Now);
            var rkcTableAdapter = new RKCTableAdapter();
            rkcTableAdapter.Fill(pollsDataSet.RKC, DateTime.Now);

            if (region ==0)
            {
                pollscommonDataTable = new PollsDataSet.POLLSCOMMONDataTable();
                pollscommonTableAdapter.FillByYT(pollscommonDataTable, year
                                                 , type);

            }
            else
            {
                pollscommonDataTable = new PollsDataSet.POLLSCOMMONDataTable();
                pollscommonTableAdapter.FillByFiltr(pollscommonDataTable, quarter, year
                                                    , region
                                                    , type);

            }

            pollsGridView.Columns.Clear();
            if (pollscommonDataTable.Rows.Count > 0)
            {

                //DataTable pollsGridTable=new DataTable();
                //pollscommonDataTable = new PollsDataSet.POLLSCOMMONDataTable();
                //pollscommonTableAdapter.FillByFiltr(pollscommonDataTable, quarter, year
                //                                    , region
                //                                    , type);
                var pollsDataTA = new POLLSDATATableAdapter();

                pollsDataTA.Fill(pollsDataSet.POLLSDATA);

                //pollsGridView.Columns.Add(new DataGridViewColumn { Name = "BRANCH", HeaderText = "Город", AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells, CellTemplate = new DataGridViewTextBoxCell() });
                var newRow = new DataGridViewRow();
                //DataGridViewCell newCell = new
                //newRow.SetValues("QQQQQQ", "1");
                //pollsGridView.Columns.Add(new DataGridViewColumn{Visible = false,CellTemplate = new DataGridViewTextBoxCell()});
                List<String> columnIDs = new List<string>();
                pollsDataSet.Polls2GridCommon.Clear();
                foreach (var row in pollscommonDataTable.OrderBy(c => c.NUM))
                {
                    var newColumn = new DataGridViewColumn
                                        {
                                            Name = row.NUM.ToString(),
                                            AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
                                            CellTemplate = new DataGridViewTextBoxCell()
                                        };
                    pollsGridView.Columns.Add(newColumn);
                    pollsDataSet.Polls2GridCommon.AddPolls2GridCommonRow(row.NUM, row.TYPE, row.RDAY, row.BRANCH, row.RKC,
                                                                      newColumn.Index);

                }

                pollsGridView.Columns.Add(new DataGridViewColumn
                                              {
                                                  Name = "Итого",
                                                  AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
                                                  HeaderCell = new DataGridViewColumnHeaderCell(){Style=new DataGridViewCellStyle(){Font = new Font(DefaultFont, FontStyle.Bold),BackColor = Color.LightPink}},
                                                  CellTemplate =
                                                      new DataGridViewTextBoxCell()
                                                          {
                                                              Style =
                                                                  new DataGridViewCellStyle()
                                                                      {
                                                                          Alignment =
                                                                              DataGridViewContentAlignment.MiddleCenter,
                                                                          BackColor = Color.LightPink,
                                                                          Font = new Font(DefaultFont, FontStyle.Bold)

                                                                      }

                                                          }
                                              });

                //var newRow = new DataGridViewRow{};
                //pollsGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
                pollsGridView.RowHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
                pollsGridView.SelectionMode = DataGridViewSelectionMode.FullColumnSelect;
                var indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {Visible = false});
                columnIDs.Add("RDAY");
                //indRow =
                //    pollsGridView.Rows.Add(new DataGridViewRow { Visible = false });
                //columnIDs.Add("RDAY");
                 indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell =
                                                       new DataGridViewRowHeaderCell()
                                                           {Value = "Социально-демографический портрет"}
                                               });
                pollsGridView.Rows[indRow].HeaderCell.Style.Font = new Font(DefaultFont, FontStyle.Bold);
                //pollsGridView.Rows[indRow].Cells[0].Value = "";
                columnIDs.Add("");

                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell = new DataGridViewRowHeaderCell() {Value = "Отделение/ОПЕРУ"}
                                               });
                columnIDs.Add("BRANCH");
                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow { HeaderCell = new DataGridViewRowHeaderCell() { Value = "РКЦ" } });
                columnIDs.Add("RKC");

                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell = new DataGridViewRowHeaderCell() {Value = "Пол"},
                                                   Tag = "SEX"
                                               });
                //pollsGridView.Rows[indRow].Cells[0].Value = "SEX";
                columnIDs.Add("SEX");
                indRow = pollsGridView.Rows.Add(new DataGridViewRow
                                                    {
                                                        HeaderCell = new DataGridViewRowHeaderCell() {Value = "Возраст"},
                                                        Tag = "AGE"
                                                    });
                //pollsGridView.Rows[indRow].Cells[0].Value = "AGE";
                columnIDs.Add("AGE");
                if (type=="TRANS")
                {

                    indRow = pollsGridView.Rows.Add(new DataGridViewRow
                    {
                        HeaderCell = new DataGridViewRowHeaderCell() { Value = "Тип перевода" },
                        Tag = "TYPETRANS"
                    });
                    columnIDs.Add("TYPETRANS");

                }

                var typesPolls = new TYPEPOLLSTableAdapter();
                typesPolls.Fill(pollsDataSet.TYPEPOLLS);
                var dataPoll = new POLLSDATATableAdapter();
                dataPoll.FillByFiltr(pollsDataSet.POLLSDATA, quarter, year, region, type);
                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell =
                                                       new DataGridViewRowHeaderCell()
                                                           {Value = "Степень удовлетворенности:"}
                                               });
                pollsGridView.Rows[indRow].HeaderCell.Style.Font = new Font(DefaultFont, FontStyle.Bold);
                columnIDs.Add("");
                pollsDataSet.ResaultColumn.Clear();
                foreach (
                    var VARIABLE in
                        pollsDataSet.TYPEPOLLS.Where(
                            c => c.TYPE == _selectionAnketControl.comboBoxPollType.SelectedValue.ToString()).OrderBy(
                                c => c.POSITION))
                {

                    var ind =
                        pollsGridView.Rows.Add(new DataGridViewRow
                                                   {
                                                       HeaderCell =
                                                           new DataGridViewRowHeaderCell() {Value = VARIABLE.NAMEQUEST},
                                                       Tag = VARIABLE.IDQUEST
                                                   });
                    columnIDs.Add("Q"+VARIABLE.IDQUEST);
                    pollsDataSet.ResaultColumn.AddResaultColumnRow(VARIABLE.IDQUEST, pollscommonDataTable.Rows.Count, 0, 0);

                }

                pollsGridView.RowHeadersWidth = 200;
                pollsGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing;
                pollsGridView.AutoSizeRowsMode =
                    DataGridViewAutoSizeRowsMode.AllCells;
                //foreach (var VARIABLE in pollscommonDataTable.OrderBy(c => c.NUM))
                //{
                //    pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("SEX"))].Cells[VARIABLE.NUM.ToString()].Value
                //        = VARIABLE.SEX[0];
                //    pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("AGE"))].Cells[VARIABLE.NUM.ToString()].Value
                //        = VARIABLE.AGE.ToString();
                //    int firstDataRow = indRow;
                //    foreach (var curentRow in pollsDataSet.POLLSDATA.Where(
                //        c =>
                //        c.BRANCH == VARIABLE.BRANCH && c.NUM == VARIABLE.NUM && c.RDAY == VARIABLE.RDAY && c.RKC
                //        == VARIABLE.RKC))
                //    {
                //        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("Q" + curentRow.IDQUEST))].Cells[
                //            VARIABLE.NUM.ToString()].Value = curentRow.QUALITY;
                //    }
                //    //for (int i = firstDataRow; i < pollsGridView.Rows.Count; i++)
                //    //{
                //    //    pollsGridView.Rows[i].Cells[VARIABLE.NUM.ToString()].Value =
                //    //        pollsDataSet.POLLSDATA.Where(
                //    //            c =>
                //    //            c.BRANCH == VARIABLE.BRANCH && c.NUM == VARIABLE.NUM && c.RDAY == VARIABLE.RDAY && c.RKC
                //    //            == VARIABLE.RKC && c.IDQUEST == pollsDataSet.TYPEPOLLS.Where(b=>b.POSITION==(i-1)&&b.TYPE==VARIABLE.TYPE).First().IDQUEST).First().QUALITY;
                //    //}

                //}
                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell =
                                                       new DataGridViewRowHeaderCell() {Value = "Степень важности:"}
                                               });
                pollsGridView.Rows[indRow].HeaderCell.Style.Font = new Font(DefaultFont, FontStyle.Bold);
                columnIDs.Add("");
                foreach (
                    var VARIABLE in
                        pollsDataSet.TYPEPOLLS.Where(
                            c => c.TYPE == _selectionAnketControl.comboBoxPollType.SelectedValue.ToString()).OrderBy(
                                c => c.POSITION))
                {

                    var ind =
                        pollsGridView.Rows.Add(new DataGridViewRow
                                                   {
                                                       HeaderCell =
                                                           new DataGridViewRowHeaderCell() {Value = VARIABLE.NAMEQUEST},
                                                       Tag = VARIABLE.IDQUEST
                                                   });
                    columnIDs.Add("I" + VARIABLE.IDQUEST);

                }

                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell =
                                                       new DataGridViewRowHeaderCell()
                                                           {Value = "Реальная удовлетворенность"}
                                               });
                pollsGridView.Rows[indRow].HeaderCell.Style.Font = new Font(DefaultFont, FontStyle.Bold);
                //pollsGridView.Rows[indRow].Cells[0].Value = "";
                columnIDs.Add("IP");

                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell =
                                                       new DataGridViewRowHeaderCell()
                                                           {Value = "Оптимальная удовлетворенность"}
                                               });
                pollsGridView.Rows[indRow].HeaderCell.Style.Font = new Font(DefaultFont, FontStyle.Bold);
                //pollsGridView.Rows[indRow].Cells[0].Value = "";
                columnIDs.Add("IO");

                indRow =
                    pollsGridView.Rows.Add(new DataGridViewRow
                                               {
                                                   HeaderCell =
                                                       new DataGridViewRowHeaderCell()
                                                           {Value = "Индекс удовлетворенности, %"}
                                               });
                pollsGridView.Rows[indRow].HeaderCell.Style.Font = new Font(DefaultFont, FontStyle.Bold);
                //pollsGridView.Rows[indRow].Cells[0].Value = "";
                columnIDs.Add("IPIO");

                //Заполняем столбцы
                decimal Ip=0;
                decimal Io=0;

                foreach (var VARIABLE in pollsDataSet.Polls2GridCommon.OrderBy(c=>c.Position))
                {
                    var curComRow = pollscommonDataTable.FindByNUMTYPERDAYBRANCHRKC(VARIABLE.Num, VARIABLE.Type,
                                                                                    VARIABLE.RDay, VARIABLE.Branch,
                                                                                    VARIABLE.RKC);

                    pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("SEX"))].Cells[(int) VARIABLE.Position].Value
                        = curComRow.SEX[0];
                    pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("AGE"))].Cells[(int)VARIABLE.Position].Value
                        = curComRow.AGE.ToString();
                    pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("BRANCH"))].Cells[(int)VARIABLE.Position].
                        Value
                        = curComRow.BRANCH.ToString();
                    pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("BRANCH"))].Cells[(int) VARIABLE.Position].
                        ToolTipText
                        = pollsDataSet.STRUCT_UNIT.FirstOrDefault(c => c.BRANCH == curComRow.BRANCH).NAME;
                    pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("RKC"))].Cells[(int) VARIABLE.Position].Value
                        = curComRow.RKC.ToString();
                    if (VARIABLE.RKC != 0)
                    {
                        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("RKC"))].Cells[(int)VARIABLE.Position].
                            ToolTipText
                            =
                            pollsDataSet.RKC.FirstOrDefault(
                                c => c.REF_OTD == VARIABLE.Branch && c.CODE_RKC == VARIABLE.RKC).NAME;
                    }
                    else
                    {
                        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("RKC"))].Cells[(int)VARIABLE.Position].
                            ToolTipText = pollsDataSet.STRUCT_UNIT.FirstOrDefault(c => c.BRANCH == VARIABLE.Branch).NAME;
                    }

                    if (type == "TRANS")
                    {

                        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("TYPETRANS"))].Cells[
                            (int)VARIABLE.Position].Value
                            = curComRow.TYPETRANS.ToString();

                    }

                    int firstDataRow = indRow;
                    foreach (var curentRow in pollsDataSet.POLLSDATA.Where(
                        c =>
                        c.BRANCH == VARIABLE.Branch && c.NUM == VARIABLE.Num && c.RDAY == VARIABLE.RDay && c.RKC
                        == VARIABLE.RKC))
                    {
                        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("Q" + curentRow.IDQUEST))].Cells[
                            (int)VARIABLE.Position].Value = curentRow.QUALITY;
                        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("I" + curentRow.IDQUEST))].Cells[
                            (int)VARIABLE.Position].Value = curentRow.IMPOTANCE;
                        pollsDataSet.ResaultColumn.FindByIDQUEST(curentRow.IDQUEST).QSUM += curentRow.QUALITY;
                        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("Q" + curentRow.IDQUEST))].Cells[
                            pollsGridView.ColumnCount - 1].Value =Math.Round(
                            pollsDataSet.ResaultColumn.FindByIDQUEST(curentRow.IDQUEST).QSUM/
                            pollsDataSet.ResaultColumn.FindByIDQUEST(curentRow.IDQUEST).COUNT,1);

                        pollsDataSet.ResaultColumn.FindByIDQUEST(curentRow.IDQUEST).ISUM += curentRow.IMPOTANCE;
                        pollsGridView.Rows[columnIDs.FindIndex(c => c.Contains("I" + curentRow.IDQUEST))].Cells[
                            pollsGridView.ColumnCount - 1].Value =Math.Round(
                            pollsDataSet.ResaultColumn.FindByIDQUEST(curentRow.IDQUEST).ISUM/
                            pollsDataSet.ResaultColumn.FindByIDQUEST(curentRow.IDQUEST).COUNT,1);

                    }
                    //for (int i = firstDataRow; i < pollsGridView.Rows.Count; i++)
                    //{
                    //    pollsGridView.Rows[i].Cells[VARIABLE.NUM.ToString()].Value =
                    //        pollsDataSet.POLLSDATA.Where(
                    //            c =>
                    //            c.BRANCH == VARIABLE.BRANCH && c.NUM == VARIABLE.NUM && c.RDAY == VARIABLE.RDAY && c.RKC
                    //            == VARIABLE.RKC && c.IDQUEST == pollsDataSet.TYPEPOLLS.Where(b=>b.POSITION==(i-1)&&b.TYPE==VARIABLE.TYPE).First().IDQUEST).First().QUALITY;
                    //}

                }
                foreach (var resRow in pollsDataSet.ResaultColumn)
                {
                    Ip += (resRow.QSUM / resRow.COUNT) * (resRow.ISUM / resRow.COUNT);
                    Io += resRow.ISUM*5;
                }
                pollsGridView.Rows[columnIDs.IndexOf("IP")].Cells[
                    pollsGridView.ColumnCount - 1].Value = Math.Round(Ip,1);
                pollsGridView.Rows[columnIDs.IndexOf("IP")].Cells[
                    pollsGridView.ColumnCount - 1].Style.BackColor = Color.Yellow;
                pollsGridView.Rows[columnIDs.IndexOf("IP")].DefaultCellStyle.BackColor = Color.Yellow;
                pollsGridView.Rows[columnIDs.IndexOf("IO")].Cells[
                    pollsGridView.ColumnCount - 1].Value = Io;
                pollsGridView.Rows[columnIDs.IndexOf("IO")].Cells[
                    pollsGridView.ColumnCount - 1].Style.BackColor = Color.LightGreen;
                pollsGridView.Rows[columnIDs.IndexOf("IO")].DefaultCellStyle.BackColor = Color.LightGreen;
                pollsGridView.Rows[columnIDs.IndexOf("IPIO")].Cells[
                    pollsGridView.ColumnCount - 1].Value = (Math.Round((Ip/Io)*100, 2));
                pollsGridView.Rows[columnIDs.IndexOf("IPIO")].Cells[
                    pollsGridView.ColumnCount - 1].Style.BackColor = Color.DarkRed;
                pollsGridView.Rows[columnIDs.IndexOf("IPIO")].Cells[
                    pollsGridView.ColumnCount - 1].Style.ForeColor = Color.White;
                pollsGridView.Rows[columnIDs.IndexOf("IPIO")].DefaultCellStyle.BackColor = Color.DarkRed;

            }
            //pollsGridView.Rows[0].SetValues("QQQQQQ", "1");
            //for (int i = 0; i < countColumns; i++)
            //{
            //    pollsGridView.Columns.Add(i+1.ToString(),i+1.ToString());

            //}
            //selectionAnketControl.comboBoxYear.SelectedIndexChanged
        }
        private void acceptChangesButton_Click(object sender, EventArgs e)
        {
            foreach (TabPage currentListBoxItem in tabControlPolls.TabPages)
            {
                var pollsCommonAdapter = new POLLSCOMMONTableAdapter();
                pollsCommonAdapter.Fill(pollsDataSet.POLLSCOMMON);
                var _newCommonRow = pollsDataSet.POLLSCOMMON.FindByNUMTYPERDAYBRANCHRKC(_oldRow.NUM, _oldRow.TYPE,
                                                                                               _oldRow.RDAY,
                                                                                               _oldRow.BRANCH,
                                                                                               _oldRow.RKC);
                _newCommonRow.NUM = Convert.ToDecimal(maskedTextBoxNumber.Text);
                _newCommonRow.RDAY = dateTimePicker.Value;
                _newCommonRow.TYPE = currentListBoxItem.Name;
                _newCommonRow.FILIAL = Convert.ToDecimal(comboBoxRegion.SelectedValue);
                _newCommonRow.BRANCH = Convert.ToDecimal(comboBoxStructUnite.SelectedValue);
                _newCommonRow.RKC = Convert.ToDecimal(comboBoxRKC.SelectedValue);
                _newCommonRow.SEX = comboBoxSex.SelectedValue.ToString();
                _newCommonRow.AGE = numericUpDown1.Value;
                _newCommonRow.LASTCHANGE = DateTime.Now;
                _newCommonRow.REFUSER = _user.Id_user;

                if(
                currentListBoxItem.Name == "TRANS")
                {}
                var typesPoll = new TYPEPOLLSTableAdapter();
                typesPoll.Fill(pollsDataSet.TYPEPOLLS);
                var splitQI = (SplitContainer) currentListBoxItem.Controls["SplitQI"];
                var qPollRadioTable = (PollRadioTable) splitQI.Panel1.Controls["QTABLE"];
                var iPollRadioTable = (PollRadioTable) splitQI.Panel2.Controls["ITABLE"];
                //pollsDataSet.POLLSCOMMON.

                //pollsDataSet.POLLSDATA.
                var pollsDataAdapter = new POLLSDATATableAdapter();
                pollsDataAdapter.Fill(pollsDataSet.POLLSDATA);
                //c => c.TYPE == currentListBoxItem.Name/*"TYPE="+currentListBoxItem.Name*/))
                foreach (PollsDataSet.TYPEPOLLSRow curCrit in pollsDataSet.TYPEPOLLS.Where(c=>c.TYPE==currentListBoxItem.Name))
                {
                    var qCurRadioRow = (GroupeRow)qPollRadioTable.tableLayoutPanel.Controls["R" + curCrit.IDQUEST];
                    var iCurRadioRow = (GroupeRow)iPollRadioTable.tableLayoutPanel.Controls["R" + curCrit.IDQUEST];
                    int markQ = 0;
                    int markI = 0;
                    for (int i = 1; i <= 5; i++)
                    {
                        var rbQ = (RadioButton) qCurRadioRow.tableLayoutPanel.Controls["Mark" + i];
                        if (rbQ.Checked)
                            markQ = i;
                        var rbI = (RadioButton)iCurRadioRow.tableLayoutPanel.Controls["Mark" + i];
                        if (rbI.Checked)
                            markI = i;

                    }
                    var newPollsDataRow = pollsDataSet.POLLSDATA.FindByNUMTYPERDAYBRANCHRKCIDQUEST(_oldRow.NUM, _oldRow.TYPE,
                                                                                               _oldRow.RDAY,
                                                                                               _oldRow.BRANCH,
                                                                                               _oldRow.RKC, curCrit.IDQUEST);

                    newPollsDataRow.BRANCH = _newCommonRow.BRANCH;
                    newPollsDataRow.RKC = _newCommonRow.RKC;
                    newPollsDataRow.NUM = _newCommonRow.NUM;
                    newPollsDataRow.RDAY = _newCommonRow.RDAY;
                    newPollsDataRow.TYPE = _newCommonRow.TYPE;
                    newPollsDataRow.QUALITY = markQ;
                    newPollsDataRow.IMPOTANCE = markI;
                    //pollsDataSet.POLLSDATA.AddPOLLSDATARow(newPollsDataRow);

                    //Console.WriteLine(qCurRadioRow.Name+ "  "+markQ);
                }
                pollsDataAdapter.Update(pollsDataSet.POLLSDATA);
                pollsDataSet.POLLSDATA.AcceptChanges();

                pollsCommonAdapter.Update(pollsDataSet.POLLSCOMMON);
                pollsDataSet.POLLSCOMMON.AcceptChanges();

            }
        }
Ejemplo n.º 4
0
        private void delPollToolStripButton_Click(object sender, EventArgs e)
        {
            if(
            MessageBox.Show(this, "Вы действительно хотите удалить анкету?", "Внимание", MessageBoxButtons.YesNo,
                            MessageBoxIcon.Warning)==DialogResult.Yes)
            {
                int columnIndex = pollsGridView.SelectedColumns[0].Index;
                pollscommonDataTable.FindByNUMTYPERDAYBRANCHRKC(
                pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).Num,
                pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).Type,
                pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).RDay,
                pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).Branch,
                pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).RKC).Delete();
                var pollscommonTA = new POLLSCOMMONTableAdapter();
                pollscommonTA.Update(pollscommonDataTable);
                pollscommonDataTable.AcceptChanges();
                foreach(var row in pollsDataSet.POLLSDATA.
                    Where(
                    c =>
                    c.NUM == pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).Num &&
                    c.RDAY == pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).RDay &&
                    c.BRANCH == pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).Branch &&
                    c.RKC == pollsDataSet.Polls2GridCommon.FindByPosition(columnIndex).RKC))
                {
                    row.Delete();
                }
                var pollsdataTa = new POLLSDATATableAdapter();
                pollsdataTa.Update(pollsDataSet.POLLSDATA);
                pollsDataSet.POLLSDATA.AcceptChanges();
                GetGridRow();

            }
        }
        private TabPage GetTabPage(String Key)
        {
            var newTab = new TabPage() { Text = pollsDataSet.TYPES.First(c=>c.TYPE==Key).NAME, Name = Key};
            var rbDictQ = new Dictionary<String,RowRadioButtons>();
            var rbDictI = new Dictionary<String,RowRadioButtons>();
            var typePolls = new TYPEPOLLSTableAdapter();
            var splitQI = new SplitContainer() { Dock = DockStyle.Fill, Orientation = Orientation.Horizontal, Name = "SplitQI",AutoSize = true,AutoScroll = true};

            newTab.Controls.Add(splitQI);
            if (Key == "TRANS")
            {
                var panelTrans = new Panel() { Size = new Size() { Height = 30, Width = 200 }, Dock = DockStyle.Top };

                _transComboBox = new ComponentsComboBox();
                _transComboBox.label.Text = "Тип перевода:";
                _transComboBox.comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                var transTypeBinding = new BindingSource();
                transTypeBinding.DataSource = pollsDataSet;
                transTypeBinding.DataMember = "TransTypes";
                _transComboBox.comboBox.DataSource = transTypeBinding;
                _transComboBox.comboBox.DisplayMember = "NameTransType";
                _transComboBox.comboBox.ValueMember = "IdTransType";
                _transComboBox.comboBox.SelectedValue = _oldRow.TYPETRANS;

                panelTrans.Controls.Add(_transComboBox);
                newTab.Controls.Add(panelTrans);

            }

            typePolls.Fill(pollsDataSet.TYPEPOLLS);

            var qPollRadioTable = new PollRadioTable() { Name = "QTABLE", AutoSize = true, AutoSizeMode = AutoSizeMode.GrowOnly,Dock = DockStyle.Fill ,AutoScroll = true};
            var iPollRadioTable = new PollRadioTable() { Name = "ITABLE", AutoSize = true, AutoSizeMode = AutoSizeMode.GrowOnly, Dock = DockStyle.Fill, AutoScroll = true };
            //qPollRadioTable.AddRow("HEADERS");
            var qHeadersRow = new GroupeRow(){Dock = DockStyle.Fill};
            var iHeadersRow = new GroupeRow() { Dock = DockStyle.Fill };

            qHeadersRow.tableLayoutPanel.RowStyles[0].SizeType = SizeType.Absolute;
            iHeadersRow.tableLayoutPanel.RowStyles[0].SizeType = SizeType.Absolute;

            for (int j = 0; j < qHeadersRow.tableLayoutPanel.ColumnCount && j < iHeadersRow.tableLayoutPanel.ColumnCount; j++)
            {
                //qPollRadioTable.tableLayoutPanel.Controls["HEADERS"].Controls.Add();
                //qPollRadioTable.tableLayoutPanel.Controls.Add(new Label {Text = _qTexts[j-1],TextAlign = ContentAlignment.MiddleCenter,AutoSize=true},j,0);

                var qHeaderLabel = new Label()
                                      {
                                          Text = _qTexts[j],
                                          Name = "Header" + j,
                                          TextAlign = ContentAlignment.MiddleCenter,
                                          AutoSize = true,
                                          Dock = DockStyle.Fill

                                      };
                var iHeaderLabel = new Label()
                                       {
                                           Text = _iTexts[j],
                                           Name = "Header" + j,
                                           TextAlign = ContentAlignment.MiddleCenter,
                                           AutoSize = true,
                                           Dock = DockStyle.Fill

                                       };

                qHeadersRow.tableLayoutPanel.Controls.Add(qHeaderLabel , j, 0);
                iHeadersRow.tableLayoutPanel.Controls.Add(iHeaderLabel, j, 0);

                //qHeadersRow.tableLayoutPanel.Controls["Header" + j].AutoSize = true;

               // Console.WriteLine("Header " + j + " " + qHeadersRow.tableLayoutPanel.Controls["Header" + j].Height + "x" + qHeadersRow.tableLayoutPanel.Controls["Header" + j].Width);
                //qHeadersRow.tableLayoutPanel.AutoSize
                //qPollRadioTable.tableLayoutPanel.Controls[]
            }
            qHeadersRow.tableLayoutPanel.RowStyles[0].Height = 30;
            iHeadersRow.tableLayoutPanel.RowStyles[0].Height = 30;

            //qHeadersRow.tableLayoutPanel.RowStyles[0].SizeType = SizeType.Absolute;
            int i = 0;
            qHeadersRow.tableLayoutPanel.AutoSize = true;
            iHeadersRow.tableLayoutPanel.AutoSize = true;

            //qHeadersRow.tableLayoutPanel.LayoutSettings.RowStyles[0].SizeType = SizeType.AutoSize;
            qPollRadioTable.tableLayoutPanel.Controls.Add(qHeadersRow,1,0);
            iPollRadioTable.tableLayoutPanel.Controls.Add(iHeadersRow, 1, 0);

            qHeadersRow.AutoSize = true;
            iHeadersRow.AutoSize = true;
            Console.WriteLine("Header "+qHeadersRow.Height);
            var pollsDataTA = new POLLSDATATableAdapter();
            pollsDataTA.FillCurrent(pollsDataSet.POLLSDATA, _oldRow.NUM, _oldRow.TYPE, _oldRow.RDAY, _oldRow.BRANCH,
                                    _oldRow.RKC);

            foreach (var currentRow in pollsDataSet.TYPEPOLLS.Where(c=>c.TYPE==Key))
            {

                var qRadioRow = new RowRadioButtons(5){Text = currentRow.NAMEQUEST};

                //qRadioRow.Mark[0].Text = "Совершенно удовлетворен";
                //qRadioRow.Mark[1].Text = "Скорее удовлетворен";
                //qRadioRow.Mark[2].Text = "В целом меня все устраивает";
                //qRadioRow.Mark[3].Text = "Скорее не удовлетворен";
                //qRadioRow.Mark[4].Text = "Совершенно не удовлетворен";
                rbDictQ.Add(currentRow.IDQUEST,qRadioRow);
                var iRadioRow = new RowRadioButtons(5){Text = currentRow.NAMEQUEST};

                //iRadioRow.Mark[0].Text = "Очень важно";
                //iRadioRow.Mark[1].Text = "Скорее важно";
                //iRadioRow.Mark[2].Text = "Имеет нейтральное значение";
                //iRadioRow.Mark[3].Text = "Скорее неважно";
                //iRadioRow.Mark[4].Text = "Совершенно неважно";
                rbDictI.Add(currentRow.IDQUEST,iRadioRow);
                qPollRadioTable.tableLayoutPanel.Controls.Add(new Label(){Name = currentRow.IDQUEST,Text = qRadioRow.Text,AutoSize = true,Height = 0},0,i+1);
                iPollRadioTable.tableLayoutPanel.Controls.Add(new Label() { Name = currentRow.IDQUEST, Text = qRadioRow.Text, AutoSize = true, Height = 0 }, 0, i + 1);

                var qCurentRadioRow = new GroupeRow() { Dock = DockStyle.Fill, Name = "R" + currentRow.IDQUEST };
                var iCurentRadioRow = new GroupeRow() { Dock = DockStyle.Fill, Name = "R" + currentRow.IDQUEST };

                var curentQ = pollsDataSet.POLLSDATA.Where(c => c.IDQUEST == currentRow.IDQUEST).FirstOrDefault().QUALITY;
                var curentI = pollsDataSet.POLLSDATA.Where(c => c.IDQUEST == currentRow.IDQUEST).FirstOrDefault().IMPOTANCE;

                for (int j = 0; j <5; j++)
                {
                    //qPollRadioTable.tableLayoutPanel.Controls.Add(qRadioRow.Mark[j], j + 1, i+1);
                    ////qPollRadioTable.tableLayoutPanel.RowStyles[i + 1] = new RowStyle(qPollRadioTable.tableLayoutPanel.RowStyles[0]);
                    //iPollRadioTable.tableLayoutPanel.Controls.Add(iRadioRow.Mark[j], j + 1, i+1);
                    //if ()
                    //{

                    //}
                    if (curentQ==j+1)
                    {
                        qRadioRow.Mark[4-j].Checked = true;
                    }
                    if (curentI == j+1)
                    {
                        iRadioRow.Mark[4 - j].Checked = true;
                    }

                    qCurentRadioRow.tableLayoutPanel.Controls.Add(qRadioRow.Mark[j], j, 0);
                    iCurentRadioRow.tableLayoutPanel.Controls.Add(iRadioRow.Mark[j], j, 0);

                }
                qPollRadioTable.tableLayoutPanel.Controls.Add(qCurentRadioRow, 1, i + 1);
                iPollRadioTable.tableLayoutPanel.Controls.Add(iCurentRadioRow, 1, i + 1);

                i++;
            }
            //if (newTab.Name != "TRANS")
            //{
               // var newTableControls = new TableLayoutPanel();
                qPollRadioTable.BorderStyle = BorderStyle.FixedSingle;
                //qPollRadioTable.MaximumSize.Width
                    //= splitQI.Panel1.Size.Width - 4;
                qPollRadioTable.AutoSize = true;
                qPollRadioTable.tableLayoutPanel.AutoSize = true;
                iPollRadioTable.BorderStyle = BorderStyle.FixedSingle;

                splitQI.Panel1.Controls.Add(qPollRadioTable);
                //splitQI.Panel1.AutoSize = true;
                //splitQI.Panel1.Dock = DockStyle.Fill;
                //splitQI.Panel1.AutoScroll = true;
                //splitQI.Panel1.Controls[newTab.Controls.IndexOfKey("QTABLE")].Dock = DockStyle.Fill;
                qPollRadioTable.tableLayoutPanel.AutoScroll = true;
                iPollRadioTable.tableLayoutPanel.AutoScroll = true;
                splitQI.Panel2.Controls.Add(iPollRadioTable);
                //splitQI.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
                //newTab.Controls[newTab.Controls.IndexOfKey("ITABLE")].Dock = DockStyle.Bottom;
                newTab.AutoSizeMode = AutoSizeMode.GrowOnly;
                newTab.AutoSize = true;
                newTab.AutoScroll = true;

                //tabControlPolls.TabPages[pollsDataSet.TYPES[index].TYPE]
            //            }
            return newTab;
        }