public void OnConfirm(object sender, EventArgs e)
        {
            string confirmValue = Request.Form["confirm_value"];

            if (confirmValue.LastIndexOf(',') > 0)
            {
                confirmValue = confirmValue.Substring(confirmValue.LastIndexOf(',') + 1);
            }
            if (confirmValue == "Yes")
            {
                using (CWMEntities cwm = new CWMEntities(EnCon))
                {
                    int IDJOB = int.Parse(Request["idj"].ToString());
                    JOB delj  = (from jj in cwm.JOB
                                 where jj.ID == IDJOB
                                 select jj).First();

                    REMOVEDJOB REMJ = new REMOVEDJOB();
                    REMJ.IDORIGINALJOB = delj.ID;
                    REMJ.IDCAR         = delj.IDCAR;
                    REMJ.IDCLASS       = delj.IDCLASS;
                    REMJ.IDEMP         = delj.IDEMP;
                    REMJ.IDPACKAGE     = delj.IDPACKAGE;
                    REMJ.JOBDATE       = delj.JOBDATE;
                    REMJ.LINE          = delj.LINE;
                    REMJ.NPLATE        = delj.NPLATE;
                    REMJ.TOTALCOST     = delj.TOTALCOST;
                    REMJ.DATEDELETED   = DateTime.Now;

                    cwm.AddToREMOVEDJOB(REMJ);
                    cwm.SaveChanges();

                    cwm.DeleteObject(delj);

                    //var delpack = from pp in cwm.PACKAGE
                    //              where pp.IDJOB == IDJOB
                    //              select pp;
                    //foreach (PACKAGE pack in delpack)
                    //{
                    //    cwm.DeleteObject(pack);
                    //}

                    //var delpackadd = from pp in cwm.PACKAGEADDSERV
                    //              where pp.IDJOB == IDJOB
                    //              select pp;
                    //foreach (PACKAGEADDSERV pack in delpackadd)
                    //{
                    //    cwm.DeleteObject(pack);
                    //}

                    cwm.SaveChanges();
                }
                //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Работа успешно удалена!')", true);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "success", @"alert('Работа успешно удалена!');location = ""Default.aspx""", true);
            }
            else
            {
                //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
            }
        }
        protected void bAdd_Click(object sender, EventArgs e)
        {
            try
            {
                lError.Text = "";
                if (tbPlate.Text == "")
                {
                    lError.Text = "Введите государственный номер автомобиля!";
                    return;
                }
                if ((chbManual.Checked) && (tbCar.Text == ""))
                {
                    lError.Text = "Введите название автомобиля!";
                    return;
                }
                bool ISPrice = false;
                foreach (ListItem c in chblPrice.Items)
                {
                    if (c.Selected)
                    {
                        ISPrice = true;
                        break;
                    }
                }
                if (!ISPrice)
                {
                    lError.Text = "Отметьте хотя бы одну услугу!";
                    return;
                }
                int y = ddlEmployees.SelectedIndex;
                if (y == -1)
                {
                    lError.Text = "Добавьте сотрудников в базу!";
                    return;
                }
                JOB J = new JOB();
                J.IDCLASS = int.Parse(ddlClass.SelectedValue);
                if (chbManual.Checked)
                {
                    J.IDCAR = AddNewCar(tbCar.Text, J.IDCLASS);
                }
                else
                {
                    J.IDCAR = int.Parse(ddlCar.SelectedValue);
                }
                //MarkIDPRICEAsDeleted();
                int cntprice = DSP.Tables["P"].Rows.Count;
                DA.SelectCommand.CommandText = "select * from JOB where ID = " + Request["idj"];
                DA.Fill(DSJ, "J");
                J.IDEMP     = int.Parse(ddlEmployees.SelectedValue);
                J.JOBDATE   = (DateTime)DSJ.Tables["J"].Rows[0]["JOBDATE"];
                J.LINE      = int.Parse(ddlLine.SelectedValue);
                J.NPLATE    = tbPlate.Text;
                J.IDPACKAGE = -1;
                if (ddlSpecial.Text == "НЕТ")
                {
                    J.TOTALCOST = GetTotalCost();
                }
                else
                {
                    J.TOTALCOST = 0;
                }

                /*if (chbPlus_50.Checked)
                 * {
                 *  J.PLUS_50 = true;
                 * }*/
                using (CWMEntities cwm = new CWMEntities(EnCon))
                {
                    int IDJOB = int.Parse(Request["idj"].ToString());
                    JOB delj  = (from jj in cwm.JOB
                                 where jj.ID == IDJOB
                                 select jj).First();
                    cwm.DeleteObject(delj);

                    var delpack = from pp in cwm.PACKAGE
                                  where pp.IDJOB == IDJOB
                                  select pp;
                    foreach (PACKAGE pack in delpack)
                    {
                        cwm.DeleteObject(pack);
                    }
                    cwm.AddToJOB(J);
                    cwm.SaveChanges();
                    AddNewPackage(J.ID);
                    // AddNewAddPackage(J.ID);
                }
            }
            catch (Exception ex)
            {
                lError.Text = "Ошибка при редактировании задания! Попробуйте обновить страницу и попробовать еще раз. " + ex.Message;
                return;
            }
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "success", @"alert('Работа успешно отредактирована!');location = ""Default.aspx""", true);
            //Response.Redirect(@"~\default.aspx");
        }