Exemple #1
0
 void FillStudentData(dlgStudent dlg, StudentAllocation S)
 {
     dlg.Text            = "Edytuj dane ucznia";
     dlg.cbKlasa.Enabled = false;
     dlg.cbKlasa.Items.Add(S.StudentClass);
     dlg.cbKlasa.SelectedIndex      = 0;
     dlg.cbMiejsceUr.DataSource     = City.ComboItems.GetCities();
     dlg.cbMiejsceZam.DataSource    = City.ComboItems.GetCities();
     dlg.cbMiejsceUr.SelectedIndex  = City.ComboItems.GetCityIndex(S.Student.BirthPlace.ID, dlg.cbMiejsceUr.Items);
     dlg.cbMiejsceZam.SelectedIndex = City.ComboItems.GetCityIndex(S.Student.ResidencePlace.ID, dlg.cbMiejsceZam.Items);
     dlg.txtImie.Text            = S.Student.FirstName;
     dlg.txtImie2.Text           = S.Student.SecondName;
     dlg.txtImieMatki.Text       = S.Student.MotherFirstName;
     dlg.txtImieOjca.Text        = S.Student.FatherFirstName;
     dlg.txtNazwisko.Text        = S.Student.LastName;
     dlg.txtNazwiskoMatki.Text   = S.Student.MotherLastName;
     dlg.txtNazwiskoOjca.Text    = S.Student.FatherLastName;
     dlg.txtNrArkusza.Text       = S.Student.RegistryNo;
     dlg.txtUlica.Text           = S.Student.StreetName;
     dlg.txtNrDomu.Text          = S.Student.PropertyNo;
     dlg.txtNrMieszkania.Text    = S.Student.ApartmentNo;
     dlg.txtPesel.Text           = S.Student.Pesel;
     dlg.txtTelefon.Text         = S.Student.PhoneNo;
     dlg.txtTelKom1.Text         = S.Student.MobilePhoneNo;
     dlg.txtTelKom2.Text         = S.Student.MobilePhoneNo2;
     dlg.txtUlica.Text           = S.Student.SecondName;
     dlg.dtDataAktywacji.Value   = S.StartDate;
     dlg.dtDataDeaktywacji.Value = S.EndDate;
     dlg.nudNrwDzienniku.Value   = S.StudentNo;
     dlg.chkSex.Checked          = S.Student.Sex > 0;
     dlg.dtDataUr.Value          = S.Student.BirthDate;
 }
Exemple #2
0
 async Task <int> UpdateStudentAllocationAsync(dlgStudent dlg, int idAllocation)
 {
     using (var scope = AppSession.TypeContainer.BeginLifetimeScope())
     {
         var dbs = scope.Resolve <IDataBaseService>();
         return(await dbs.UpdateRecordAsync(StudentSQL.UpdateStudentAllocation(), CreateAllocationParamWithValue(dlg, idAllocation)));
     }
 }
