示例#1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        OAOfficeResPersonalApplication 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 int Update(OAOfficeResPersonalApplication model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update OA_OfficeRes_PersonalApplication set ");
            builder.Append("ApplyMan='" + model.ApplyMan + "',");
            builder.Append("UseMan='" + model.UseMan + "',");
            builder.Append("CorpCode='" + model.CorpCode + "'");
            builder.Append(" where PARecordID=" + model.PARecordID);
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
        public int Add(OAOfficeResPersonalApplication model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into OA_OfficeRes_PersonalApplication(");
            builder.Append("CorpCode,ApplyDate,ApplyMan,UseMan,IsSubmit,IsComplete,UserCode,RecordDate,ACRecordID");
            builder.Append(")");
            builder.Append(" values (");
            builder.Append("'" + model.CorpCode + "',");
            builder.Append("'" + model.ApplyDate + "',");
            builder.Append("'" + model.ApplyMan + "',");
            builder.Append("'" + model.UseMan + "',");
            builder.Append("'" + model.IsSubmit + "',");
            builder.Append("'" + model.IsComplete + "',");
            builder.Append("'" + model.UserCode + "',");
            builder.Append("'" + model.RecordDate + "',");
            builder.Append("'" + model.ACRecordID + "'");
            builder.Append(")");
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
        public OAOfficeResPersonalApplication GetModel(int PARecordID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select *  ");
            builder.Append(" PARecordID,CorpCode,ApplyDate,ApplyMan,UseMan,IsSubmit,IsComplete,UserCode,RecordDate,ACRecordID ");
            builder.Append(" from OA_OfficeRes_PersonalApplication ");
            builder.Append(" where PARecordID=" + PARecordID);
            OAOfficeResPersonalApplication application = new OAOfficeResPersonalApplication();
            DataSet set = publicDbOpClass.DataSetQuary(builder.ToString());

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if (set.Tables[0].Rows[0]["PARecordID"].ToString() != "")
            {
                application.PARecordID = int.Parse(set.Tables[0].Rows[0]["PARecordID"].ToString());
            }
            application.CorpCode = set.Tables[0].Rows[0]["CorpCode"].ToString();
            if (set.Tables[0].Rows[0]["ApplyDate"].ToString() != "")
            {
                application.ApplyDate = DateTime.Parse(set.Tables[0].Rows[0]["ApplyDate"].ToString());
            }
            application.ApplyMan   = set.Tables[0].Rows[0]["ApplyMan"].ToString();
            application.UseMan     = set.Tables[0].Rows[0]["UseMan"].ToString();
            application.IsSubmit   = set.Tables[0].Rows[0]["IsSubmit"].ToString();
            application.IsComplete = set.Tables[0].Rows[0]["IsComplete"].ToString();
            application.UserCode   = set.Tables[0].Rows[0]["UserCode"].ToString();
            if (set.Tables[0].Rows[0]["RecordDate"].ToString() != "")
            {
                application.RecordDate = DateTime.Parse(set.Tables[0].Rows[0]["RecordDate"].ToString());
            }
            if (set.Tables[0].Rows[0]["ACRecordID"].ToString() != "")
            {
                application.ACRecordID = new Guid(set.Tables[0].Rows[0]["ACRecordID"].ToString());
            }
            return(application);
        }