protected void btnImport_Click(object sender, EventArgs e) { if (ddlMenu.SelectedValue == "") { JscriptMsg(350, 230, "错误提示", "<b>请选择平台!</b>", "back", "Error"); return; } else { BLL.ReportSet bllSet = new BLL.ReportSet(); Model.ReportSet modSet = new Model.ReportSet(); modSet = bllSet.GetModelByBak(ddlMenu.SelectedValue); if (modSet != null) { int_SumDate = int.Parse(modSet.SumDate); int_ChannelName = int.Parse(modSet.ChannelName); int_GameName = int.Parse(modSet.GameName); int_RegisterValue = int.Parse(modSet.RegisterValue); int_ConsumptionValue = int.Parse(modSet.ConsumptionValue); int_Income = int.Parse(modSet.Income); } else { JscriptMsg(350, 230, "错误提示", "<b>请先维护上传设置!</b>", "back", "Error"); return; } } if (FileUpload1.HasFile) { string fileName = FileUpload1.FileName; string savePath = Server.MapPath("~/file/"); FileOperatpr(fileName, savePath); FileUpload1.PostedFile.SaveAs(savePath + fileName);//将图片存储到服务器上 //FileUpload file = new FileUpload(); //file.SaveAs(savePath + fileName); DataOperator(fileName, savePath); this.hdNum.Value = strNum; this.rptList.DataSource = DbHelper.Query(" select * from ReportTemp where Bak4= '" + strNum + "'").Tables[0]; this.rptList.DataBind(); //Response.Redirect("ReportUpload.aspx?Num=" + strNum); //JscriptPrint("导入成功啦!", "ReportUpload.aspx?Num=" + strNum + "", "Success"); //JscriptMsg(350, 230, "上传成功", "上传成功" + k + "条", "back", "Success"); } else { JscriptMsg(350, 230, "错误提示", "<b>请选择文件!</b>", "back", "Error"); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.ReportSet DataRowToModel(DataRow row) { Model.ReportSet model = new Model.ReportSet(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["SumDate"] != null) { model.SumDate = row["SumDate"].ToString(); } if (row["ChannelName"] != null) { model.ChannelName = row["ChannelName"].ToString(); } if (row["GameName"] != null) { model.GameName = row["GameName"].ToString(); } if (row["RegisterValue"] != null) { model.RegisterValue = row["RegisterValue"].ToString(); } if (row["ConsumptionValue"] != null) { model.ConsumptionValue = row["ConsumptionValue"].ToString(); } if (row["Income"] != null) { model.Income = row["Income"].ToString(); } if (row["Bak1"] != null) { model.Bak1 = row["Bak1"].ToString(); } if (row["Bak2"] != null) { model.Bak2 = row["Bak2"].ToString(); } if (row["Bak3"] != null) { model.Bak3 = row["Bak3"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.ReportSet GetModelByBak(string Bak1) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,SumDate,ChannelName,GameName,RegisterValue,ConsumptionValue,Income,Bak1,Bak2,Bak3 from ReportSet "); strSql.Append(" where Bak1=@Bak1"); SqlParameter[] parameters = { new SqlParameter("@Bak1", SqlDbType.NVarChar,50) }; parameters[0].Value = Bak1; Model.ReportSet model = new Model.ReportSet(); DataSet ds = DbHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }