예제 #1
0
        void EditSchoolType()
        {
            try
            {
                if (olvSchoolType.SelectedObject == null)
                {
                    return;
                }
                using (var dlg = new dlgSchoolType())
                {
                    var T = (SchoolType)olvSchoolType.SelectedObject;
                    FillDialog(dlg, T);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (UpdateSchoolTypeAsync(dlg, T.ID).Result > 0)
                        {
                            GetData(olvSchoolType);
                            SeekHelper.SetListItem <SchoolType, int>(T.ID, "ID", olvSchoolType);
                            return;
                        }
                        throw new Exception("Aktualizacja danych nie powiodła się!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
 private async Task <int> UpdateSchoolTypeAsync(dlgSchoolType dlg, int id)
 {
     using (var scope = AppSession.TypeContainer.BeginLifetimeScope())
     {
         var dbs = scope.Resolve <IDataBaseService>();
         return(await dbs.UpdateRecordAsync(SchoolSQL.UpdateSchoolType(), CreateUpdateParams(dlg, id)));
     }
 }
예제 #3
0
 private void cmdAddNew_Click(object sender, EventArgs e)
 {
     using (var dlg = new dlgSchoolType())
     {
         dlg.IsNewMode       = true;
         dlg.NewRecordAdded += RefreshData;
         dlg.ShowDialog();
         dlg.NewRecordAdded -= RefreshData;
     }
 }
예제 #4
0
        IDictionary <string, object> CreateUpdateParams(dlgSchoolType dlg, int id)
        {
            var sqlParamWithValue = new Dictionary <string, object>();

            sqlParamWithValue.Add("@ID", id);
            sqlParamWithValue.Add("@Nazwa", dlg.txtNazwa.Text.Trim());
            sqlParamWithValue.Add("@Opis", dlg.txtOpis.Text.Trim());
            sqlParamWithValue.Add("@User", UserSession.User.Login);
            sqlParamWithValue.Add("@IP", AppSession.HostIP);
            return(sqlParamWithValue);
        }
예제 #5
0
 private void FillDialog(dlgSchoolType dlg, SchoolType T)
 {
     dlg.txtNazwa.Text = T.Name;
     dlg.txtOpis.Text  = T.Description;
 }