示例#1
0
        protected void grdCountries_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "EditRow")
                {
                    var row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
                    if (row != null)
                    {
                        txtCountryName.Text = ((Label)(row.FindControl("lblCountryName"))).Text;
                        _countryId = Convert.ToInt32(((Label)(row.FindControl("lblCountryId"))).Text);
                    }

                }
                else if (e.CommandName == "Del")
                {
                    var row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
                    if (row != null)
                    {
                        var oCountry = new TMSLibrary.Country();
                        var countryId = Convert.ToInt32(((Label)(row.FindControl("lblCountryId"))).Text);
                        MasterDataMethods.DeleteCountry(countryId);
                        FillGrid();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
示例#2
0
        protected void btnAdd_OnClick(object sender, EventArgs e)
        {
            if (txtCountryName.Text.Trim() != "")
            {
                int res = 0;
                var oCountry = new TMSLibrary.Country()
                {
                    CountryId = _countryId,
                    CountryName = txtCountryName.Text
                };
                if (_countryId == 0)
                {
                    res = TMSLibrary.MasterDataMethods.AddCountry(oCountry.CountryName);
                }
                else if (_countryId > 0)
                {
                    res = TMSLibrary.MasterDataMethods.UpdateCountry(oCountry);
                }

                if (res > 0)
                {
                    ValidatePopup("Operation Successfull.");
                }
                else if (res <= 0)
                {
                    ValidatePopup("Please Try Again");
                }
                _countryId = 0;
                FillGrid();
            }
            else
            {
                ValidatePopup("Country name cannot be empty.");
            }
        }
示例#3
0
 /// <summary>
 /// Updates a country.
 /// </summary>
 /// <param name="oCountry"></param>
 /// <returns></returns>
 public static int UpdateCountry(Country oCountry)
 {
     return TMSDataLibrary.MasterData.UpdateCountry(oCountry.CountryId, oCountry.CountryName);
 }
示例#4
0
        /// <summary>
        /// Get Country List 
        /// </summary>
        /// <returns></returns>
        public static List<Country> GetAllCountries()
        {
            List<Country> countrylist = new List<Country>();
            DataTable dt = TMSDataLibrary.MasterData.GetCountry();
            if (dt.Rows.Count > 0)
            {
                int count =  dt.Rows.Count;
                Country _country = new Country();

                for (int i = 0; i < count; i++)
                {
                    _country = new Country();
                    _country.CountryId = Convert.ToInt32(dt.Rows[i][CONSTS.CountryColumnIndex.CountryId]);
                    _country.CountryName = (dt.Rows[i][CONSTS.CountryColumnIndex.CountryName]).ToString();
                    countrylist.Add(_country);
                }
            }
            return countrylist;
        }