Example #1
0
        private void edit()
        {
            try
            {
                STCity data = GetSelectionData();

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

                DialogResult result = wnd.ShowDialog();

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

                    init_list();

                    if (gpos >= 0 && dataGridViewCity.Rows.Count > 0)
                    {
                        dataGridViewCity.Rows[gpos].Selected             = true;
                        dataGridViewCity.FirstDisplayedScrollingRowIndex = gpos;
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); }
        }
Example #2
0
        public DlgCitys(SqlConnection cn, STCity st, ushort md)
        {
            InitializeComponent();

            connect = cn;
            mode    = md;
            gstCity = st;

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

            init_combo();

            set_data();
        }
Example #3
0
        private void del()
        {
            try
            {
                STCity data = GetSelectionData();

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

            stC = new STCity();

            stC = read_data();

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

            return(ret);
        }
Example #5
0
        private STCity read_data()
        {
            STCity ret = new STCity();

            CRegion region;

            try
            {
                if (gstCity.id != 0)
                {
                    ret.id = gstCity.id;
                }
                else
                {
                    ret.id = clCity.GetFreeId();
                }

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

                string str = comboBoxRegion.Text.Trim();
                if (str.Length > 0)
                {
                    region    = new CRegion(connect, str);
                    ret.idreg = region.stReg.id;
                }
                else
                {
                    ret.idreg = 0;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }

            return(ret);
        }
Example #6
0
        private STCity GetSelectionData()
        {
            STCity ret = new STCity();

            string n;

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

                    CCity ct = new CCity(connect, n);

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

            return(ret);
        }