Beispiel #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        OAOfficeResApplicationCollectDetail data = this.GetData();

        if (this.OperateType == "add")
        {
            int num = this.amAction.Add(data);
            if (num > 0)
            {
                this.Page.RegisterStartupScript("", "<script>alert('添加成功!');returnValue=true;window.close();</script>");
            }
            else
            {
                this.Page.RegisterStartupScript("", "<script>alert('没有相关数据可添加!');</script>");
            }
        }
        if (this.OperateType == "upd")
        {
            int num = this.amAction.Update(data);
            if (num > 0)
            {
                this.Page.RegisterStartupScript("", "<script>alert('修改成功!');returnValue=true;window.close();</script>");
                return;
            }
            this.Page.RegisterStartupScript("", "<script>alert('没有相关数据可更新!');</script>");
        }
    }
        public OAOfficeResApplicationCollectDetail GetModel(int ACDetailID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select *  ");
            builder.Append(" ACDetailID,ACRecordID,MaterialID,ApplyNumber ");
            builder.Append(" from OA_OfficeRes_ApplicationCollectDetail ");
            builder.Append(" where ACDetailID=" + ACDetailID);
            OAOfficeResApplicationCollectDetail detail = new OAOfficeResApplicationCollectDetail();
            DataSet set = publicDbOpClass.DataSetQuary(builder.ToString());

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if (set.Tables[0].Rows[0]["ACDetailID"].ToString() != "")
            {
                detail.ACDetailID = int.Parse(set.Tables[0].Rows[0]["ACDetailID"].ToString());
            }
            if (set.Tables[0].Rows[0]["ACRecordID"].ToString() != "")
            {
                detail.ACRecordID = new Guid(set.Tables[0].Rows[0]["ACRecordID"].ToString());
            }
            if (set.Tables[0].Rows[0]["MaterialID"].ToString() != "")
            {
                detail.MaterialID = int.Parse(set.Tables[0].Rows[0]["MaterialID"].ToString());
            }
            if (set.Tables[0].Rows[0]["ApplyNumber"].ToString() != "")
            {
                detail.ApplyNumber = int.Parse(set.Tables[0].Rows[0]["ApplyNumber"].ToString());
            }
            return(detail);
        }
        public int Update(OAOfficeResApplicationCollectDetail model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update OA_OfficeRes_ApplicationCollectDetail set ");
            builder.Append("ApplyNumber=" + model.ApplyNumber);
            builder.Append(" where ACDetailID=" + model.ACDetailID);
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
        public int Add(OAOfficeResApplicationCollectDetail model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into OA_OfficeRes_ApplicationCollectDetail(");
            builder.Append("ACRecordID,MaterialID,ApplyNumber");
            builder.Append(")");
            builder.Append(" values (");
            builder.Append("'" + model.ACRecordID + "',");
            builder.Append(model.MaterialID + ",");
            builder.Append(model.ApplyNumber);
            builder.Append(")");
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }