コード例 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvCity.SelectedRows.Count <= 0)
            {
                return;
            }

            DialogResult dr = MessageBox.Show("Are you sure ?", "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dr != DialogResult.Yes)
            {
                return;
            }

            DAL.City ct = new DAL.City();
            ct.Id = Convert.ToInt32(dgvCity.SelectedRows[0].Cells["colId"].Value);
            if (ct.Delete())
            {
                MessageBox.Show("Deleted");
                btnSearch.PerformClick();
            }
            else
            {
                MessageBox.Show(ct.Error);
            }
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int er = 0;

            if (txtName.Text == "")
            {
                er++;
                ep.SetError(txtName, "Required");
            }
            if (cmbCountry.SelectedValue == null || cmbCountry.SelectedValue.ToString() == "")
            {
                er++;
                ep.SetError(cmbCountry, "Required");
            }
            if (er > 0)
            {
                return;
            }

            DAL.City city = new DAL.City();
            city.Id        = Id;
            city.Name      = txtName.Text;
            city.CountryId = Convert.ToInt32(cmbCountry.SelectedValue);
            if (city.Update())
            {
                MessageBox.Show(@"Data Updated");
            }
            else
            {
                MessageBox.Show(city.Error);
            }
        }
コード例 #3
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (proGrid1.SelectedRows.Count <= 0)
            {
                return;
            }

            DialogResult confurmDelete = MessageBox.Show("Are you sure?", "Confirmation.", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (confurmDelete != DialogResult.Yes)
            {
                return;
            }

            DAL.City city = new DAL.City();
            string   ids  = "";

            for (int i = 0; i < proGrid1.SelectedRows.Count; i++)
            {
                ids += proGrid1.SelectedRows[i].Cells["ColId"].Value.ToString() + ", ";
            }

            ids = ids.Substring(0, ids.Length - 2);

            if (city.Delete(ids))
            {
                MessageBox.Show("Data deleted");
                buttonSearch.PerformClick();
            }
            else
            {
                MessageBox.Show(city.Error);
            }
        }
コード例 #4
0
        private void cmbCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            int?countryId = cmbCountry.SelectedValue as int?;

            if (countryId == null)
            {
                return;
            }
            DAL.City city = new DAL.City();
            cmbCity.Source(city.SelectCountry(countryId));
        }
コード例 #5
0
 public static void SaveCity(dtoCity city)
 {
     DAL.City NewCity = dtoCity.castToDal(city);
     //School ExistSchool = Entities.context.Schools.FirstOrDefault(p => p.SchoolId == NewSchool.SchoolId);
     //if (ExistSchool != null)
     //{
     //    Entities.context.Schools.Remove(ExistSchool);
     //}
     context.Cities.Add(NewCity);
     context.SaveChanges();
 }
コード例 #6
0
 public static DTO.ChildWithFamilyDetails GetChildWithDetailsById(string childId)
 {
     DAL.Child  child  = new DAL.Child();
     DAL.Family family = new DAL.Family();
     DAL.City   city   = new DAL.City();
     DAL.School school = new DAL.School();
     child  = context.Childs.FirstOrDefault(p => p.IdentityNum == childId);
     family = context.Families.FirstOrDefault(p => p.FamilyId == child.FamilyId);
     school = context.Schools.FirstOrDefault(p => p.SchoolId == child.SchoolId);
     city   = context.Cities.FirstOrDefault(p => p.CityId == family.CityId);
     DTO.ChildWithFamilyDetails childWithDetails = new DTO.ChildWithFamilyDetails
     {
         IdentityNum      = child.IdentityNum,
         FamilyId         = child.FamilyId,
         FirstName        = child.FirstName,
         FamilyName       = family.FamilyName,
         FatherFirstName  = family.FatherFirstName,
         MotherFirstName  = family.MotherFirstName,
         NumOfChildren    = family.NumOfChildren,
         CityId           = family.CityId,
         Address          = family.Address,
         Telephone        = family.Telephone,
         Cellular1        = family.Cellular1,
         Cellular2        = family.Cellular2,
         Kind             = child.Kind,
         BirthDate        = child.BirthDate,
         PlaceInFamily    = child.PlaceInFamily,
         SchoolId         = child.SchoolId,
         Grade            = child.Grade,
         JoiningDate      = child.JoiningDate,
         ViturSodiutFrom  = child.ViturSodiutFrom,
         PreviousCare     = child.PreviousCare,
         Note             = child.Note,
         IsActive         = child.IsActive,
         IsMunicipality   = child.IsMunicipality,
         sumAfterDiscount = child.sumAfterDiscount,
         SchoolName       = school == null ? null : school.SchoolName,
         CityName         = city == null ? null : city.CityName
     };
     return(childWithDetails);
 }
コード例 #7
0
ファイル: City.cs プロジェクト: hihua/hihuacode
 public City()
 {
     d_City = new DAL.City();
 }