예제 #1
0
        private STParticipant GetSelectionData()
        {
            STParticipant ret = new STParticipant();

            int id;

            try
            {
                foreach (DataGridViewRow item in dataGridViewPart.SelectedRows)
                {
                    id = int.Parse(item.Cells[8].Value.ToString());

                    foreach (STParticipant s in list)
                    {
                        if (id == s.idpart)
                        {
                            ret = s;
                        }
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }

            return(ret);
        }
예제 #2
0
        private void edit()
        {
            try
            {
                STParticipant data = GetSelectionData();

                if (data.idpart > 0)
                {
                    DlgParticipant wnd = new DlgParticipant(connect, data);

                    DialogResult result = wnd.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        flawour = wnd.GetFl();

                        init_data();

                        if (gpos >= 0 && dataGridViewPart.Rows.Count > 0)
                        {
                            dataGridViewPart.Rows[gpos].Selected             = true;
                            dataGridViewPart.FirstDisplayedScrollingRowIndex = gpos;
                        }
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }
예제 #3
0
        public DlgParticipant(SqlConnection cn, ushort md, STParticipant st)
        {
            InitializeComponent();

            connect        = cn;
            mode           = md;
            gstParticipant = st;

            gid = gstParticipant.idpart;

            clParticipant = new CParticipant(connect);
            clParam       = new CParamApp();

            caption = "–едактировать данные участника";
        }
예제 #4
0
        private void del()
        {
            STParticipant data = GetSelectionData();

            if (data.idpart > 0)
            {
                string text = string.Format("Вы действительно желаете удалить тренера: {0} {1} {2}",
                                            data.family, data.name, data.payname);

                if (MessageBox.Show(text, "Внимание!", MessageBoxButtons.OKCancel,
                                    MessageBoxIcon.Question) == DialogResult.OK)
                {
                    if (clParticipant.Delete(data))
                    {
                        init_data();
                    }
                }
            }
        }
예제 #5
0
        private bool save()
        {
            bool ret = false;

            STParticipant data = new STParticipant();

            data = read_data();

            if (gstParticipant.idpart != 0)
            {
                ret = clParticipant.Update(data, gstParticipant.idpart);
            }
            else
            {
                ret = clParticipant.Insert(data);
            }

            return(ret);
        }
예제 #6
0
        private void edit()
        {
            STParticipant data = GetSelectionData();

            if (data.idpart > 0)
            {
                DlgParticipant wnd = new DlgParticipant(connect, mode, data);

                DialogResult result = wnd.ShowDialog();

                if (result == DialogResult.OK)
                {
                    init_data();

                    if (dataGridViewPart.Rows.Count > 0)
                    {
                        int x = get_num_row(wnd.RetId());
                        dataGridViewPart.Rows[x].Selected = true;

                        dataGridViewPart.FirstDisplayedScrollingRowIndex = x;
                    }
                }
            }
        }
예제 #7
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                rData = read_data();

                if (mode == 1)
                {
                    if (clWork.Update(rData, (STParticipant)oldData))
                    {
                        DialogResult = DialogResult.OK;
                    }
                }

                if (mode == 0)
                {
                    if (clWork.Insert(rData))
                    {
                        DialogResult = DialogResult.OK;
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }
예제 #8
0
        private STParticipant read_data()
        {
            STParticipant ret = new STParticipant();

            CCountry clCo;

            try
            {
                ret.idpart = gid;

                if (textBoxFamily.Text.Length > 0)
                {
                    ret.family = textBoxFamily.Text;
                }
                else
                {
                    ret.family = null;
                }

                if (textBoxName.Text.Length > 0)
                {
                    ret.name = textBoxName.Text;
                }
                else
                {
                    ret.name = null;
                }

                if (textBoxSecondName.Text.Length > 0)
                {
                    ret.payname = textBoxSecondName.Text;
                }
                else
                {
                    ret.payname = null;
                }

                ret.datebirth = new DateTime(dateTimePickerDateBirth.Value.Year,
                                             dateTimePickerDateBirth.Value.Month, dateTimePickerDateBirth.Value.Day, 0, 0, 0, 0);

                if (checkBoxNBL.CheckState == CheckState.Checked)
                {
                    ret.adminflag = 1;
                }
                else
                {
                    ret.adminflag = 0;
                }

                if (textBoxPersonalNum.Text.Length > 0)
                {
                    ret.personalnum = textBoxPersonalNum.Text;
                }
                else
                {
                    ret.personalnum = null;
                }

                if (comboBoxCountry.Text.Length > 0)
                {
                    string c = comboBoxCountry.Text;

                    clCo = new CCountry(connect, c);

                    ret.idcountry = clCo.stCountry.id;
                }
                else
                {
                    ret.idcountry = 0;
                }

                if (labelNameFoto.Text.Length > 0)
                {
                    ret.namefoto = labelNameFoto.Text.Trim();
                }
                else
                {
                    ret.namefoto = null;
                }

                if (textBoxDescript.Text.Length > 0)
                {
                    ret.descript = textBoxDescript.Text;
                }
                else
                {
                    ret.descript = null;
                }

                if (checkBoxVisible.Checked == true)
                {
                    ret.vf = 1;
                }
                else
                {
                    ret.vf = 0;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

            return(ret);
        }
예제 #9
0
        private STParticipant read_data()
        {
            STParticipant ret = new STParticipant();

            CCountry clCo;

            try
            {
                if (textBoxId.Text.Length > 0)
                {
                    ret.idpart = int.Parse(textBoxId.Text.Trim());
                }
                else
                {
                    ret.idpart = 0;
                }

                if (textBoxFamily.Text.Length > 0)
                {
                    ret.family = textBoxFamily.Text;
                }
                else
                {
                    ret.family = null;
                }

                if (textBoxName.Text.Length > 0)
                {
                    ret.name = textBoxName.Text;
                }
                else
                {
                    ret.name = null;
                }

                if (textBoxSecondName.Text.Length > 0)
                {
                    ret.payname = textBoxSecondName.Text;
                }
                else
                {
                    ret.payname = null;
                }

                ret.datebirth = new DateTime(dateTimePickerDateBirth.Value.Year,
                                             dateTimePickerDateBirth.Value.Month, dateTimePickerDateBirth.Value.Day, 0, 0, 0, 0);

                if (checkBoxNBL.CheckState == CheckState.Checked)
                {
                    ret.adminflag = 1;
                }
                else
                {
                    ret.adminflag = 0;
                }

                if (textBoxPersonalNum.Text.Length > 0)
                {
                    ret.personalnum = textBoxPersonalNum.Text;
                }
                else
                {
                    ret.personalnum = null;
                }

                if (comboBoxCountry.Text.Length > 0)
                {
                    string c = comboBoxCountry.Text;

                    clCo = new CCountry(connect, c);

                    ret.idcountry = clCo.stCountry.id;
                }
                else
                {
                    ret.idcountry = 0;
                }

                if (labelNameFoto.Text.Length > 0)
                {
                    ret.namefoto = labelNameFoto.Text.Trim();
                }
                else
                {
                    ret.namefoto = null;
                }

                if (checkBoxVisible.Checked == true)
                {
                    ret.vf = 1;
                }
                else
                {
                    ret.vf = 0;
                }

                List <int> arr = new List <int>();
                STPostment st;
                for (int i = 0; i < checkedListBoxPost.Items.Count; i++)
                {
                    if (checkedListBoxPost.GetItemChecked(i))
                    {
                        st = new STPostment();
                        string text = checkedListBoxPost.Items[i].ToString();
                        if (text.Length > 0)
                        {
                            st = clPost.GetPost(text);
                        }

                        arr.Add(st.idpost);
                    }
                }

                if (arr.Count > 0)
                {
                    ret.post = clWork.GetStringPost(arr);
                }
                else
                {
                    ret.post = null;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

            return(ret);
        }
예제 #10
0
        private void set_data(STParticipant data)
        {
            CCountry clCo;

            try
            {
                textBoxId.Text = data.idpart.ToString();

                if (data.idpart != 0)
                {
                    textBoxFamily.Text = data.family;
                    textBoxName.Text   = data.name;
                    if (data.payname != null)
                    {
                        textBoxSecondName.Text = data.payname;
                    }
                    if (data.datebirth != null)
                    {
                        dateTimePickerDateBirth.Value = (DateTime)data.datebirth;
                    }

                    if (data.adminflag == 1)
                    {
                        checkBoxNBL.CheckState = CheckState.Checked;
                    }
                    else
                    {
                        checkBoxNBL.CheckState = CheckState.Unchecked;
                    }

                    textBoxPersonalNum.Text = data.personalnum;

                    if (data.idcountry != null)
                    {
                        clCo = new CCountry(connect, (int)data.idcountry);
                        comboBoxCountry.Text = clCo.stCountry.shortname;
                    }

                    if (data.namefoto != null && data.namefoto.Length > 0)
                    {
                        string pathfoto = string.Format("{0}\\{1}", clParam.s_Path.pathfoto, data.namefoto);

                        FileInfo fi = new FileInfo(pathfoto);
                        if (fi.Exists)
                        {
                            labelNameFoto.Text = data.namefoto;

                            Bitmap bt = new Bitmap(pathfoto);
                            pictureBoxFoto.Image = bt;;
                        }
                        else
                        {
                            MessageBox.Show(string.Format("‘айл {0} не найден", pathfoto),
                                            "¬нимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    if (data.vf == 1)
                    {
                        checkBoxVisible.Checked = true;
                    }
                    else
                    {
                        checkBoxVisible.Checked = false;
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
        }