139 lines
5.2 KiB
C#
139 lines
5.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Configuration;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Security;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
using System.Web.UI.WebControls;
|
|||
|
|
using System.Web.UI.WebControls.WebParts;
|
|||
|
|
using System.Web.UI.HtmlControls;
|
|||
|
|
using System.Data.OleDb;
|
|||
|
|
using WeiSha.Common;
|
|||
|
|
using Song.ServiceInterfaces;
|
|||
|
|
using Song.Entities;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Text.RegularExpressions;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Xml;
|
|||
|
|
|
|||
|
|
namespace Song.Site.Manage.Course
|
|||
|
|
{
|
|||
|
|
public partial class Outline_Input : Extend.CustomPage
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>get<65><74><EFBFBD><EFBFBD><EFBFBD>Ŀγ<C4BF>id
|
|||
|
|
int couid_get = WeiSha.Common.Request.QueryString["couid"].Int32 ?? 0;
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
protected void ExcelInput1_OnInput(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//xml<6D><6C><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
|
XmlDocument xmldoc = new XmlDocument();
|
|||
|
|
string confing = WeiSha.Common.App.Get["ExcelInputConfig"].VirtualPath + ExcelInput1.Config;
|
|||
|
|
xmldoc.Load(WeiSha.Common.Server.MapPath(confing));
|
|||
|
|
XmlNodeList nodes = xmldoc.GetElementsByTagName("item");
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
DataTable dt = ExcelInput1.SheetDataTable;
|
|||
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
|||
|
|
_inputData(dt.Rows[i], nodes);
|
|||
|
|
}
|
|||
|
|
catch(Exception ex)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7>ظ<EFBFBD><D8B8>ؼ<EFBFBD>
|
|||
|
|
ExcelInput1.AddError(dt.Rows[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Business.Do<IOutline>().OnSave(null, EventArgs.Empty);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ijһ<C4B3><D2BB><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>뵽<EFBFBD><EBB5BD><EFBFBD>ݿ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dr"></param>
|
|||
|
|
/// <param name="dl"></param>
|
|||
|
|
private void _inputData(DataRow dr,XmlNodeList nodes)
|
|||
|
|
{
|
|||
|
|
Song.Entities.Outline obj = new Song.Entities.Outline();
|
|||
|
|
foreach (KeyValuePair<String, String> rel in ExcelInput1.DataRelation)
|
|||
|
|
{
|
|||
|
|
//Excel<65><6C><EFBFBD>е<EFBFBD>ֵ
|
|||
|
|
string column = dr[rel.Key].ToString();
|
|||
|
|
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
string field = rel.Value;
|
|||
|
|
if (field == "Ol_ID")
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(column) || column.Trim() == "") continue;
|
|||
|
|
int id = Convert.ToInt32(column);
|
|||
|
|
Song.Entities.Outline isHavObj = Business.Do<IOutline>().OutlineSingle(id);
|
|||
|
|
if (isHavObj != null) obj = isHavObj;
|
|||
|
|
}
|
|||
|
|
//<2F>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (field == "<22>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD>")
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrWhiteSpace(column)|| column.Trim()=="") return;
|
|||
|
|
obj.Ol_Name = column.Trim();
|
|||
|
|
Song.Entities.Outline isHavObj = Business.Do<IOutline>().OutlineSingle(obj.Ol_Name);
|
|||
|
|
if (isHavObj != null) obj = isHavObj;
|
|||
|
|
}
|
|||
|
|
PropertyInfo[] properties = obj.GetType().GetProperties();
|
|||
|
|
for (int j = 0; j < properties.Length; j++)
|
|||
|
|
{
|
|||
|
|
PropertyInfo pi = properties[j];
|
|||
|
|
if (field == pi.Name && !string.IsNullOrEmpty(column))
|
|||
|
|
{
|
|||
|
|
object val = getValue(field, column, nodes);
|
|||
|
|
if (val == null) continue;
|
|||
|
|
pi.SetValue(obj, Convert.ChangeType(val, pi.PropertyType), null);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
obj.Cou_ID = couid_get;
|
|||
|
|
Song.Entities.Course cur = Business.Do<ICourse>().CourseSingle(couid_get);
|
|||
|
|
obj.Sbj_ID = cur.Sbj_ID;
|
|||
|
|
obj.Org_ID = cur.Org_ID;
|
|||
|
|
Business.Do<IOutline>().OutlineInput(obj);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="field"><3E>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
|
/// <param name="val"><3E>ֶζ<D6B6>Ӧ<EFBFBD><D3A6>ֵ</param>
|
|||
|
|
/// <param name="nodes"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>xml<6D><6C><EFBFBD><EFBFBD></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private object getValue(string field, string val, XmlNodeList nodes)
|
|||
|
|
{
|
|||
|
|
object obj = null;
|
|||
|
|
for (int j = 0; j < nodes.Count; j++)
|
|||
|
|
{
|
|||
|
|
string _field = nodes[j].Attributes["Field"] != null ? nodes[j].Attributes["Field"].Value : "";
|
|||
|
|
if (field != _field) continue;
|
|||
|
|
//Ĭ<>ϵĶ<CFB5>Ӧ<EFBFBD><D3A6>ϵ
|
|||
|
|
string _defvalue = nodes[j].Attributes["DefautValue"] != null ? nodes[j].Attributes["DefautValue"].Value : "";
|
|||
|
|
if (string.IsNullOrWhiteSpace(_defvalue))
|
|||
|
|
{
|
|||
|
|
obj = val;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
foreach (string s in _defvalue.Split('|'))
|
|||
|
|
{
|
|||
|
|
string h = s.Substring(0, s.IndexOf("="));
|
|||
|
|
string f = s.Substring(s.LastIndexOf("=") + 1);
|
|||
|
|
if (val == f) obj = h;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return obj;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|