Ejemplo n.º 1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.btnSave.Enabled = false;
     this.btnCancle.Enabled = false;
     if (string.IsNullOrEmpty(this.txtRegionName.Text.Trim()))
     {
         this.btnSave.Enabled = true;
         this.btnCancle.Enabled = true;
         MessageBox.ShowFailTip(this, "地区名称不能为空!");
     }
     else
     {
         Maticsoft.Model.Ms.Regions model = new Maticsoft.Model.Ms.Regions {
             AreaId = null
         };
         if (((this.Regions1.Province_iID == 0) && (this.Regions1.City_iID == 0)) && (this.Regions1.Area_iID == 0))
         {
             model.ParentId = null;
             model.Path = "0,";
             model.Depth = 1;
         }
         if (((this.Regions1.Province_iID != 0) && (this.Regions1.City_iID == 0)) && (this.Regions1.Area_iID == 0))
         {
             model.ParentId = new int?(this.Regions1.Province_iID);
             model.Path = "0," + this.Regions1.Province_iID;
             model.Depth = 2;
         }
         if (((this.Regions1.Province_iID != 0) && (this.Regions1.City_iID != 0)) && (this.Regions1.Area_iID == 0))
         {
             model.ParentId = new int?(this.Regions1.City_iID);
             model.Path = string.Concat(new object[] { "0,", this.Regions1.Province_iID, ",", this.Regions1.City_iID });
             model.Depth = 3;
         }
         if (((this.Regions1.Province_iID != 0) && (this.Regions1.City_iID != 0)) && (this.Regions1.Area_iID != 0))
         {
             MessageBox.ShowSuccessTip(this, "暂时支持添加到三级区域");
         }
         else
         {
             Maticsoft.BLL.Ms.Regions regions2 = new Maticsoft.BLL.Ms.Regions();
             model.RegionId = regions2.GetMaxId();
             model.RegionName = this.txtRegionName.Text;
             model.Spell = null;
             model.SpellShort = this.txtSpellShort.Text;
             model.DisplaySequence = Globals.SafeInt(this.txtDisplaySequence.Text, 1);
             if (0 < regions2.Add(model))
             {
                 this.btnSave.Enabled = false;
                 this.btnCancle.Enabled = false;
                 MessageBox.ShowSuccessTip(this, "保存成功!", "add.aspx");
             }
             else
             {
                 this.btnSave.Enabled = true;
                 this.btnCancle.Enabled = true;
                 MessageBox.ShowSuccessTip(this, "添加失败!");
             }
         }
     }
 }
Ejemplo n.º 2
0
 public Maticsoft.Model.Ms.Regions DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Ms.Regions regions = new Maticsoft.Model.Ms.Regions();
     if (row != null)
     {
         if ((row["AreaId"] != null) && (row["AreaId"].ToString() != ""))
         {
             regions.AreaId = new int?(int.Parse(row["AreaId"].ToString()));
         }
         if ((row["RegionId"] != null) && (row["RegionId"].ToString() != ""))
         {
             regions.RegionId = int.Parse(row["RegionId"].ToString());
         }
         if ((row["ParentId"] != null) && (row["ParentId"].ToString() != ""))
         {
             regions.ParentId = new int?(int.Parse(row["ParentId"].ToString()));
         }
         if (row["RegionName"] != null)
         {
             regions.RegionName = row["RegionName"].ToString();
         }
         if (row["Spell"] != null)
         {
             regions.Spell = row["Spell"].ToString();
         }
         if (row["SpellShort"] != null)
         {
             regions.SpellShort = row["SpellShort"].ToString();
         }
         if ((row["DisplaySequence"] != null) && (row["DisplaySequence"].ToString() != ""))
         {
             regions.DisplaySequence = int.Parse(row["DisplaySequence"].ToString());
         }
         if (row["Path"] != null)
         {
             regions.Path = row["Path"].ToString();
         }
         if ((row["Depth"] != null) && (row["Depth"].ToString() != ""))
         {
             regions.Depth = int.Parse(row["Depth"].ToString());
         }
     }
     return regions;
 }
Ejemplo n.º 3
0
 public Maticsoft.Model.Ms.Regions GetModel(int RegionId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 * from MS_Regions ");
     builder.Append(" where RegionId=@RegionId");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@RegionId", SqlDbType.Int, 4) };
     cmdParms[0].Value = RegionId;
     Maticsoft.Model.Ms.Regions regions = new Maticsoft.Model.Ms.Regions();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["AreaId"] != null) && (set.Tables[0].Rows[0]["AreaId"].ToString() != ""))
     {
         regions.AreaId = new int?(int.Parse(set.Tables[0].Rows[0]["AreaId"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["RegionId"] != null) && (set.Tables[0].Rows[0]["RegionId"].ToString() != ""))
     {
         regions.RegionId = int.Parse(set.Tables[0].Rows[0]["RegionId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ParentId"] != null) && (set.Tables[0].Rows[0]["ParentId"].ToString() != ""))
     {
         regions.ParentId = new int?(int.Parse(set.Tables[0].Rows[0]["ParentId"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["RegionName"] != null) && (set.Tables[0].Rows[0]["RegionName"].ToString() != ""))
     {
         regions.RegionName = set.Tables[0].Rows[0]["RegionName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Spell"] != null) && (set.Tables[0].Rows[0]["Spell"].ToString() != ""))
     {
         regions.Spell = set.Tables[0].Rows[0]["Spell"].ToString();
     }
     if ((set.Tables[0].Rows[0]["SpellShort"] != null) && (set.Tables[0].Rows[0]["SpellShort"].ToString() != ""))
     {
         regions.SpellShort = set.Tables[0].Rows[0]["SpellShort"].ToString();
     }
     if ((set.Tables[0].Rows[0]["DisplaySequence"] != null) && (set.Tables[0].Rows[0]["DisplaySequence"].ToString() != ""))
     {
         regions.DisplaySequence = int.Parse(set.Tables[0].Rows[0]["DisplaySequence"].ToString());
     }
     if ((set.Tables[0].Rows[0]["Path"] != null) && (set.Tables[0].Rows[0]["Path"].ToString() != ""))
     {
         regions.Path = set.Tables[0].Rows[0]["Path"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Depth"] != null) && (set.Tables[0].Rows[0]["Depth"].ToString() != ""))
     {
         regions.Depth = int.Parse(set.Tables[0].Rows[0]["Depth"].ToString());
     }
     return regions;
 }