Exemplo n.º 1
0
 /// <summary>
 /// 属性名添加
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_Add_Click(object sender, EventArgs e)
 {
     if (Txt_Property.Text.Trim() == "")
     {
         ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('属性名不能为空!')", true);
         Txt_Property.Focus();
     }
     else if (Checking(Txt_Property.Text.Trim(), 2))
     {
         if (Session["product"] != null)
         {
             product = (HSProduct)Session["product"];
         }
         else
         {
             product = new HSProduct();
             product.HSID = Guid.NewGuid();
         }
         //if (product == null)
         //{
         //    product = new HSProduct();
         //    product.HSID = Guid.NewGuid();
         //}
         HSProperty property = new HSProperty();
         property.HSPID = Guid.NewGuid();
         property.HSID = product.HSID;
         property.PropertyName = Txt_Property.Text.Trim();
         property.ChineseRemark = Txt_ChineseRemark.Text.Trim();
         //_HSProperty.AddHSProperty(property);
         product.HSProperty.Add(property);
         Session.Remove("product");
         Session["product"] = product;
         Gv_Productiy.DataSource = product.HSProperty;
         Gv_Productiy.DataBind();
         if (Gv_Productiy.Rows.Count > 0)
         {
             DVProperty.Visible = true;
         }
         else
         {
             DVProperty.Visible = false;
         }
         Txt_ChineseRemark.Text = string.Empty;
         Txt_Property.Text = string.Empty;
     }
     else
     {
         ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('属性名已经存在,请重新输入!')", true);
         Txt_Property.Focus();
     }
 }
Exemplo n.º 2
0
     private void FixupHSProperty(HSProperty previousValue, bool skipKeys = false)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.HSRelations.Contains(this))
         {
             previousValue.HSRelations.Remove(this);
         }
 
         if (HSProperty != null)
         {
             if (!HSProperty.HSRelations.Contains(this))
             {
                 HSProperty.HSRelations.Add(this);
             }
 
             HSPID = HSProperty.HSPID;
         }
         else if (!skipKeys)
         {
             HSPID = null;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("HSProperty")
                 && (ChangeTracker.OriginalValues["HSProperty"] == HSProperty))
             {
                 ChangeTracker.OriginalValues.Remove("HSProperty");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("HSProperty", previousValue);
             }
             if (HSProperty != null && !HSProperty.ChangeTracker.ChangeTrackingEnabled)
             {
                 HSProperty.StartTracking();
             }
         }
     }
Exemplo n.º 3
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_Close_Click(object sender, EventArgs e)
 {
     if (product == null)
     {
         product = (HSProduct)Session["product"];
     }
     bool Ok = false;
     for (int i = Gv_Productiy.Rows.Count - 1; i > -1; i--)
     {
         string Bar = string.Empty;
         if (((CheckBox)Gv_Productiy.Rows[i].FindControl("chkId")).Checked)
         {
             Ok = true;
             Bar = Gv_Productiy.DataKeys[i].Value.ToString();
             foreach (HSProperty hs in product.HSProperty)
             {
                 if (hs.HSID == Guid.Parse(Bar))
                 {
                     property = hs;
                 }
             }
             product.HSProperty.Remove(property);
             Session["product"] = product;
         }
     }
     if (Ok == true)
     {
         ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('删除成功!')", true);
         if (product.HSProperty.Count == 0)
         {
             btn_Close.Visible = false;
         }
         Gv_Productiy.DataSource = product.HSProperty;
         Gv_Productiy.DataBind();
     }
     else
     {
         ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('请选择要移除的记录!')", true);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Gv_Productiy_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     string HScode=ViewState["HSCode"].ToString();
     if (HScode == Txt_HSCode.Text.Trim().ToUpper())
     {
         property = _HSProperty.FindHSPropertyByHSPID(Gv_Productiy.DataKeys[e.RowIndex].Value.ToString());
         property.PropertyName = ((TextBox)Gv_Productiy.Rows[e.RowIndex].FindControl("Txt_PropertyName")).Text.Trim();
         property.ChineseRemark = ((TextBox)Gv_Productiy.Rows[e.RowIndex].FindControl("Txt_ChineseRemark")).Text.Trim();
         _HSProperty.ModifyProperty(property);
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!')</script>");
         product = _HSProduct.FindHSProductByHSCode(HScode);
         Gv_Productiy.EditIndex = -1;
         Gv_Productiy.DataSource = product.HSProperty;
         Gv_Productiy.DataBind();
         Session.Remove("product");
         Session["product"] = product;
     }
 }