示例#1
0
        /// <summary>
        /// Применение изменений
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                int index = listSigns.SelectedIndex;

                if (index != -1)
                {
                    road_sign sign = PE.road_sign.ToArray <road_sign>()[index];

                    PE.road_sign.Where(x => x.code_road_sign == sign.code_road_sign).First().description = tbDescription.Text;

                    var lP = PE.item_list_prohibition.Where(x => x.code_road_sign == sign.code_road_sign);
                    foreach (var item in lP)
                    {
                        PE.item_list_prohibition.Remove(item);
                    }

                    var lR = PE.item_list_resolution.Where(x => x.code_road_sign == sign.code_road_sign);
                    foreach (var item in lR)
                    {
                        PE.item_list_resolution.Remove(item);
                    }

                    PE.SaveChanges();

                    foreach (string item in listResolution.Items)
                    {
                        act _act = PE.act.Where(x => x.name == item).First();

                        item_list_resolution iR = new item_list_resolution();
                        iR.code_road_sign = sign.code_road_sign;
                        iR.code_act       = _act.code_act;

                        PE.item_list_resolution.Add(iR);
                        PE.SaveChanges();
                    }

                    foreach (string item in listProhibishin.Items)
                    {
                        act _act = PE.act.Where(x => x.name == item).First();

                        item_list_prohibition iP = new item_list_prohibition();
                        iP.code_road_sign = sign.code_road_sign;
                        iP.code_act       = _act.code_act;

                        PE.item_list_prohibition.Add(iP);
                        PE.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
示例#2
0
        private void AddNewSign()
        {
            road_sign newSign = new road_sign();

            newSign.name           = tbName.Text;
            newSign.pdd_number     = tbNumber.Text;
            newSign.code_type_sign = PE.type_road_sign.ToArray <type_road_sign>()[cbType.SelectedIndex].code_type_road_sign;
            newSign.description    = tbDescription.Text;

            ImageWorker IM = new ImageWorker();

            IM.CopyImageByName(tbPath.Text, newSign.pdd_number.Replace('.', '_'));
            newSign.img = newSign.pdd_number.Replace('.', '_') + ".png";

            PE.road_sign.Add(newSign);
            PE.SaveChanges();

            foreach (string item in listResolution.Items)
            {
                act _act = PE.act.Where(x => x.name == item).First();

                item_list_resolution iR = new item_list_resolution();
                iR.code_road_sign = newSign.code_road_sign;
                iR.code_act       = _act.code_act;

                PE.item_list_resolution.Add(iR);
                PE.SaveChanges();
            }

            foreach (string item in listProhibishin.Items)
            {
                act _act = PE.act.Where(x => x.name == item).First();

                item_list_prohibition iP = new item_list_prohibition();
                iP.code_road_sign = newSign.code_road_sign;
                iP.code_act       = _act.code_act;

                PE.item_list_prohibition.Add(iP);
                PE.SaveChanges();
            }

            this.Close();
        }
示例#3
0
        /// <summary>
        /// Удаление действия из списка
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (listAct.SelectedIndex > -1)
                {
                    int index = listAct.SelectedIndex;
                    act _act  = PE.act.ToArray <act>()[index];

                    PE.act.Remove(_act);
                    PE.SaveChanges();

                    UpdateList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }