Пример #1
0
        public ClientView(int pIdClient)
        {
            InitializeComponent();
            idClient = pIdClient;

            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    ClientView_Result clv = contextDB.ClientView(idClient).FirstOrDefault();

                    if (clv.famil != null)
                    {
                        txtbFamilCl.Text = clv.famil;
                    }
                    if (clv.f_name != null)
                    {
                        txtbNameCl.Text = clv.f_name;
                    }
                    if (clv.s_name != null)
                    {
                        txtbSurnameCl.Text = clv.s_name;
                    }
                    if (clv.number_pasp != null)
                    {
                        txtbPasp.Text = clv.number_pasp;
                    }
                    if (clv.tel != null)
                    {
                        txtbTel.Text = clv.tel;
                    }

                    if (clv.city_town != null)
                    {
                        txtbCityTown.Text = clv.city_town;
                    }

                    if (clv.city_town == "Москва")
                    {
                        rbtnMoscow.IsChecked = true;
                    }
                    else
                    {
                        rbtnMO.IsChecked = true;
                    }

                    if (clv.street != null)
                    {
                        txtbStreet.Text = clv.street;
                    }
                    if (clv.house != null)
                    {
                        txtbHouse.Text = clv.house.ToString();
                    }
                    if (clv.korp != null)
                    {
                        txtbKorp.Text = clv.korp;
                    }
                    if (clv.flat != null)
                    {
                        txtbFlat.Text = clv.flat.ToString();
                    }
                    if (clv.podezd != null)
                    {
                        txtbPodezd.Text = clv.podezd.ToString();
                    }
                    if (clv.etag != null)
                    {
                        txtbEtag.Text = clv.etag.ToString();
                    }
                    if (clv.domofon != null)
                    {
                        txtbDomofon.Text = clv.domofon;
                    }

                    if (clv.id_metro != null)
                    {
                        txtBMetro.Text = contextDB.Metro
                                         .Where(c => c.id_metro == clv.id_metro)
                                         .FirstOrDefault()
                                         .name_metro
                                         .ToString();
                    }


                    if (clv.raion != null)
                    {
                        txtbRajon.Text = clv.raion;
                    }


                    if (clv.kol_hol != null)
                    {
                        txtbKolHol.Text = clv.kol_hol.ToString();
                    }
                    if (clv.id_hol_schetch != null)
                    {
                        txtbMarkaHol.Text = contextDB.Request_snab.Where(c => c.id_hol_schetch == clv.id_hol_schetch)
                                            .FirstOrDefault().H_Schetchik.marka_hol_schetch.ToString();
                    }
                    if (clv.kol_gor != null)
                    {
                        txtbKolGor.Text = clv.kol_gor.ToString();
                    }
                    if (clv.id_gor_schetch != null)
                    {
                        txtbMarkaGor.Text = contextDB.Request_snab.Where(c => c.id_gor_schetch == clv.id_gor_schetch)
                                            .FirstOrDefault().G_Schetchik.marka_gor_schetch.ToString();
                    }
                    if (clv.kol_teplo != null)
                    {
                        txtbKolTeplo.Text = clv.kol_teplo.ToString();
                    }
                    if (clv.id_teplo_schetch != null)
                    {
                        txtbMarkaTeplo.Text = contextDB.Request_snab.Where(c => c.id_teplo_schetch == clv.id_teplo_schetch)
                                              .FirstOrDefault().Teplo_Schetchik.marka_teplo_schetch.ToString();
                    }

                    if (clv.datetime_vyezda_montazhnika != null)
                    {
                        txtbVyezd.Text = ((DateTime)clv.datetime_vyezda_montazhnika).ToString("dd.MM.yyyy");
                    }

                    if (clv.date_execution != null)
                    {
                        txtbDateExecution.Text = ((DateTime)clv.date_execution).ToString("dd.MM.yyyy");
                    }

                    if (clv.id_mont != null)
                    {
                        txtbMont.Text = contextDB.Request_attachment
                                        .Where(c => c.id_mont == clv.id_mont)
                                        .FirstOrDefault()
                                        .Montazhniki.full_name
                                        .ToString();
                    }

                    if (clv.sum_contract != null)
                    {
                        txtbSum.Text = clv.sum_contract.ToString();
                    }

                    if (clv.id_request != null)
                    {
                        txtbNumberRequest.Text = clv.id_request.ToString();
                    }
                    if (clv.date_request != null)
                    {
                        txtbDateReg.Text = ((DateTime)clv.date_request).ToString("dd.MM.yyyy");
                    }
                    if (clv.dispetcher != null)
                    {
                        txtbDispR.Text = clv.dispetcher;
                    }
                    if (clv.kind_of_work != null)
                    {
                        txtbKindOfWork.Text = contextDB.Request_reception
                                              .Where(c => c.id_kind_of_work == clv.id_kind_of_work)
                                              .FirstOrDefault()
                                              .Kind_of_work
                                              .kind_of_work1
                                              .ToString();
                    }
                    if (clv.status != null)
                    {
                        txtbStatus.Text = clv.status;
                    }

                    if (clv.date_otkaza != null)
                    {
                        txtbDateOtkaz.Text = ((DateTime)clv.date_otkaza).ToString("dd.MM.yyyy");
                    }
                    if (clv.reason_otkaza != null)
                    {
                        txtbReasonOtkaza.Text = clv.reason_otkaza;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Пример #2
0
        public ClientUpdate(int pIdClient)
        {
            InitializeComponent();
            idClient = pIdClient;

            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    ClientView_Result clv = contextDB.ClientView(idClient).FirstOrDefault();
                    idAdrInst = Convert.ToInt32(clv.id_adr_installation);
                    idClient  = Convert.ToInt32(clv.id_client);
                    idReqSnab = Convert.ToInt32(clv.id_request_snab);
                    idReqAtt  = Convert.ToInt32(clv.id_request_execution);
                    idReqBuhg = Convert.ToInt32(clv.id_request_buhg);
                    idReqRec  = Convert.ToInt32(clv.id_request);

                    if (clv.famil != null)
                    {
                        txtbFamilCl.Text = clv.famil;
                    }
                    if (clv.f_name != null)
                    {
                        txtbNameCl.Text = clv.f_name;
                    }
                    if (clv.s_name != null)
                    {
                        txtbSurnameCl.Text = clv.s_name;
                    }
                    if (clv.number_pasp != null)
                    {
                        txtbPasp.Text = clv.number_pasp;
                    }
                    if (clv.tel != null)
                    {
                        txtbTel.Text = clv.tel;
                    }
                    if (clv.city_town != null)
                    {
                        txtbCityTown.Text = clv.city_town;
                    }

                    if (clv.city_town == "Москва")
                    {
                        rbtnMoscow.IsChecked = true;
                    }
                    else
                    {
                        rbtnMO.IsChecked = true;
                    }

                    if (clv.street != null)
                    {
                        txtbStreet.Text = clv.street;
                    }
                    if (clv.house != null)
                    {
                        txtbHouse.Text = clv.house.ToString();
                    }
                    if (clv.korp != null)
                    {
                        txtbKorp.Text = clv.korp;
                    }
                    if (clv.flat != null)
                    {
                        txtbFlat.Text = clv.flat.ToString();
                    }
                    if (clv.podezd != null)
                    {
                        txtbPodezd.Text = clv.podezd.ToString();
                    }
                    if (clv.etag != null)
                    {
                        txtbEtag.Text = clv.etag.ToString();
                    }
                    if (clv.domofon != null)
                    {
                        txtbDomofon.Text = clv.domofon;
                    }

                    var dataMetro = from me in contextDB.Metro
                                    select new { me.id_metro, me.name_metro };

                    cmbMetro.ItemsSource       = dataMetro.ToList();
                    cmbMetro.DisplayMemberPath = "name_metro";
                    cmbMetro.SelectedValuePath = "id_metro";

                    if (clv.id_metro != null)
                    {
                        cmbMetro.SelectedValue = clv.id_metro;
                    }

                    if (clv.raion != null)
                    {
                        txtbRajon.Text = clv.raion;
                    }

                    if (clv.kol_hol != null)
                    {
                        txtbKolHol.Text = clv.kol_hol.ToString();
                    }

                    var dataMarkaHol = from mh in contextDB.H_Schetchik
                                       select new { mh.id_hol_schetch, mh.marka_hol_schetch };
                    cmbMarkaHol.ItemsSource       = dataMarkaHol.ToList();
                    cmbMarkaHol.DisplayMemberPath = "marka_hol_schetch";
                    cmbMarkaHol.SelectedValuePath = "id_hol_schetch";

                    if (clv.id_hol_schetch != null)
                    {
                        cmbMarkaHol.SelectedValue = clv.id_hol_schetch;
                    }
                    if (clv.kol_gor != null)
                    {
                        txtbKolGor.Text = clv.kol_gor.ToString();
                    }

                    var dataMarkaGor = from mg in contextDB.G_Schetchik
                                       select new { mg.id_gor_schetch, mg.marka_gor_schetch };
                    cmbMarkaGor.ItemsSource       = dataMarkaGor.ToList();
                    cmbMarkaGor.DisplayMemberPath = "marka_gor_schetch";
                    cmbMarkaGor.SelectedValuePath = "id_gor_schetch";

                    if (clv.id_gor_schetch != null)
                    {
                        cmbMarkaGor.SelectedValue = clv.id_gor_schetch;
                    }
                    if (clv.kol_teplo != null)
                    {
                        txtbKolTeplo.Text = clv.kol_teplo.ToString();
                    }

                    var dataMarkaTeplo = from mt in contextDB.Teplo_Schetchik
                                         select new { mt.id_teplo_schetch, mt.marka_teplo_schetch };
                    cmbMarkaTeplo.ItemsSource       = dataMarkaTeplo.ToList();
                    cmbMarkaTeplo.DisplayMemberPath = "marka_teplo_schetch";
                    cmbMarkaTeplo.SelectedValuePath = "id_teplo_schetch";

                    if (clv.id_teplo_schetch != null)
                    {
                        cmbMarkaTeplo.SelectedValue = clv.id_teplo_schetch;
                    }

                    if (clv.datetime_vyezda_montazhnika != null)
                    {
                        txtbVyezd.Text = ((DateTime)clv.datetime_vyezda_montazhnika).ToString("dd.MM.yyyy");
                    }

                    if (clv.date_execution != null)
                    {
                        txtbDateExecution.Text = ((DateTime)clv.date_execution).ToString("dd.MM.yyyy");
                    }

                    var dataMont = from m in contextDB.Montazhniki
                                   select new { m.id_mont, m.full_name };
                    cmbMont.ItemsSource       = dataMont.ToList();
                    cmbMont.DisplayMemberPath = "full_name";
                    cmbMont.SelectedValuePath = "id_mont";

                    if (clv.id_mont != null)
                    {
                        cmbMont.SelectedValue = clv.id_mont;
                    }

                    if (clv.dispetcher != null)
                    {
                        txtbDisp.Text = clv.dispetcher;
                    }

                    if (clv.date_request != null)
                    {
                        txtbDTRegistr.Text = ((DateTime)clv.date_request).ToString("dd.MM.yyyy");
                    }
                    if (clv.sum_contract != null)
                    {
                        txtbSum.Text = clv.sum_contract.ToString();
                    }

                    if (clv.id_request != null)
                    {
                        txtbNumberRequest.Text = clv.id_request.ToString();
                    }
                    if (clv.date_otkaza != null)
                    {
                        txtbDateOtkaz.Text = ((DateTime)clv.date_otkaza).ToString("dd.MM.yyyy");
                    }
                    if (clv.reason_otkaza != null)
                    {
                        txtbReasonOtkaza.Text = clv.reason_otkaza;
                    }

                    var dataKindOfWork = from k in contextDB.Kind_of_work
                                         select new { k.id_kind_of_work, k.kind_of_work1 };
                    cmbKindOfWork.ItemsSource       = dataKindOfWork.ToList();
                    cmbKindOfWork.DisplayMemberPath = "kind_of_work1";
                    cmbKindOfWork.SelectedValuePath = "id_kind_of_work";

                    if (clv.kind_of_work != null)
                    {
                        cmbKindOfWork.SelectedValue = clv.id_kind_of_work;
                    }

                    var dataStatus = from s in contextDB.Status
                                     select new { s.id_status, s.status1 };
                    cmbStatus.ItemsSource       = dataStatus.ToList();
                    cmbStatus.DisplayMemberPath = "status1";
                    cmbStatus.SelectedValuePath = "id_status";

                    if (clv.status != null)
                    {
                        cmbStatus.SelectedValue = clv.id_status;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

            try
            {
                using (CRM_magEntities contextDB = new CRM_magEntities())
                {
                    txtbNumberRequest.IsEnabled = false;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }