Ejemplo n.º 1
0
        private void LoadData()
        {
            int id = GetInt("id");

            if (id > 0)
            {
                CurrentCarModel = Cars.Instance.GetCarModelModel(id, true);

                txtName.Value = CurrentCarModel.Name;
                SetSelectedByValue(ddlCarBrand, CurrentCarModel.BrandID.ToString());
            }

            ddlCarSeries.DataSource     = Cars.Instance.GetCarSeriesListByBrandID(CurrentCarModel == null ? DataConvert.SafeInt(ddlCarBrand.Items[0].Value) : CurrentCarModel.BrandID, true);
            ddlCarSeries.DataTextField  = "Name";
            ddlCarSeries.DataValueField = "ID";
            ddlCarSeries.DataBind();

            if (id > 0)
            {
                SetSelectedByValue(ddlCarSeries, CurrentCarModel.SeriesID.ToString());
                hdnCarSeries.Value = CurrentCarModel.SeriesID.ToString();
            }
            else
            {
                hdnCarSeries.Value = ddlCarSeries.Items[0].Value;
            }
        }
Ejemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            CarModelInfo entity = new CarModelInfo();
            int id = GetInt("id");
            if (id > 0) entity = Cars.Instance.GetCarModelModel(id, true);
            FillData(entity);

            if (id > 0) Cars.Instance.UpdateCarModel(entity);
            else Cars.Instance.AddCarModel(entity);

            Cars.Instance.ReloadCarModelListCache();
            Response.Redirect("carmodelmg.aspx");
        }
Ejemplo n.º 3
0
        public static CarModelInfo PopulateCarModelInfo(IDataReader reader)
        {
            CarModelInfo entity = new CarModelInfo()
            {
                ID = (int)reader["ID"],
                Name = reader["Name"] as string,
                BrandID = (int)reader["BrandID"],
                BrandName = reader["BrandName"] as string,
                BrandNameIndex = reader["BrandNameIndex"] as string,
                SeriesName = reader["SeriesName"] as string,
                SeriesID = (int)reader["SeriesID"]
            };

            return entity;
        }
Ejemplo n.º 4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            CarModelInfo entity = new CarModelInfo();
            int          id     = GetInt("id");

            if (id > 0)
            {
                entity = Cars.Instance.GetCarModelModel(id, true);
            }
            FillData(entity);

            if (id > 0)
            {
                Cars.Instance.UpdateCarModel(entity);
            }
            else
            {
                Cars.Instance.AddCarModel(entity);
            }

            Cars.Instance.ReloadCarModelListCache();
            Response.Redirect("carmodelmg.aspx");
        }
Ejemplo n.º 5
0
        private void LoadData()
        {
            int id = GetInt("id");
            if (id > 0)
            {
                CurrentCarModel = Cars.Instance.GetCarModelModel(id, true);

                txtName.Value = CurrentCarModel.Name;
                SetSelectedByValue(ddlCarBrand, CurrentCarModel.BrandID.ToString());
            }

            ddlCarSeries.DataSource = Cars.Instance.GetCarSeriesListByBrandID(CurrentCarModel == null ? DataConvert.SafeInt(ddlCarBrand.Items[0].Value) : CurrentCarModel.BrandID, true);
            ddlCarSeries.DataTextField = "Name";
            ddlCarSeries.DataValueField = "ID";
            ddlCarSeries.DataBind();

            if (id > 0)
            {
                SetSelectedByValue(ddlCarSeries, CurrentCarModel.SeriesID.ToString());
                hdnCarSeries.Value = CurrentCarModel.SeriesID.ToString();
            }
            else
                hdnCarSeries.Value = ddlCarSeries.Items[0].Value;
        }
Ejemplo n.º 6
0
 private void FillData(CarModelInfo entity)
 {
     entity.Name     = txtName.Value;
     entity.SeriesID = DataConvert.SafeInt(hdnCarSeries.Value);
 }
Ejemplo n.º 7
0
 public override int AddCarModel(CarModelInfo entity)
 {
     string sql = @"INSERT INTO ComOpp_CarModel(
         [Name]
         ,[SeriesID]
     )VALUES(
         @Name
         ,@SeriesID
     );SELECT @@IDENTITY";
     SqlParameter[] p =
     {
         new SqlParameter("@Name",entity.Name),
         new SqlParameter("@SeriesID",entity.SeriesID)
     };
     return DataConvert.SafeInt(SqlHelper.ExecuteScalar(_con, CommandType.Text, sql, p));
 }
Ejemplo n.º 8
0
 public override void UpdateCarModel(CarModelInfo entity)
 {
     string sql = @"
     UPDATE ComOpp_CarModel set
         Name = @Name
         ,SeriesID = @SeriesID
     WHERE ID=@ID";
     SqlParameter[] parameters =
     {
         new SqlParameter("@ID", entity.ID),
         new SqlParameter("@Name", entity.Name),
         new SqlParameter("@SeriesID", entity.SeriesID)
     };
     SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, parameters);
 }
Ejemplo n.º 9
0
 public abstract void UpdateCarModel(CarModelInfo entity);
Ejemplo n.º 10
0
 public abstract int AddCarModel(CarModelInfo entity);
Ejemplo n.º 11
0
 public int AddCarModel(CarModelInfo entity)
 {
     return CommonDataProvider.Instance().AddCarModel(entity);
 }
Ejemplo n.º 12
0
 public void UpdateCarModel(CarModelInfo entity)
 {
     CommonDataProvider.Instance().UpdateCarModel(entity);
 }
Ejemplo n.º 13
0
 private void FillData(CarModelInfo entity)
 {
     entity.Name = txtName.Value;
     entity.SeriesID = DataConvert.SafeInt(hdnCarSeries.Value);
 }