Exemple #1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.BD_TemplateAttrValue model)
 {
     return(dal.Update(model));
 }
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        SqlTransaction Tran = null;

        try
        {
            Hi.Model.BD_Template model = null;
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            string str      = Request["chekAttr"];                          //属性id List
            string template = Common.NoHTML(this.txtTemplate.Value.Trim()); //模板名称
            object obj      = Request["tempId"];
            if (obj != null)
            {
                string tempIds = obj.ToString();
                List <Hi.Model.BD_TemplateAttribute> l = new Hi.BLL.BD_TemplateAttribute().GetList("", "isnull(dr,0)=0 and compid=" + this.CompID + " and templateId=" + tempIds, "", Tran);
                if (l.Count > 0)
                {
                    foreach (Hi.Model.BD_TemplateAttribute item in l)
                    {
                        new Hi.BLL.BD_TemplateAttribute().Delete(item.ID, Tran);
                        new Hi.BLL.BD_TemplateAttrValue().Delete(item.ID, Tran);
                    }
                }
                model = new Hi.BLL.BD_Template().GetModel(Convert.ToInt32(tempIds), Tran);
            }

            model              = new Hi.Model.BD_Template();
            model.CompID       = this.CompID;
            model.CreateDate   = DateTime.Now;
            model.CreateUserID = this.UserID;
            model.modifyuser   = this.UserID;
            model.TemplateName = template;
            model.TemplateCode = "";
            model.ts           = DateTime.Now;
            model.IsEnabled    = 1;
            int tempId = 0;
            if (obj != null)
            {
                tempId   = Convert.ToInt32(obj.ToString());
                model.ID = tempId;
                new Hi.BLL.BD_Template().Update(model, Tran);
            }
            else
            {
                tempId = new Hi.BLL.BD_Template().Add(model, Tran);
            }
            for (int i = 0; i < str.Split(',').Length; i++)
            {
                Hi.Model.BD_TemplateAttribute model2 = new Hi.Model.BD_TemplateAttribute();
                model2.AttributeID  = Convert.ToInt32(str.Split(',')[i]);
                model2.CompID       = this.CompID;
                model2.TemplateID   = tempId;
                model2.CreateDate   = DateTime.Now;
                model2.CreateUserID = this.UserID;
                model2.ts           = DateTime.Now;
                model2.modifyuser   = this.UserID;
                int    TemplateAttrId = new Hi.BLL.BD_TemplateAttribute().Add(model2, Tran);
                string str2           = Request["chekAttrValue" + str.Split(',')[i]];
                for (int x = 0; x < str2.Split(',').Length; x++)
                {
                    Hi.Model.BD_TemplateAttrValue model3 = new Hi.Model.BD_TemplateAttrValue();
                    model3.CompID           = this.CompID;
                    model3.AttributeValueID = Convert.ToInt32(str2.Split(',')[x]);
                    model3.TemplateAttrID   = TemplateAttrId;
                    model3.CreateDate       = DateTime.Now;
                    model3.CreateUserID     = this.UserID;
                    model3.ts         = DateTime.Now;
                    model3.modifyuser = this.UserID;
                    new Hi.BLL.BD_TemplateAttrValue().Add(model3, Tran);
                }
            }
            Tran.Commit();
            // Response.Write("<script>window.parent.CloseDialog(\"2\");window.opener.location=window.opener.location;</script>");
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>parent.location.reload();window.parent.CloseDialog(\"2\");</script>");
        }
        catch (Exception ex)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMethod(this, "保存失败了", JScript.IconOption.错误);
            return;
        }
        finally
        {
            DBUtility.SqlHelper.ConnectionClose();
        }
    }
Exemple #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_TemplateAttrValue model)
 {
     return(dal.Add(model));
 }