Beispiel #1
0
    protected void btnXoa_Click(object sender, EventArgs e)
    {
        cls_City      cls;
        List <object> selectedKey = grvList.GetSelectedFieldValues(new string[] { "city_id" });

        if (selectedKey.Count > 0)
        {
            foreach (var item in selectedKey)
            {
                cls = new cls_City();
                tbCity checkImage = (from i in db.tbCities where i.city_id == Convert.ToInt32(item) select i).SingleOrDefault();
                if (cls.City_Xoa(Convert.ToInt32(item)))
                {
                    alert.alert_Success(Page, "Xóa thành công", "");
                }
                else
                {
                    alert.alert_Error(Page, "Xóa thất bại", "");
                }
            }
        }
        else
        {
            alert.alert_Warning(Page, "Bạn chưa chọn dữ liệu", "");
        }
    }
Beispiel #2
0
    public bool City_Them(string city_name, string city_toado, int zoom)
    {
        tbCity insert = new tbCity();

        insert.city_name = city_name;
        try
        {
            string lat   = string.Format(city_toado.Split(',')[0]);
            string longg = string.Format(city_toado.Split(',')[1]);
            insert.location_lat  = lat;
            insert.location_long = longg;
        }
        catch { }
        insert.city_zoom = zoom;
        db.tbCities.InsertOnSubmit(insert);
        try
        {
            db.SubmitChanges();
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Beispiel #3
0
    public bool City_Xoa(int city_id)
    {
        tbCity delete = db.tbCities.Where(x => x.city_id == city_id).FirstOrDefault();

        db.tbCities.DeleteOnSubmit(delete);
        try
        {
            db.SubmitChanges();
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Beispiel #4
0
    public bool City_Sua(int city_id, string city_name, string city_toado, int zoom)
    {
        tbCity update = db.tbCities.Where(x => x.city_id == city_id).FirstOrDefault();

        update.city_name = city_name;
        string lat   = string.Format(city_toado.Split(',')[0]);
        string longg = string.Format(city_toado.Split(',')[1]);

        update.location_lat  = lat;
        update.location_long = longg;
        update.city_zoom     = zoom;
        try
        {
            db.SubmitChanges();
            return(true);
        }
        catch
        {
            return(false);
        }
    }