Example #1
0
        private void EditSchoolClass()
        {
            try
            {
                var SC = olvKlasa.SelectedObject as SchoolClass;
                using (var dlg = new dlgSchoolClass(false))
                {
                    FillDialog(dlg, SC);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (UpdateData(dlg, SC).Result > 0)
                        {
                            NewRecord(SC.ID);
                            return;
                        }
                        throw new Exception("Aktualizacja danych nie powiodła się!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
 private async Task <int> UpdateData(dlgSchoolClass dlg, SchoolClass SC)
 {
     using (var scope = AppSession.TypeContainer.BeginLifetimeScope())
     {
         var dbs = scope.Resolve <IDataBaseService>();
         return(await dbs.UpdateRecordAsync(SchoolClassSQL.UpdateSchoolClass(), CreateUpdateParams(dlg, SC.ID)));
     }
 }
Example #3
0
 private void cmdAddNew_Click(object sender, EventArgs e)
 {
     using (var dlg = new dlgSchoolClass(true))
     {
         dlg.NewRecordAdded += NewRecord;
         dlg.ShowDialog();
         dlg.NewRecordAdded -= NewRecord;
     }
 }
Example #4
0
        private void FillDialog(dlgSchoolClass dlg, SchoolClass SC)
        {
            dlg.Text            = "Edycja danych";
            dlg.cbKlasa.Enabled = false;

            dlg.cbKlasa.Items.Add(SC.ClassCode);
            dlg.cbKlasa.SelectedIndex = 0;
            dlg.chkVirtual.Checked    = SC.IsVirtual > 0;
            dlg.cmdOK.Enabled         = true;
        }
Example #5
0
        IDictionary <string, Object> CreateUpdateParams(dlgSchoolClass dlg, int id)
        {
            var sqlParamWithValue = new Dictionary <string, object>();

            sqlParamWithValue.Add("@ID", id);
            sqlParamWithValue.Add("@NazwaKlasy", dlg.txtNazwa.Text.Trim());
            sqlParamWithValue.Add("@IsVirtual", dlg.chkVirtual.Checked);
            sqlParamWithValue.Add("@User", UserSession.User.Login);
            sqlParamWithValue.Add("@IP", AppSession.HostIP);
            return(sqlParamWithValue);
        }