Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        private void AddNewPackage(int idjob)
        {
            PACKAGE p;

            using (CWMEntities cwm = new CWMEntities(EnCon))
            {
                foreach (ListItem c in chblPrice.Items)
                {
                    if (c.Selected)
                    {
                        p         = new PACKAGE();
                        p.IDJOB   = idjob;
                        p.IDPRICE = int.Parse(c.Value);
                        if ((int)Session["special"] == 0)
                        {
                            p.COST = GetCost(c.Value);
                        }
                        else
                        {
                            p.COST = 0;
                        }
                        cwm.AddToPACKAGE(p);
                    }
                }
                cwm.SaveChanges();
            }
            //CrystalReport1 cr = new CrystalReport1();
            //cr.SetDataSource(
        }
Exemplo n.º 3
0
        private int AddNewCar(string cname, int cclass)
        {
            CAR c = new CAR();

            c.CNAME   = cname;
            c.IDCLASS = cclass;
            using (CWMEntities cwm = new CWMEntities(EnCon))
            {
                cwm.AddToCAR(c);
                cwm.SaveChanges();
            }
            return(c.ID);
        }
Exemplo n.º 4
0
        private void AddNewPackage(int idjob)
        {
            PACKAGE p;

            using (CWMEntities cwm = new CWMEntities(EnCon))
            {
                foreach (ListItem c in chblPrice.Items)
                {
                    if (c.Selected)
                    {
                        p         = new PACKAGE();
                        p.IDJOB   = idjob;
                        p.IDPRICE = int.Parse(c.Value);
                        if (ddlSpecial.Text == "НЕТ")
                        {
                            p.COST = GetCost(c.Value);
                        }
                        else
                        {
                            p.COST = 0;
                        }

                        cwm.AddToPACKAGE(p);
                    }
                }
                DeletedServices = Session["delp"] as List <int>;
                foreach (int i in DeletedServices)
                {
                    p         = new PACKAGE();
                    p.IDJOB   = idjob;
                    p.IDPRICE = int.Parse(i.ToString());
                    if (ddlSpecial.Text == "НЕТ")
                    {
                        p.COST = GetCost(i.ToString());
                    }
                    else
                    {
                        p.COST = 0;
                    }

                    p.DELETED = true;
                    cwm.AddToPACKAGE(p);
                }
                cwm.SaveChanges();
            }
        }
Exemplo n.º 5
0
        protected void bAdd_Click(object sender, EventArgs e)
        {
            JOB SessionJob = (JOB)Session["JOB"];

            try
            {
                int special = (int)Session["special"];
                if (special == 0)
                {
                    SessionJob.TOTALCOST = GetTotalCost();
                }
                else
                {
                    SessionJob.TOTALCOST = 0;
                }

                /*if (chbPlus_50.Checked)
                 * {
                 *  J.PLUS_50 = true;
                 * }*/
                using (CWMEntities cwm = new CWMEntities(EnCon))
                {
                    cwm.AddToJOB(SessionJob);
                    cwm.SaveChanges();
                    AddNewPackage(SessionJob.ID);
                }
            }
            catch (Exception ex)
            {
                lError.Text  = "Ошибка при добавлении задания! Попробуйте обновить страницу и попробовать еще раз. " + ex.Message;// +ex.InnerException.Message;
                bAdd.Enabled = true;
                return;
            }
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "success", @"alert('Работа успешно добавлена!');location = ""Default.aspx""", true);
            //Response.Redirect(@"~\default.aspx");
            //bAdd.Enabled = true;
        }
Exemplo n.º 6
0
        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");
        }