Exemple #3
0
        IDictionary <string, object> CreateStudentParamWithValue(int idStudent, dlgStudent dlg)
        {
            var sqlParamWithValue = new Dictionary <string, object>();

            sqlParamWithValue.Add("@ID", idStudent);
            sqlParamWithValue.Add("@Nazwisko", dlg.txtNazwisko.Text.Trim());
            sqlParamWithValue.Add("@Imie", dlg.txtImie.Text.Trim());
            sqlParamWithValue.Add("@Imie2", dlg.txtImie2.Text.Trim());
            string Nr = null;

            if (dlg.txtNrArkusza.Text.Trim().Length > 0)
            {
                Nr = dlg.txtNrArkusza.Text.Trim();
            }
            sqlParamWithValue.Add("@NrArkusza", Nr);
            sqlParamWithValue.Add("@ImieOjca", dlg.txtImieOjca.Text.Trim());
            sqlParamWithValue.Add("@NazwiskoOjca", dlg.txtNazwiskoOjca.Text.Trim());
            sqlParamWithValue.Add("@ImieMatki", dlg.txtImieMatki.Text.Trim());
            sqlParamWithValue.Add("@NazwiskoMatki", dlg.txtNazwiskoMatki.Text.Trim());
            sqlParamWithValue.Add("@DataUr", dlg.dtDataUr.Value);
            sqlParamWithValue.Add("@Pesel", dlg.txtPesel.Text.Trim());
            int?CityID = null;

            if (((City)dlg.cbMiejsceUr.SelectedItem).ID != 0)
            {
                CityID = ((City)dlg.cbMiejsceUr.SelectedItem).ID;
            }
            sqlParamWithValue.Add("@IdMiejsceUr", CityID);
            CityID = null;
            if (((City)dlg.cbMiejsceZam.SelectedItem).ID != 0)
            {
                CityID = ((City)dlg.cbMiejsceZam.SelectedItem).ID;
            }
            sqlParamWithValue.Add("@IdMiejsceZam", CityID);
            sqlParamWithValue.Add("@Ulica", dlg.txtUlica.Text.Trim());
            sqlParamWithValue.Add("@NrDomu", dlg.txtNrDomu.Text.Trim());
            sqlParamWithValue.Add("@NrMieszkania", dlg.txtNrMieszkania.Text.Trim());
            sqlParamWithValue.Add("@Tel", dlg.txtTelefon.Text.Trim());
            sqlParamWithValue.Add("@TelKom1", dlg.txtTelKom1.Text.Trim());
            sqlParamWithValue.Add("@TelKom2", dlg.txtTelKom2.Text.Trim());
            sqlParamWithValue.Add("@Man", dlg.chkSex.Checked);
            sqlParamWithValue.Add("@User", UserSession.User.Login);
            sqlParamWithValue.Add("@IP", AppSession.HostIP);

            return(sqlParamWithValue);
        }
Exemple #4
0
        void AddNew()
        {
            if (!HasWritePrivilage())
            {
                return;
            }
            using (var dlg = new dlgStudent(true))
            {
                dlg.cbMiejsceUr.DataSource  = City.ComboItems.GetCities();
                dlg.cbMiejsceZam.DataSource = City.ComboItems.GetCities();

                dlg.cbKlasa.SelectedIndexChanged += dlg.cbKlasa_SelectedIndexChanged;
                dlg.NewRecordAdded += NewRecord;
                dlg.ShowDialog();
                dlg.NewRecordAdded -= NewRecord;
                dlg.cbKlasa.SelectedIndexChanged -= dlg.cbKlasa_SelectedIndexChanged;
            }
        }
Exemple #5
0
        IDictionary <string, object> CreateAllocationParamWithValue(dlgStudent dlg, int idAllocation)
        {
            var sqlParamWithValue = new Dictionary <string, object>();

            byte?Nr = null;

            if (dlg.nudNrwDzienniku.Value > 0)
            {
                Nr = (byte)dlg.nudNrwDzienniku.Value;
            }

            sqlParamWithValue.Add("@ID", idAllocation);
            sqlParamWithValue.Add("@NrwDzienniku", Nr);
            sqlParamWithValue.Add("@DataAktywacji", dlg.dtDataAktywacji.Value);
            sqlParamWithValue.Add("@DataDeaktywacji", dlg.dtDataDeaktywacji.Value);
            sqlParamWithValue.Add("@User", UserSession.User.Login);
            sqlParamWithValue.Add("@IP", AppSession.HostIP);

            return(sqlParamWithValue);
        }
Exemple #6
0
        void EditStudent()
        {
            var S = olvStudent.SelectedObject as StudentAllocation;

            if (S == null)
            {
                return;
            }
            if (!HasWritePrivilage(S.StudentClass.ID))
            {
                return;
            }
            using (var dlg = new dlgStudent(false))
            {
                FillStudentData(dlg, S);

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        var Student    = UpdateStudentAsync(dlg, S.Student.ID);
                        var Allocation = UpdateStudentAllocationAsync(dlg, S.ID);
                        if (Student.Result > 0 && Allocation.Result > 0)
                        {
                            NewRecord(S.Student.ID);
                            return;
                        }
                        throw new Exception("Aktualizacja danych nie powiodła się!");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }