private void Save()
        {
            ShowShop.BLL.SystemInfo.Provinces bll = new ShowShop.BLL.SystemInfo.Provinces();
            Model.SystemInfo.Provinces model = new ShowShop.Model.SystemInfo.Provinces();
            try
            {
                model.AddDate = System.DateTime.Now;
                model.Child = 0;
                model.CityEnglishName = this.txtCityEnglishName.Text;
                model.CityName = this.txtCityName.Text;
                model.Depth = ChangeHope.Common.StringHelper.StringToInt(this.txtDepth.Value);
                model.Id = ChangeHope.Common.StringHelper.StringToInt(this.txtId.Value);
                model.IsUse = ChangeHope.Common.StringHelper.StringToInt(this.ckbIsUse.SelectedValue);

                model.ParentId = ChangeHope.Common.StringHelper.StringToInt(this.ddlParentId.SelectedValue);
                model.OrderID = bll.GetChildCount(model.ParentId.ToString());
                model.ParentPath = this.txtParentPath.Value;
                if (model.Id > 0)
                {
                    model.Child = bll.GetChildCount(model.Id.ToString());
                    bll.Update(model);
                }
                else
                {
                    this.txtId.Value = bll.Add(model).ToString();
                }
                model = null;
                bll = null;
                this.ltlMsg.Text = "保存成功!";
                this.pnlMsg.CssClass = "actionOk";
            }
            catch {
                this.ltlMsg.Text = "保存失败!";
                this.pnlMsg.CssClass = "actionErr";
            }
            finally {
                this.pnlMsg.Visible = true;
                model = null;
                bll = null;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ShowShop.Model.SystemInfo.Provinces GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,CityName,CityEnglishName,ParentId,ParentPath,Depth,OrderID,Child,IsUse,AddDate from yxs_Provinces ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)};
            parameters[0].Value = Id;

            ShowShop.Model.SystemInfo.Provinces model = new ShowShop.Model.SystemInfo.Provinces();
            DataSet ds = ChangeHope.DataBase.SQLServerHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.CityName = ds.Tables[0].Rows[0]["CityName"].ToString();
                model.CityEnglishName = ds.Tables[0].Rows[0]["CityEnglishName"].ToString();
                if (ds.Tables[0].Rows[0]["ParentId"].ToString() != "")
                {
                    model.ParentId = int.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString());
                }
                model.ParentPath = ds.Tables[0].Rows[0]["ParentPath"].ToString();
                if (ds.Tables[0].Rows[0]["Depth"].ToString() != "")
                {
                    model.Depth = int.Parse(ds.Tables[0].Rows[0]["Depth"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderID"].ToString() != "")
                {
                    model.OrderID = int.Parse(ds.Tables[0].Rows[0]["OrderID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Child"].ToString() != "")
                {
                    model.Child = int.Parse(ds.Tables[0].Rows[0]["Child"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsUse"].ToString() != "")
                {
                    model.IsUse = int.Parse(ds.Tables[0].Rows[0]["IsUse"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddDate"].ToString() != "")
                {
                    model.AddDate = DateTime.Parse(ds.Tables[0].Rows[0]["AddDate"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }