Example #1
0
        IDictionary <string, object> CreateUpdateParams(dlgSchool dlg, int id)
        {
            var    sqlParamWithValue = new Dictionary <string, object>();
            string NipNumber         = null;

            if (dlg.txtNip.Text.Length > 0)
            {
                NipNumber = dlg.txtNip.Text;
            }
            int?CityID = null;

            if (((City)dlg.cbMiejscowosc.SelectedItem).ID != 0)
            {
                CityID = ((City)dlg.cbMiejscowosc.SelectedItem).ID;
            }
            sqlParamWithValue.Add("@ID", id);
            sqlParamWithValue.Add("@Nazwa", dlg.txtNazwa.Text.Trim());
            sqlParamWithValue.Add("@Alias", dlg.txtAlias.Text.Trim());
            sqlParamWithValue.Add("@Nip", NipNumber);
            sqlParamWithValue.Add("@Ulica", dlg.txtUlica.Text.Trim());
            sqlParamWithValue.Add("@Nr", dlg.txtNr.Text.Trim());
            sqlParamWithValue.Add("@IdMiejscowosc", CityID);
            sqlParamWithValue.Add("@Telefon", dlg.txtTel.Text.Trim());
            sqlParamWithValue.Add("@Fax", dlg.txtFax.Text.Trim());
            sqlParamWithValue.Add("@Email", dlg.txtEmail.Text.Trim());
            sqlParamWithValue.Add("@User", UserSession.User.Login);
            sqlParamWithValue.Add("@IP", AppSession.HostIP);
            return(sqlParamWithValue);
        }
Example #2
0
        private void EditSchool()
        {
            try
            {
                using (var dlg = new dlgSchool())
                {
                    var S = olvSzkola.SelectedObject as School;
                    FillDialog(dlg, S);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        //IsqlCommand cmd = new SqlCommand();
                        if (UpdateDataAsync(dlg, S.ID).Result > 0)
                        {
                            NewRecord(S.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 #3
0
 private async Task <int> UpdateDataAsync(dlgSchool dlg, int id)
 {
     using (var scope = AppSession.TypeContainer.BeginLifetimeScope())
     {
         var dbs = scope.Resolve <IDataBaseService>();
         return(await dbs.UpdateRecordAsync(SchoolSQL.UpdateSchool(), CreateUpdateParams(dlg, id)));
     }
 }
Example #4
0
 private void cmdAddNew_Click(object sender, EventArgs e)
 {
     using (var dlg = new dlgSchool())
     {
         dlg.IsNewMode          = true;
         dlg.cbTyp.DataSource   = cbSchoolType.DataSource;
         dlg.cbTyp.SelectedItem = cbSchoolType.SelectedItem;
         dlg.NewRecordAdded    += NewRecord;
         dlg.ShowDialog();
         dlg.NewRecordAdded -= NewRecord;
     }
 }
Example #5
0
        private void FillDialog(dlgSchool dlg, School S)
        {
            dlg.Text          = "Edycja danych szkoły";
            dlg.IsNewMode     = false;
            dlg.cbTyp.Enabled = false;

            dlg.cbTyp.DataSource = cbSchoolType.DataSource;
            SetSchoolType(S.SchoolType.ID, dlg.cbTyp);
            dlg.txtNazwa.Text = S.Name;
            dlg.txtAlias.Text = S.Alias;
            dlg.txtEmail.Text = S.Email;
            dlg.txtFax.Text   = S.FaxNo;
            dlg.txtNip.Text   = S.Nip;
            dlg.txtNr.Text    = S.PlaceNo;
            dlg.txtTel.Text   = S.PlaceNo;
            dlg.txtUlica.Text = S.StreetName;
            //dlgSchool.SetCity(S.Location.ID, dlg.cbMiejscowosc);
            dlg.cbMiejscowosc.SelectedIndex = City.ComboItems.GetCityIndex(S.Location.ID, dlg.cbMiejscowosc.Items);
        }