|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Security;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.HtmlControls;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using System.Web.UI.WebControls.WebParts;
|
|
|
|
|
using DSWeb.Models;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.ParameterSet
|
|
|
|
|
{
|
|
|
|
|
public partial class ExchangeRateEdit : System.Web.UI.Page
|
|
|
|
|
{
|
|
|
|
|
private string strUserID;
|
|
|
|
|
private string strCompanyID;//公司GID
|
|
|
|
|
private string strShowName;//用户显示名
|
|
|
|
|
private string strDeptName;//部门名称
|
|
|
|
|
private string strHandle;
|
|
|
|
|
private string strExchangeID;//汇率GID
|
|
|
|
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Session["USERID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strUserID = Session["USERID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["SHOWNAME"] != null)
|
|
|
|
|
{
|
|
|
|
|
strShowName = Session["SHOWNAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["COMPANYID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strCompanyID = Session["COMPANYID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["DEPTNAME"] != null)
|
|
|
|
|
{
|
|
|
|
|
strDeptName = Session["DEPTNAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["handle"] != null)
|
|
|
|
|
{
|
|
|
|
|
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["id"] != null)
|
|
|
|
|
{
|
|
|
|
|
strExchangeID = Request.QueryString["id"].ToString();
|
|
|
|
|
this.h_exchangeid.Value = strExchangeID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
GetExchangeRateInfo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetExchangeRateInfo()
|
|
|
|
|
{
|
|
|
|
|
//init Currency
|
|
|
|
|
CurrencyDA currencyDA = new CurrencyDA();
|
|
|
|
|
IList<CurrencyEntity> currencyEntities = new List<CurrencyEntity>();
|
|
|
|
|
|
|
|
|
|
currencyEntities = currencyDA.GetAllCurrency();
|
|
|
|
|
if (currencyEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
this.sel_currency.Items.Clear();
|
|
|
|
|
foreach (CurrencyEntity currencyEntity in currencyEntities)
|
|
|
|
|
{
|
|
|
|
|
this.sel_currency.Items.Add(new ListItem(currencyEntity.CodeName, currencyEntity.GID));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//init ExchangeRate Type
|
|
|
|
|
this.sel_type.Items.Add(new ListItem("common", "common"));
|
|
|
|
|
this.sel_type.Items.Add(new ListItem("shipping", "shipping"));
|
|
|
|
|
this.sel_type.Items.Add(new ListItem("account", "account"));
|
|
|
|
|
|
|
|
|
|
string tempExchangeID = this.h_exchangeid.Value.Trim();
|
|
|
|
|
|
|
|
|
|
//if ExchangeRate GID Exist
|
|
|
|
|
if (!tempExchangeID.Equals(""))
|
|
|
|
|
{
|
|
|
|
|
ExchangeRateDA exchangeRateDA = new ExchangeRateDA();
|
|
|
|
|
ExchangeRateEntity exchangeRateEntity = new ExchangeRateEntity();
|
|
|
|
|
|
|
|
|
|
exchangeRateEntity = exchangeRateDA.GetExchangeRateByID(tempExchangeID);
|
|
|
|
|
|
|
|
|
|
if (exchangeRateEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (exchangeRateEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
if (sel_currency.Items.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
sel_currency.Value = exchangeRateEntity.CurrencyID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.sel_type.Value = exchangeRateEntity.Type;
|
|
|
|
|
this.txt_rateval.Value = exchangeRateEntity.Value.ToString();
|
|
|
|
|
|
|
|
|
|
CompanyDA companyDA = new CompanyDA();
|
|
|
|
|
CompanyEntity companyEntity = new CompanyEntity();
|
|
|
|
|
|
|
|
|
|
companyEntity = companyDA.GetCompanyByID(exchangeRateEntity.CompanyID);
|
|
|
|
|
|
|
|
|
|
if (companyEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (companyEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
this.txt_company.Value = companyEntity.NAME;
|
|
|
|
|
this.h_checkcompid.Value = companyEntity.GID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exchangeRateEntity.StartTime != DateTime.MinValue)
|
|
|
|
|
{
|
|
|
|
|
this.txt_begintime.Value = exchangeRateEntity.StartTime.ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
if (exchangeRateEntity.EndTime != DateTime.MinValue)
|
|
|
|
|
{
|
|
|
|
|
this.txt_endtime.Value = exchangeRateEntity.EndTime.ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exchangeRateEntity.CreateUserID != null)
|
|
|
|
|
{
|
|
|
|
|
UserDA userDA = new UserDA();
|
|
|
|
|
UserEntity userEntity = new UserEntity();
|
|
|
|
|
|
|
|
|
|
userEntity = userDA.GetUserSignByID(exchangeRateEntity.CreateUserID);
|
|
|
|
|
|
|
|
|
|
if (userEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (userEntity.Gid != null)
|
|
|
|
|
{
|
|
|
|
|
this.txt_createuser.InnerHtml = userEntity.ShowName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.txt_createtime.InnerHtml = exchangeRateEntity.CreateTime.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (h_checkcompid.Value.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
h_checkcompid.Value = strCompanyID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompanyDA companyDA = new CompanyDA();
|
|
|
|
|
CompanyEntity companyEntity = new CompanyEntity();
|
|
|
|
|
|
|
|
|
|
companyEntity = companyDA.GetCompanyByID(strCompanyID);
|
|
|
|
|
|
|
|
|
|
if (companyEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (companyEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
this.txt_company.Value = companyEntity.NAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void btn_enter_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string strTempCurrencyGID = "";
|
|
|
|
|
string strTempRateType = "";
|
|
|
|
|
string strTempCompanyID = "";
|
|
|
|
|
DateTime tTempStartTime = DateTime.MinValue;
|
|
|
|
|
DateTime tTempEndTime = DateTime.MinValue;
|
|
|
|
|
decimal dTempRate = 0;
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
if (Request.Form["sel_currency"] != null)
|
|
|
|
|
{
|
|
|
|
|
strTempCurrencyGID = Request.Form["sel_currency"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.Form["txt_rateval"] != null)
|
|
|
|
|
{
|
|
|
|
|
dTempRate = decimal.Parse(Request.Form["txt_rateval"].ToString().Trim());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.Form["sel_type"] != null)
|
|
|
|
|
{
|
|
|
|
|
strTempRateType = Request.Form["sel_type"].ToString().Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.Form["txt_begintime"] != null)
|
|
|
|
|
{
|
|
|
|
|
tTempStartTime = DateTime.Parse((Request.Form["txt_begintime"].ToString().Trim().Equals("") ? DateTime.MinValue.ToString() : Request.Form["txt_begintime"].ToString().Trim()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.Form["txt_endtime"] != null)
|
|
|
|
|
{
|
|
|
|
|
tTempEndTime = DateTime.Parse((Request.Form["txt_endtime"].ToString().Trim().Equals("") ? DateTime.MinValue.ToString() : Request.Form["txt_endtime"].ToString().Trim()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (h_checkcompid.Value.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
strTempCompanyID = h_checkcompid.Value.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExchangeRateDA exchangeRateDA = new ExchangeRateDA();
|
|
|
|
|
ExchangeRateEntity exchangeRateEntity = new ExchangeRateEntity();
|
|
|
|
|
|
|
|
|
|
if (h_exchangeid.Value.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
exchangeRateEntity.GID = Guid.NewGuid().ToString();
|
|
|
|
|
exchangeRateEntity.CurrencyID = strTempCurrencyGID;
|
|
|
|
|
exchangeRateEntity.Type = strTempRateType;
|
|
|
|
|
exchangeRateEntity.Value = dTempRate;
|
|
|
|
|
exchangeRateEntity.StartTime = tTempStartTime;
|
|
|
|
|
exchangeRateEntity.EndTime = tTempEndTime;
|
|
|
|
|
exchangeRateEntity.CompanyID = strTempCompanyID;
|
|
|
|
|
exchangeRateEntity.CreateUserID = strUserID;
|
|
|
|
|
|
|
|
|
|
iResult = exchangeRateDA.InsertExchangeRate(exchangeRateEntity);
|
|
|
|
|
|
|
|
|
|
if (iResult == 1)
|
|
|
|
|
{
|
|
|
|
|
this.h_exchangeid.Value = exchangeRateEntity.GID;
|
|
|
|
|
this.txt_createuser.InnerHtml = strShowName;
|
|
|
|
|
|
|
|
|
|
exchangeRateEntity = exchangeRateDA.GetExchangeRateByID(h_exchangeid.Value);
|
|
|
|
|
|
|
|
|
|
if (exchangeRateEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (exchangeRateEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
this.txt_createtime.InnerHtml = exchangeRateEntity.CreateTime.ToString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.txt_createuser.InnerHtml = strShowName;
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('保存成功');window.opener.location.href=window.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('保存失败');</script>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
exchangeRateEntity = exchangeRateDA.GetExchangeRateByID(h_exchangeid.Value.Trim());
|
|
|
|
|
|
|
|
|
|
if (exchangeRateEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (exchangeRateEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
exchangeRateEntity.CurrencyID = strTempCurrencyGID;
|
|
|
|
|
exchangeRateEntity.Type = strTempRateType;
|
|
|
|
|
exchangeRateEntity.Value = dTempRate;
|
|
|
|
|
exchangeRateEntity.StartTime = tTempStartTime;
|
|
|
|
|
exchangeRateEntity.EndTime = tTempEndTime;
|
|
|
|
|
exchangeRateEntity.CompanyID = strTempCompanyID;
|
|
|
|
|
exchangeRateEntity.ModifiedUserID = strUserID;
|
|
|
|
|
|
|
|
|
|
iResult = exchangeRateDA.UpdateExchangeRate(exchangeRateEntity);
|
|
|
|
|
|
|
|
|
|
if (iResult == 1)
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('保存成功');window.opener.location.href=window.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('保存失败');</script>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('要操作的汇率信息不存在');</script>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('要操作的汇率信息不存在');</script>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|