private void btnOborVedPoSkladu_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    dateFrom = (DateTime)dtpDateFrom.SelectedDate;
                    dateTo   = (DateTime)dtpDateTo.SelectedDate;
                    Params p = contextDB.Params.Find(1);
                    p.p_date_from = dateFrom;
                    p.p_date_to   = dateTo;
                    contextDB.SaveChanges();

                    var v = contextDB.spOborotkaSklad(dateFrom, dateTo);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            if (_pr != null)
            {
                try
                {
                    _pr.Kill();
                }
                catch { };
            }
            //_pr = Process.Start("D:\\Fujitsu\\CRM\\2019-06-12_1\\CRM\\CRM_Access.accdb", "/X mcrOborotkaSklad");
            _pr = Process.Start("D:\\Projects\\CRM\\CRM_Access.accdb", "/X mcrOborotkaSklad");
        }
Exemple #2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    Params p = contextDB.Params.Find(1);

                    p.param_int = Convert.ToInt32(txtBNomerNakladnoj.Text);
                    contextDB.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            if (_pr != null)
            {
                try
                {
                    _pr.Kill();
                }
                catch { };
            }
            //_pr = Process.Start("D:\\Fujitsu\\CRM\\2019-06-12_1\\CRM\\CRM_Access.accdb", "/X mcrRashod");
            _pr = Process.Start("D:\\Projects\\CRM\\CRM_Access.accdb", "/X mcrRashod");
        }
Exemple #3
0
        private void IntVedomost_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    Params p = contextDB.Params.Find(1);

                    p.p_date_to = (DateTime)dtCurInvent.SelectedDate;

                    contextDB.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            if (_pr != null)
            {
                try
                {
                    _pr.Kill();
                }
                catch { };
            }
            _pr = Process.Start("D:\\Projects\\CRM\\CRM_Access.accdb", "/X mcrIntVedomost");
            //_pr = Process.Start("D:\\Fujitsu\\CRM\\2019-06-12_1\\CRM\\CRM_Access.accdb", "/X mcrIntVedomost");
        }
