Exemple #1
0
 public static List<District> SelectAll()
 {
     List<District> list = new List<District>();
     string spSelectAll = "spGetAllDistrict";
     SqlDataReader rd = DataProvider.ExecuteQueryWithDataReader(spSelectAll, CommandType.StoredProcedure);
     if (rd.HasRows)
     {
         while (rd.Read())
         {
             District r = new District()
             {
                 DistrictID = rd.GetInt32(0),
                 NameOfDistrict = rd.GetString(1)
             };
             list.Add(r);
         }
     }
     return list.OrderBy(p => p.DistrictID).ToList();
 }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                District dis = new District();
                dis.DistrictID = (DistrictBLL.GetCurrentIden() + 1);
                dis.NameOfDistrict = txtNameOfDistrict.Text;
                DistrictBLL.AddDistrict(dis);
                System.Windows.Forms.MessageBox.Show("Successfully");
                if (AddFinshed != null)
                {
                    AddFinshed(dis);
                }

            }
            catch (Exception g)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + g.Message);
            }
            finally
            {
                this.Close();
            }
        }
 private void updateTable(District dis)
 {
     dt.Rows.Add(dis.DistrictID,dis.NameOfDistrict);
 }
Exemple #4
0
 public static bool AddDistrict(District dis)
 {
     return DistrictData.InsertDistrict(dis);
 }
Exemple #5
0
 public static bool InsertDistrict(District dis)
 {
     string sql = "spAddDistrict";
     SqlParameter NameOfDistrict = new SqlParameter("Name", dis.NameOfDistrict);
     return DataProvider.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, NameOfDistrict);
 }