You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/ParameterSet/ExchangeRateInfo.aspx.cs

326 lines
13 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
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 System.Text;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Web.Script.Serialization;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;
using System.Web.Mail;
using System.IO;
using System.Data.OleDb;
using JsonHelper;
using DSWeb.Log;
namespace DSWeb.ParameterSet
{
public partial class ExchangeRateInfo : System.Web.UI.Page
{
public string strHandleType = String.Empty;
public string sSQL = String.Empty;
T_ALL_DA T_ALL_DA = new T_ALL_DA();
public string strUserID;//用户GID
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString().Trim();
hdUserID.Value = strUserID;
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
//strUserID = "";
//hdUserID.Value = strUserID;
}
//
if (!IsPostBack)
{
if (Request.QueryString["handle"] != null) //if (Request.QueryString["handle"] != null)
{
//ViewState["strHandleType"] = Request.QueryString["handle"].ToString();
this.hdHandleType.Value = Request.QueryString["handle"].ToString();
strHandleType = Request.QueryString["handle"].ToString();
if (Request.QueryString["id"] != null)
{
ViewState["GID"] = Request.QueryString["id"].ToString();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
}
//分公司代码
DataSet ds = SqlHelper.OpenSqlDataSet(SqlHelper.ConnectionStringLocalTransaction, "select COMPANYID from user_company where USERID='" + strUserID.Trim() + "'");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
this.hdCOMPANYID.Value = ds.Tables[0].Rows[0]["COMPANYID"].ToString().Trim();
}
else
{
this.hdCOMPANYID.Value = "";
}
}
else
{
this.hdCOMPANYID.Value = "";
}
switch (strHandleType)
{
case "add"://新增
ViewState["GID"] = getBSNO();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
getClear();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
break;
case "addfull"://新增
getDataSet("select * from currency_exchange where Gid='" + ViewState["GID"].ToString().Trim() + "'");
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
break;
case "edit"://录入
getDataSet("select * from currency_exchange where Gid='" + ViewState["GID"].ToString().Trim() + "'");
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
break;
}
}
else
{
}
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initComboCURRENCY();</script>");
}
protected void getClear()
{
this.hd_comboCURRENCY.Value = "";
this.hd_comboCURRENCYID.Value = "";
tbVALUE.Text = "";
tbSTARTTIME.Text = "";
tbENDTIME.Text = "";
ddlTYPE.Text = "common";
}
protected void getDataSet(string str)
{
DataSet ds = T_ALL_DA.GetAllSQL(str);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
ViewState["GID"] = ds.Tables[0].Rows[0]["GID"].ToString().Trim();
this.hd_comboCURRENCYID.Value = ds.Tables[0].Rows[0]["CURRENCYID"].ToString().Trim();
this.hd_comboCURRENCY.Value = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from code_currency where GID='" + this.hd_comboCURRENCYID.Value.Trim() + "'");
tbVALUE.Text = ds.Tables[0].Rows[0]["VALUE"].ToString().Trim();
tbSTARTTIME.Text = ds.Tables[0].Rows[0]["STARTTIME"].ToString().Trim();
tbENDTIME.Text = ds.Tables[0].Rows[0]["ENDTIME"].ToString().Trim();
ddlTYPE.Text = ds.Tables[0].Rows[0]["TYPE"].ToString().Trim();
}
else
{
getClear();
}
}
else
{
getClear();
}
}
protected String getBSNO()
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = "Rate" + strBSNO;
return strBSNO;
}
protected bool getAdd()
{
this.hd_comboCURRENCYID.Value = T_ALL_DA.GetStrSQL("GID", "select GID from code_currency where CODENAME='" + this.hd_comboCURRENCY.Value.Trim() + "'");
sSQL = "insert into currency_exchange(GID,CURRENCYID,VALUE,TYPE,{0}{2}CREATEUSER,MODIFIEDUSER) values('" + ViewState["GID"].ToString().Trim() + "','" + this.hd_comboCURRENCYID.Value.Trim() + "','" + tbVALUE.Text + "','" + ddlTYPE.Text + "',{1}{3}'" + strUserID.Trim() + "','" + strUserID.Trim() + "')";
string strSTARTTIME = tbSTARTTIME.Text.Trim().Equals("") ? "" : "'" + tbSTARTTIME.Text.Trim() + "',";
string strSTARTTIME_name = strSTARTTIME.Equals("") ? "" : "STARTTIME,";
string strENDTIME = tbENDTIME.Text.Trim().Equals("") ? "" : "'" + tbENDTIME.Text.Trim() + "',";
string strENDTIME_name = strENDTIME.Equals("") ? "" : "ENDTIME,";
sSQL = String.Format(sSQL, strSTARTTIME_name, strSTARTTIME, strENDTIME_name, strENDTIME);
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (bl)
{
//ViewState["strHandleType"] = "edit";
this.hdHandleType.Value = "edit";
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
this.hd_comboCURRENCYID.Value = T_ALL_DA.GetStrSQL("GID", "select GID from code_currency where CODENAME='" + this.hd_comboCURRENCY.Value.Trim() + "'");
sSQL = "update currency_exchange set CURRENCYID='" + this.hd_comboCURRENCYID.Value.Trim() + "',VALUE='" + tbVALUE.Text + "',TYPE='" + ddlTYPE.Text + "',{0}{1}{2}{3}MODIFIEDUSER='" + strUserID.Trim() + "' where GID='" + ViewState["GID"].ToString().Trim() + "'";
string strSTARTTIME = tbSTARTTIME.Text.Trim().Equals("") ? "null," : "'" + tbSTARTTIME.Text.Trim() + "',";
string strSTARTTIME_name = "STARTTIME=";
string strENDTIME = tbENDTIME.Text.Trim().Equals("") ? "null," : "'" + tbENDTIME.Text.Trim() + "',";
string strENDTIME_name = "ENDTIME=";
sSQL = String.Format(sSQL, strSTARTTIME_name, strSTARTTIME, strENDTIME_name, strENDTIME);
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (bl)
{
//ViewState["strHandleType"] = "edit";
this.hdHandleType.Value = "edit";
return true;
}
else
{
return false;
}
}
protected void getEnter()
{
bool bl = false;
strHandleType =this.hdHandleType.Value.Trim();//ViewState["strHandleType"].ToString();
if (strHandleType.Equals("add"))//新增
{
bl = getAdd();
}
else if (strHandleType.Equals("addfull"))//新增
{
bl = getAdd();
}
else if (strHandleType.Equals("edit"))//录入
{
bl = getEdit();
}
//
if (bl)
{
//hjdhg
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','" + strHandleType.Trim() + "');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('操作成功!');window.opener.location.reload();history.back();</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('出错,请重新填写!');</script>");
}
}
protected void ibEnter_Click(object sender, EventArgs e)
{
bool bl = false;
strHandleType = this.hdHandleType.Value.Trim(); //ViewState["strHandleType"].ToString();
if (strHandleType.Equals("add"))//新增
{
bl = getAdd();
}
else if (strHandleType.Equals("addfull"))//新增
{
bl = getAdd();
}
else if (strHandleType.Equals("edit"))//录入
{
bl = getEdit();
}
//
if (bl)
{
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','" + strHandleType .Trim()+ "');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('操作成功!');window.opener.location.reload();history.back();</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", "<script>alert('出错,请重新填写!');</script>");
}
}
protected void ibFullAdd_Click(object sender, EventArgs e)
{
//ViewState["strHandleType"] = "add";
this.hdHandleType.Value = "add";
ViewState["GID"] = getBSNO();
//
//getDataSet();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
}
protected void ibAdd_Click(object sender, EventArgs e)
{
//ViewState["strHandleType"] = "add";
this.hdHandleType.Value = "add";
ViewState["GID"] = getBSNO();
this.hdGid.Value = ViewState["GID"].ToString().Trim();
getClear();
//
ibDel.Enabled = false;
ibAdd.Enabled = false;
ibFullAdd.Enabled = false;
}
protected void ibDel_Click(object sender, EventArgs e)
{
bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from currency_exchange where GID='" + ViewState["GID"].ToString().Trim() + "'");
if (bl)
{ //
//ViewState["strHandleType"] = "edit";
this.hdHandleType.Value = "edit";
getDataSet("select top 1 * from currency_exchange order by CREATETIME desc");
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','del');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key8", "<script>alert('删除成功!');window.opener.location.reload();history.back();</script>");
}
else
{
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
ibFullAdd.Enabled = true;
Page.ClientScript.RegisterStartupScript(this.GetType(), "key9", "<script>alert('删除出错!');</script>");
}
}
}
}