Exemple #4
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    Rashod1 rash1 = new Rashod1();
                    rash1.data_nakl = (DateTime)dtPRashod.SelectedDate;
                    if (cmbPoluchatel.SelectedValue != null)
                    {
                        rash1.id_mont = Convert.ToInt32(cmbPoluchatel.SelectedValue);
                    }
                    contextDB.Rashod1.Add(rash1);
                    contextDB.SaveChanges();

                    idRash1 = rash1.id;
                    txtBNomerNakladnoj.Text = idRash1.ToString();

                    foreach (Rashod_2 item in rashod2s)
                    {
                        Rashod_2 rashod2 = new Rashod_2();
                        rashod2.id          = idRash1;
                        rashod2.id_material = item.id_material;

                        rashod2.kod_ed_izm = contextDB.Materialy.Find(item.id_material).id_ed_izm;


                        rashod2.kol  = item.kol;
                        rashod2.cena = item.cena;
                        contextDB.Rashod_2.Add(rashod2);
                    }

                    contextDB.SaveChanges();
                    dgRashod.ItemsSource = null;
                    dgRashod.ItemsSource = rashod2s;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    Prihod1 prih1 = new Prihod1();
                    prih1.data_prihod = (DateTime)dtpDatePrih.SelectedDate;
                    if (cmbPostavshik.SelectedValue != null)
                    {
                        prih1.id_postavsh = Convert.ToInt32(cmbPostavshik.SelectedValue);
                    }
                    contextDB.Prihod1.Add(prih1);
                    contextDB.SaveChanges();

                    idPrih1 = prih1.id;
                    txtbNumPrihOrder.Text = idPrih1.ToString();

                    foreach (Prihod2 item in prihod2s)
                    {
                        Prihod2 prihod2 = new Prihod2();
                        prihod2.id          = idPrih1;
                        prihod2.id_material = item.id_material;

                        prihod2.kod_ed_izm = contextDB.Materialy.Find(item.id_material).id_ed_izm;

                        prihod2.kol  = item.kol;
                        prihod2.cena = item.cena;
                        contextDB.Prihod2.Add(prihod2);
                    }
                    contextDB.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 private void rbtnPerezv_Checked(object sender, RoutedEventArgs e)
 {
     try
     {
         using (CRM_magEntities contextDB = new CRM_magEntities())
         {
             Perenos_request pr = new Perenos_request();
             pr.vyezd_or_perezvon = false;
             contextDB.Perenos_request.Add(pr);
             contextDB.SaveChanges();
             idPerenosReq = pr.id_perenos_request;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (CRM_magEntities contextDB = new CRM_magEntities())
         {
             foreach (var item in unsd)
             {
                 int idRA = Convert.ToInt32(contextDB.Request_reception.Find(item.NumberRequest).id_request_execution);
                 Request_attachment ra = contextDB.Request_attachment.Find(idRA);
                 ra.id_mont = item.IdMont;
             }
             contextDB.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #8
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     using (CRM_magEntities context = new CRM_magEntities())
     {
         try
         {
             foreach (var it in lstVvPervOst)
             {
                 Materialy mat = new Materialy();
                 mat                  = context.Materialy.Find(it.id_material);
                 mat.ostatok_cur      = it.ostatok_cur;
                 mat.date_ostatok_cur = (DateTime)dtVvPervOst.SelectedDate;
             }
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Error");
         }
     }
 }
        private void btnOKFizL_Click(object sender, RoutedEventArgs e)
        {
            if (IsErrorFizLico())
            {
                MessageBox.Show(sErrorFizLico, "Ошибка!");
            }
            else
            {
                try
                {
                    using (CRM_magEntities contextDB = new CRM_magEntities())
                    {
                        Client cl = new Client();

                        cl.famil       = txtbFamilCl.Text;
                        cl.f_name      = txtbNameCl.Text;
                        cl.s_name      = txtbSurnameCl.Text;
                        cl.number_pasp = txtbPasp.Text;
                        cl.tel         = txtbTel.Text;
                        contextDB.Client.Add(cl);
                        contextDB.SaveChanges();
                        idClient = cl.id_client;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }


            if (!IsErrorFizLico())
            {
                try
                {
                    using (CRM_magEntities contextDB = new CRM_magEntities())
                    {
                        Adr_installation adr = new Adr_installation();
                        if (rbtnMoscow.IsChecked == true)
                        {
                            adr.city_town = "Москва";
                        }
                        else if (rbtnMO.IsChecked == true)
                        {
                            adr.city_town = txtbCityTown.Text;
                        }
                        adr.raion = txtbRajon.Text;
                        if (txtbStreet.Text != null)
                        {
                            adr.street = txtbStreet.Text;
                        }
                        adr.house = Convert.ToInt32(txtbHouse.Text);
                        adr.korp  = txtbKorp.Text;
                        adr.flat  = Convert.ToInt32(txtbFlat.Text);
                        if (cmbMetro.SelectedValue != null)
                        {
                            adr.id_metro = Convert.ToInt32(cmbMetro.SelectedValue);
                        }

                        adr.podezd    = Convert.ToInt32(txtbPodezd.Text);
                        adr.etag      = Convert.ToInt32(txtbEtag.Text);
                        adr.domofon   = txtbDomofon.Text;
                        adr.id_client = idClient;
                        contextDB.Adr_installation.Add(adr);
                        contextDB.SaveChanges();
                        idAdrInst = adr.id_adr_installation;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }


            if (!IsErrorFizLico())
            {
                try
                {
                    using (CRM_magEntities contextDB = new CRM_magEntities())
                    {
                        Request_snab rs = new Request_snab();
                        if (cmbMarkaGor.SelectedValue != null)
                        {
                            rs.id_gor_schetch = Convert.ToInt32(cmbMarkaGor.SelectedValue);
                        }
                        if (cmbMarkaHol.SelectedValue != null)
                        {
                            rs.id_hol_schetch = Convert.ToInt32(cmbMarkaHol.SelectedValue);
                        }
                        if (cmbMarkaTeplo.SelectedValue != null)
                        {
                            rs.id_teplo_schetch = Convert.ToInt32(cmbMarkaTeplo.SelectedValue);
                        }
                        int  numbKolGor;
                        bool resultKolGor = int.TryParse(txtbKolGor.Text, out numbKolGor);
                        if (resultKolGor == true)
                        {
                            rs.kol_gor = numbKolGor;
                        }

                        int  numbKolHol;
                        bool resultKolHol = int.TryParse(txtbKolHol.Text, out numbKolHol);
                        if (resultKolHol == true)
                        {
                            rs.kol_hol = numbKolHol;
                        }

                        int  numbKolTeplo;
                        bool resultKolTeplo = int.TryParse(txtbKolTeplo.Text, out numbKolTeplo);
                        if (resultKolTeplo == true)
                        {
                            rs.kol_teplo = numbKolTeplo;
                        }

                        contextDB.Request_snab.Add(rs);
                        contextDB.SaveChanges();

                        idReqSnab = rs.id_request_snab;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }


            if (!IsErrorFizLico())
            {
                try
                {
                    using (CRM_magEntities contextDB = new CRM_magEntities())
                    {
                        Request_attachment ra = new Request_attachment();
                        ra.datetime_vyezda_montazhnika = Convert
                                                         .ToDateTime(txtbVyezd.Text);

                        if (cmbMont.SelectedValue != null)
                        {
                            ra.id_mont = Convert.ToInt32(cmbMont.SelectedValue);
                        }

                        contextDB.Request_attachment.Add(ra);
                        contextDB.SaveChanges();

                        idReqAtt = ra.id_request_execution;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }



            if (!IsErrorFizLico())
            {
                try
                {
                    using (CRM_magEntities contextDB = new CRM_magEntities())
                    {
                        Request_buhg rb = new Request_buhg();
                        decimal      sum;
                        bool         resultSum = decimal.TryParse(txtbSum.Text, out sum);
                        if (resultSum == true)
                        {
                            rb.sum_contract = sum;
                        }

                        contextDB.Request_buhg.Add(rb);
                        contextDB.SaveChanges();
                        idReqBuhg = rb.id_request_buhg;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            if (!IsErrorFizLico())
            {
                try
                {
                    using (CRM_magEntities contextDB = new CRM_magEntities())
                    {
                        Request_reception rr = new Request_reception();
                        rr.id_request_snab      = idReqSnab;
                        rr.id_request_buhg      = idReqBuhg;
                        rr.id_request_execution = idReqAtt;
                        rr.id_adr_installation  = idAdrInst;
                        rr.id_status            = 1;
                        rr.id_kind_of_work      = Convert.ToInt32(cmbKindOfWork.SelectedValue);
                        if (idPerenosReq != 0)
                        {
                            rr.id_perenos_request = idPerenosReq;
                        }
                        rr.dispetcher   = txtbDispR.Text;
                        rr.date_request = Convert.ToDateTime(txtbDateReg.Text);

                        contextDB.Request_reception.Add(rr);
                        contextDB.SaveChanges();
                        txtbNumberRequest.Text = rr.id_request.ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                if (evNewClient != null)
                {
                    evNewClient();
                }
            }
        }