Esempio n. 1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        ptOfficeResInStorageDetail data      = this.GetData();
        ptOfficeResStock           stockData = this.GetStockData();

        if (this.OperateType == "add")
        {
            this.amAction.AddStock(stockData);
            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")
        {
            this.amAction.UpdateStock(stockData, this.RecordID);
            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(ptOfficeResInStorageDetail model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update OA_OfficeRes_InStorage_Detail set ");
            builder.Append("Amount=" + model.Amount + ",");
            builder.Append("HandleMan='" + model.HandleMan + "'");
            builder.Append(" where RecordID=" + model.RecordID);
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
        public int Add(ptOfficeResInStorageDetail model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into OA_OfficeRes_InStorage_Detail(");
            builder.Append("InStorageID,MaterialID,InStoragePrice,Amount,HandleMan");
            builder.Append(")");
            builder.Append(" values (");
            builder.Append(model.InStorageID + ",");
            builder.Append(model.MaterialID + ",");
            builder.Append(model.InStoragePrice + ",");
            builder.Append(model.Amount + ",");
            builder.Append("'" + model.HandleMan + "'");
            builder.Append(")");
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
        public ptOfficeResInStorageDetail GetModel(int RecordID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(" select RecordID,InStorageID,MaterialID,InStoragePrice,Amount,HandleMan ");
            builder.Append(" from OA_OfficeRes_InStorage_Detail ");
            builder.Append(" where RecordID=" + RecordID);
            ptOfficeResInStorageDetail detail = new ptOfficeResInStorageDetail();
            DataSet set = publicDbOpClass.DataSetQuary(builder.ToString());

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if (set.Tables[0].Rows[0]["RecordID"].ToString() != "")
            {
                detail.RecordID = int.Parse(set.Tables[0].Rows[0]["RecordID"].ToString());
            }
            if (set.Tables[0].Rows[0]["InStorageID"].ToString() != "")
            {
                detail.InStorageID = int.Parse(set.Tables[0].Rows[0]["InStorageID"].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]["InStoragePrice"].ToString() != "")
            {
                detail.InStoragePrice = decimal.Parse(set.Tables[0].Rows[0]["InStoragePrice"].ToString());
            }
            if (set.Tables[0].Rows[0]["Amount"].ToString() != "")
            {
                detail.Amount = decimal.Parse(set.Tables[0].Rows[0]["Amount"].ToString());
            }
            detail.HandleMan = set.Tables[0].Rows[0]["HandleMan"].ToString();
            return(detail);
        }