Esempio n. 1
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 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();
        }
        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();

            }
        }