Ejemplo n.º 1
0
        private void edit()
        {
            try
            {
                STRegion data = GetSelectionData();

                DlgRegions wnd = new DlgRegions(connect, data, mode);

                DialogResult result = wnd.ShowDialog();

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

                    init_list();

                    if (gpos >= 0 && dataGridViewRegion.Rows.Count > 0)
                    {
                        dataGridViewRegion.Rows[gpos].Selected             = true;
                        dataGridViewRegion.FirstDisplayedScrollingRowIndex = gpos;
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }
Ejemplo n.º 2
0
        public DlgRegions(SqlConnection cn, STRegion st, ushort md)
        {
            InitializeComponent();

            connect   = cn;
            mode      = md;
            gstRegion = st;

            caption = "Редактировать регион";

            init_combo();

            set_data();
        }
Ejemplo n.º 3
0
        private STRegion read_data()
        {
            STRegion ret = new STRegion();

            CCountry country;

            try
            {
                if (gstRegion.id != 0)
                {
                    ret.id = gstRegion.id;
                }
                else
                {
                    ret.id = clRegion.GetFreeId();
                }

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

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

                string str = comboBoxCountry.Text.Trim();
                if (str.Length > 0)
                {
                    country       = new CCountry(connect, str);
                    ret.idcountry = country.stCountry.id;
                }
                else
                {
                    ret.idcountry = 0;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

            return(ret);
        }
Ejemplo n.º 4
0
        private void del()
        {
            try
            {
                STRegion data = GetSelectionData();

                if (MessageBox.Show("Вы действиетльно желаете удалить запись?", "Внимание!",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    clRegion.Delete(data);
                    init_list();
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }
Ejemplo n.º 5
0
        private bool save()
        {
            bool ret = false;

            stC = new STRegion();

            stC = read_data();

            if (gstRegion.id != 0)
            {
                ret = clRegion.Update(stC);
            }
            else
            {
                ret = clRegion.Insert(stC);
            }

            return(ret);
        }
Ejemplo n.º 6
0
        private STRegion GetSelectionData()
        {
            STRegion ret = new STRegion();

            string n;

            try
            {
                foreach (DataGridViewRow item in dataGridViewRegion.SelectedRows)
                {
                    n = item.Cells[1].Value.ToString();

                    CRegion ct = new CRegion(connect, n);

                    ret = ct.stReg;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }

            return(ret);
        }