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.

928 lines
37 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL.CardBill;
using BLL.Sys;
using CPCBILLSYS.Common;
using Ext.Net;
using Model;
namespace CPCBILLSYS
{
public partial class BillInfoMg : System.Web.UI.Page
{
LogClass log = new LogClass();
/// <summary>
/// 基础
/// </summary>
DictionaryBLL dicbll = new DictionaryBLL(CommonHelper._dbType, CommonHelper.DbConStr);
/// <summary>
/// cpc
/// </summary>
BILLBLL billbll = new BILLBLL(CommonHelper._dbType, CommonHelper.DbConStr);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (CommonHelper._userType == "3")
{
if (string.IsNullOrEmpty(Request.QueryString["userId"]) || string.IsNullOrEmpty(Request.QueryString["userName"]))
{
Response.Write("<script>alert('错误的访问!');window.location.href='http://10.15.0.36:9996'</script>");
return;
}
try
{
hdUserId.Value = Request.QueryString["userId"].ToString();
hdMan.Value = HttpUtility.UrlDecode(Request.QueryString["userName"].ToString());
}
catch
{
Response.Write("<script>alert('数据库访问异常!');window.location.href='http://10.15.0.36:9996'</script>");
return;
}
//hdUserId.Value = "1";
//hdMan.Value = "武俊涛";
}
else
{
if (Session["UserID"] == null || Session["SysID"] == null || Session["MAN"] == null)
{
Response.Write("<script>alert('错误的访问!');window.location.href='../Default.aspx'</script>");
return;
}
hdUserId.Value = Session["UserID"].ToString();
hdMan.Value = Session["MAN"].ToString();
}
txtAdMan.Text = hdMan.Value.ToString();
txtAdMan.Disabled = true;
s_txtStartDt.Value = DateTime.Now;
s_txtEndDt.Value = DateTime.Now.AddDays(1);
txtClassDt.Value = DateTime.Now;
StCardInfo.AutoLoadParams.Add(new Ext.Net.Parameter("Start", "0"));
StCardInfo.AutoLoadParams.Add(new Ext.Net.Parameter("Limit", Paging.PageSize.ToString()));
BindSub();
BindBillKind();
BindBillType();
BindClassNO();
BindBillUsingType();
BindIsHigh();
if (CommonHelper._userType == "1")
{
cmbIsHigh.Hide();
s_cmbIsHigh.Hide();
}
else
{
cmbIsHigh.Hide();
s_cmbIsHigh.Hide();
}
//BindBillName();
}
}
#region 绑定数据
public void BindClassNO()
{
stClassNo.DataSource = dicbll.GetClass("");
stClassNo.DataBind();
}
public void BindIsHigh()
{
DataTable dt = new DataTable();
dt.Columns.Add("VALUE", typeof(int));
dt.Columns.Add("TEXT", typeof(string));
DataRow dr1 = dt.NewRow();
dr1["VALUE"] = "1";
dr1["TEXT"] = "高速";
dt.Rows.Add(dr1);
DataRow dr2 = dt.NewRow();
dr2["VALUE"] = "2";
dr2["TEXT"] = "一级路";
dt.Rows.Add(dr2);
stEIsHigh.DataSource = dt;
stEIsHigh.DataBind();
}
/// <summary>
/// 绑定站
/// </summary>
public void BindSub()
{
if (CommonHelper._userType == "1")
{
//s_cmbSubcom.Disabled = true;
//s_cmbSta.Disabled = true;
s_cmbSubcom.Hidden = true;
s_cmbSta.Hidden = true;
}
else if (CommonHelper._userType == "2")
{
//SUBCOMNAME,SUBCOMNO
storeSubCompany.DataSource = dicbll.GetSubCompany("");
}
else
{
DataTable dt = dicbll.GetSubCompany("");
DataRow dr = dt.NewRow();
dr["SUBCOMNO"] = "1";
dr["SUBCOMNAME"] = "总公司";
dt.Rows.Add(dr);
storeSubCompany.DataSource = dt;
}
storeSubCompany.DataBind();
}
protected void s_cmbSubcom_Select(object sender, Ext.Net.DirectEventArgs e)
{
if (s_cmbSubcom.SelectedItem.Value == "1")
{
DataTable dt = new DataTable();
dt.Columns.Add("STANO", typeof(int));
dt.Columns.Add("STANAME", typeof(string));
DataRow dr = dt.NewRow();
dr["STANO"] = "1";
dr["STANAME"] = "总公司";
dt.Rows.Add(dr);
stSta.DataSource = dt;
}
else
{
stSta.DataSource = dicbll.GetStaAllInfo(" and SUBCOMNO='" + s_cmbSubcom.SelectedItem.Value + "'");
}
stSta.DataBind();
}
public void BindBillKind()
{
stBillKind.DataSource = dicbll.GetCBBillKind("");
stBillKind.DataBind();
s_stBillKind.DataSource = dicbll.GetCBBillKind("");
s_stBillKind.DataBind();
}
public void BindBillType()
{
stBillType.DataSource = dicbll.GetCBKind(" and VALUE in(1,2)");
stBillType.DataBind();
s_stBillType.DataSource = dicbll.GetCBKind(" and VALUE in(1,2)");
s_stBillType.DataBind();
}
public void BindBillUsingType()
{
stBillUsingType.DataSource = dicbll.GetBillType("");
stBillUsingType.DataBind();
s_stBillUsingType.DataSource = dicbll.GetBillType("");
s_stBillUsingType.DataBind();
}
public void BindBillName()
{
//string sqlwhere = " and FLAG='" + CommonHelper._ishighway + "'";
string sqlwhere = string.Empty;
stBillName.DataSource = dicbll.GetCBBillName(sqlwhere);
stBillName.DataBind();
s_stBillName.DataSource = dicbll.GetCBBillName(sqlwhere);
s_stBillName.DataBind();
}
/// <summary>
/// 票据种类-有票据类型,票据种类找出票据名称
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void cmbBillKind_Select(object sender, Ext.Net.DirectEventArgs e)
{
string sqlwhere = string.Empty;
if (!string.IsNullOrEmpty(cmbBillType.SelectedItem.Value))
{
sqlwhere += " and TYPE='" + cmbBillType.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票类型");
return;
}
if (!string.IsNullOrEmpty(cmbBillKind.SelectedItem.Value))
{
sqlwhere += " and KIND='" + cmbBillKind.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票种类");
return;
}
if (cmbBillType.SelectedItem.Value == "1")
{
if (CommonHelper._userType == "1")
{
sqlwhere += " and FLAG='" + CommonHelper._ishighway + "'";
}
}
//sqlwhere += " and value<=16";
//sqlwhere += " and FLAG='" + CommonHelper._ishighway + "'";
stBillName.DataSource = dicbll.GetCBBillName(sqlwhere);
stBillName.DataBind();
}
/// <summary>
/// 区分站和上级单位
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void cmbIsHigh_Select(object sender, Ext.Net.DirectEventArgs e)
{
string sqlwhere = string.Empty;
if (!string.IsNullOrEmpty(cmbBillType.SelectedItem.Value))
{
sqlwhere += " and TYPE='" + cmbBillType.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票类型");
return;
}
if (!string.IsNullOrEmpty(cmbBillKind.SelectedItem.Value))
{
sqlwhere += " and KIND='" + cmbBillKind.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票种类");
return;
}
//sqlwhere += " and FLAG='" + cmbIsHigh.SelectedItem.Value + "'";
stBillName.DataSource = dicbll.GetCBBillName(sqlwhere);
stBillName.DataBind();
}
// <summary>
/// 票据种类-有票据类型,票据种类找出票据名称
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void cmbBillName_Select(object sender, Ext.Net.DirectEventArgs e)
{
//txtBillName.Text = cmbBillName.SelectedItem.Text.Trim();
string sqlwhere = string.Empty;
if (!string.IsNullOrEmpty(cmbBillType.SelectedItem.Value))
{
sqlwhere += " and KIND='" + cmbBillType.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票类型");
return;
}
if (!string.IsNullOrEmpty(cmbBillKind.SelectedItem.Value))
{
sqlwhere += " and BILLKIND='" + cmbBillKind.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票种类");
return;
}
//if (!string.IsNullOrEmpty(cmbIsHigh.SelectedItem.Value))
//{
// sqlwhere += " and BAK1='" + cmbIsHigh.SelectedItem.Value + "'";
//}
//else
//{
// if (CommonHelper._userType == "1")
// {
// sqlwhere += " and BAK1='" + CommonHelper._ishighway + "'";
// }
// else
// {
// CommonHelper.MsgShowInfo("请选择单位类别");
// return;
// }
//}
DataTable dt = null;
try
{
sqlwhere += " and BILLNAME='" + cmbBillName.SelectedItem.Value + "'";
//获取今年的发票代码
dt = dicbll.GetBillSeqNO(sqlwhere);
}
catch
{
dt = new DataTable();
}
cmbBillSeqNo.Clear();
txtBillSeqNo.Text = "";
stBillSeqNo.DataSource = dt;
stBillSeqNo.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void cmbBillSeqNo_Select(object sender, Ext.Net.DirectEventArgs e)
{
txtBillSeqNo.Text = cmbBillSeqNo.SelectedItem.Value;
}
/// <summary>
/// 票据种类-有票据类型,票据种类找出票据名称
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void s_cmbBillKind_Select(object sender, Ext.Net.DirectEventArgs e)
{
string sqlwhere = string.Empty;
if (!string.IsNullOrEmpty(s_cmbbillType.SelectedItem.Value))
{
sqlwhere += " and TYPE='" + s_cmbbillType.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票类型");
return;
}
if (!string.IsNullOrEmpty(s_cmbBillKind.SelectedItem.Value))
{
sqlwhere += " and KIND='" + s_cmbBillKind.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票种类");
return;
}
sqlwhere += " and value<=16";
//sqlwhere += " and FLAG='" + CommonHelper._ishighway + "'";
s_stBillName.DataSource = dicbll.GetCBBillName(sqlwhere);
s_stBillName.DataBind();
}
/// <summary>
/// 区分站和上级单位
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void s_cmbIsHigh_Select(object sender, Ext.Net.DirectEventArgs e)
{
string sqlwhere = string.Empty;
if (!string.IsNullOrEmpty(s_cmbbillType.SelectedItem.Value))
{
sqlwhere += " and TYPE='" + s_cmbbillType.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票类型");
return;
}
if (!string.IsNullOrEmpty(s_cmbBillKind.SelectedItem.Value))
{
sqlwhere += " and KIND='" + s_cmbBillKind.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票种类");
return;
}
//sqlwhere += " and FLAG='" + s_cmbIsHigh.SelectedItem.Value + "'";
s_stBillName.DataSource = dicbll.GetCBBillName(sqlwhere);
s_stBillName.DataBind();
}
// <summary>
/// 票据种类-有票据类型,票据种类找出票据名称
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void s_cmbBillName_Select(object sender, Ext.Net.DirectEventArgs e)
{
//txtBillName.Text = cmbBillName.SelectedItem.Text.Trim();
string sqlwhere = string.Empty;
if (!string.IsNullOrEmpty(s_cmbbillType.SelectedItem.Value))
{
sqlwhere += " and KIND='" + s_cmbbillType.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票类型");
return;
}
if (!string.IsNullOrEmpty(s_cmbBillKind.SelectedItem.Value))
{
sqlwhere += " and BILLKIND='" + s_cmbBillKind.SelectedItem.Value + "'";
}
else
{
CommonHelper.MsgShowInfo("请选择票种类");
return;
}
//if (!string.IsNullOrEmpty(s_cmbIsHigh.SelectedItem.Value))
//{
// sqlwhere += " and BAK1='" + s_cmbIsHigh.SelectedItem.Value + "'";
//}
//else
//{
// if (CommonHelper._userType == "1")
// {
// sqlwhere += " and BAK1='" + CommonHelper._ishighway + "'";
// }
// else
// {
// CommonHelper.MsgShowInfo("请选择单位类别");
// return;
// }
//}
DataTable dt = null;
try
{
sqlwhere += " and BILLNAME='" + s_cmbBillName.SelectedItem.Value + "'";
//获取今年的发票代码
dt = dicbll.GetBillSeqNO(sqlwhere);
}
catch
{
dt = new DataTable();
}
s_cmbBillSeqNo.Clear();
s_txtBillSeqNo.Text = "";
s_stBillSeqNo.DataSource = dt;
s_stBillSeqNo.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void s_cmbBillSeqNo_Select(object sender, Ext.Net.DirectEventArgs e)
{
s_txtBillSeqNo.Text = s_cmbBillSeqNo.SelectedItem.Value;
}
#endregion 绑定数据
#region 增删改
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, Ext.Net.DirectEventArgs e)
{
wdSearch.Hide();
Paging.SetPageIndex(1);
StCardInfo.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void StCardInfo_RefreshData(object sender, Ext.Net.StoreRefreshDataEventArgs e)
{
int start; int limit;
if (!string.IsNullOrEmpty(e.Parameters["Start"]) && !string.IsNullOrEmpty(e.Parameters["Limit"]))
{
start = int.Parse(e.Parameters["Start"]);
limit = int.Parse(e.Parameters["Limit"]);
}
else
{
start = e.Start;
limit = e.Limit;
}
if (s_txtStartDt.Value == null || string.IsNullOrEmpty(s_txtStartDt.Value.ToString()) || s_txtEndDt.Value == null)
{
CommonHelper.MsgShowInfo("请选择查询日期!");
return;
}
string sqlwhere = string.Empty;
TimeSpan ts = Convert.ToDateTime(s_txtEndDt.Value) - Convert.ToDateTime(s_txtStartDt.Value);
if (ts.Days < 0)
{
CommonHelper.MsgShowInfo("开始日期不大于结束日期!");
return;
}
if (CommonHelper._dbType == "1")
{
sqlwhere += " and CLASSDATE>='" + Convert.ToDateTime(s_txtStartDt.Value).ToString("yyyy-MM-dd") + "' and CLASSDATE<='" + Convert.ToDateTime(s_txtEndDt.Value).ToString("yyyy-MM-dd") + "'";
}
else if (CommonHelper._dbType == "4")
{
sqlwhere += " and CLASSDATE>=DATE_FORMAT('" + Convert.ToDateTime(s_txtStartDt.Value).ToString("yyyy-MM-dd HH:mm:ss") + "','%Y-%m-%d %H:%i:%s') and CLASSDATE<=DATE_FORMAT('" + Convert.ToDateTime(s_txtEndDt.Value).AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") + "','%Y-%m-%d %H:%i:%s')";
}
else
{
sqlwhere += " and CLASSDATE>=to_date('" + Convert.ToDateTime(s_txtStartDt.Value).ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd HH24:mi:ss') and CLASSDATE<=to_date('" + Convert.ToDateTime(s_txtEndDt.Value).ToString("yyyy-MM-dd") + "','yyyy-MM-dd HH24:mi:ss')";
}
//if (!string.IsNullOrEmpty(s_txtBillSeqNo.Text.Trim()))
//{
// sqlwhere += " and BILLNO like '%" + s_txtBillSeqNo.Text.Trim() + "%'";
//}
if (!string.IsNullOrEmpty(s_cmbbillType.SelectedItem.Value))
{
sqlwhere += " and KIND='" + s_cmbbillType.SelectedItem.Value + "'";
}
if (!string.IsNullOrEmpty(s_cmbBillKind.SelectedItem.Value))
{
sqlwhere += " and BILLKIND='" + s_cmbBillKind.SelectedItem.Value + "'";
}
if (!string.IsNullOrEmpty(s_cmbBillUsingType.SelectedItem.Value))
{
sqlwhere += " and BILLTYPE='" + s_cmbBillUsingType.SelectedItem.Value + "'";
}
if (!string.IsNullOrEmpty(s_cmbBillName.Text.Trim()))
{
sqlwhere += " and BILLNAME='" + s_cmbBillName.Text.Trim() + "'";
}
if (!string.IsNullOrEmpty(s_txtBillSeqNo.Text.Trim()))
{
sqlwhere += " and BILLSEQNO='" + s_txtBillSeqNo.Text.Trim() + "'";
}
if (!string.IsNullOrEmpty(s_txtAcarNo.Text.Trim()))
{
sqlwhere += " and ACARNO like '%" + s_txtAcarNo.Text.Trim() + "%'";
}
if (CommonHelper._userType == "2" && CommonHelper._ishighway == "2")
{
sqlwhere += " and SUBCOMNO=" + CommonHelper._userStaNo + "";
}
int ct = 0;
DataTable dt = billbll.GetBillInfoLst(sqlwhere, start + 1, start + limit, out ct);
e.Total = ct;
StCardInfo.DataSource = dt;
StCardInfo.DataBind();
}
/// <summary>
/// 增加
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAdd_Click(object sender, Ext.Net.DirectEventArgs e)
{
if (hdMan.Value.ToString().ToLower() == "admin")
{
CommonHelper.MsgShowInfo("ADMIN禁止更改卡信息...");
return;
}
if (string.IsNullOrEmpty(txtBillNo.Text) || string.IsNullOrEmpty(txtInCash.Text.Trim()))
{
CommonHelper.MsgShowInfo("请输入正确票据号/开票金额...");
return;
}
if (string.IsNullOrEmpty(txtBillSeqNo.Text))
{
CommonHelper.MsgShowInfo("请输入正确票据代码...");
return;
}
if (string.IsNullOrEmpty(cmbBillKind.SelectedItem.Value) || string.IsNullOrEmpty(cmbBillType.SelectedItem.Value) || string.IsNullOrEmpty(cmbBillUsingType.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("请选择发票类型/发票种类/使用类别...");
return;
}
if (string.IsNullOrEmpty(txtClassDt.Text.Trim()) || string.IsNullOrEmpty(cmbClassNo.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("请输入正确统计日/班次...");
return;
}
if (string.IsNullOrEmpty(cmbBillName.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("请选择票据名称...");
return;
}
if (string.IsNullOrEmpty(txtAcarno.Text.Trim()))
{
CommonHelper.MsgShowInfo("请输入正确车牌...");
return;
}
else
{
//string str = @"^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$";
//Regex rg = new Regex(str);
//if (!rg.IsMatch(txtAcarno.Text.Trim()))
//{
// CommonHelper.MsgShowInfo("请输入正确车牌...");
// return;
//}
if (!CommonHelper.TxtLength(txtAcarno.Text.Trim(), 8))
{
CommonHelper.MsgShowInfo("请输入正确车牌...");
return;
}
}
int cash = 0;
int ct = 0;
if (string.IsNullOrEmpty(txtInCash.Text.Trim()))
{
CommonHelper.MsgShowInfo("请输入开票金额...");
return;
}
else
{
bool f = int.TryParse(txtInCash.Text.Trim(), out ct);
if (f)
{
cash = Convert.ToInt32(Convert.ToDecimal(txtInCash.Text.Trim()) * 100);
}
else
{
CommonHelper.MsgShowInfo("请输入正确的开票金额...");
return;
}
}
try
{
CB_BILLINFO_TABLE mdl = new CB_BILLINFO_TABLE();
if (CommonHelper._userType == "3" || CommonHelper._userType == "3")
{
mdl.SUBCOMNO = 1;
}
else if (CommonHelper._userType == "2")
{
mdl.SUBCOMNO = int.Parse(CommonHelper._userStaNo);
}
else
{
DataTable dtSta = dicbll.GetStaAllInfo(" and STANO=" + CommonHelper._userStaNo + "");
mdl.SUBCOMNO = int.Parse(dtSta.Rows[0]["SUBCOMNO"].ToString());
}
string ishav = "select count(1) from CB_BILLINFO_TABLE where BILLNO = '" + txtBillNo.Text.Trim() + "' and SUBCOMNO=" + mdl.SUBCOMNO + " and STANO=" + CommonHelper._userStaNo + " and INCASH=" + cash + "";
if (billbll.IsExist(ishav) > 0)
{
CommonHelper.MsgShowInfo("该金额(" + ct + "元)下票号已录入,请输入正确的票号...");
return;
}
mdl.STANO = int.Parse(CommonHelper._userStaNo);
mdl.MKDT = DateTime.Now;
mdl.ACARNO = txtAcarno.Text.Trim();
mdl.INCASH = cash;
mdl.KIND = int.Parse(cmbBillType.SelectedItem.Value);
mdl.BILLTYPE = int.Parse(cmbBillUsingType.SelectedItem.Value);
mdl.BILLNO = long.Parse(txtBillNo.Text.Trim());
mdl.ENDBILLNO = long.Parse(txtBillNo.Text.Trim());
mdl.CLASSDATE = DateTime.Parse(txtClassDt.Text.Trim());
mdl.CLASSNO = int.Parse(cmbClassNo.SelectedItem.Value);
mdl.ADMANNO = int.Parse(hdUserId.Value.ToString());
mdl.ADMAN = hdMan.Value.ToString();
mdl.DATEMARK = DateTime.Now;
mdl.REMARK = txtRemark.Text.Trim();
mdl.USERTYPE = int.Parse(CommonHelper._userType);
mdl.BILLNAME = int.Parse(cmbBillName.SelectedItem.Value);
mdl.BILLSEQNO = txtBillSeqNo.Text.Trim();
mdl.BILLKIND = int.Parse(cmbBillKind.SelectedItem.Value);
if (billbll.AddBillInfo(mdl))
{
CommonHelper.MsgShowInfo("票据信息录入成功");
}
else
{
CommonHelper.MsgShowInfo("票据信息录入失败,请重新操作...");
}
}
catch (Exception ex)
{
CommonHelper.MsgShowInfo("票据信息录入异常:" + ex.Message);
}
StCardInfo.DataBind();
wdEdit.Hide();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click(object sender, Ext.Net.DirectEventArgs e)
{
DataTable dt;
try
{
if (hdSubCmno.Value == null || hdStano.Value == null || hdBillNo.Value == null || hdMKDt.Value == null || hdoldManNo.Value == null || hdInCash.Value == null)
{
CommonHelper.MsgShowInfo("请重新选择要操作的行...");
return;
}
else
{
if (hdoldManNo.Value != null && !string.IsNullOrEmpty(hdoldManNo.Value.ToString()))
{
if (!hdoldManNo.Value.Equals(hdUserId.Value.ToString()) || !hdoldUType.Value.ToString().Equals(CommonHelper._userType))
{
CommonHelper.MsgShowInfo("非本人/非本单位录入数据,不允许更改...");
return;
}
}
//启用修改指令
//if (CommonHelper._updateflag == CommonHelper._UpdateOrder_Flag.ToString())
//{
// string djDt = hdMKDt.Value.ToString();
// TimeSpan ts = DateTime.Now - Convert.ToDateTime(djDt);
// if ((ts.TotalMinutes > 60 && ts.Days == 0) || ts.Days >= 1)
// {
// if (!CommonHelper.CheckUpdate(out dt, Convert.ToDateTime(hdMKDt.Value).Date))
// {
// CommonHelper.MsgShowInfo("未收到-修改指令,不允许更改数据,请提交修改申请...");
// return;
// }
// }
//}
//else
//{
// string djDt = hdMKDt.Value.ToString();
// TimeSpan ts = DateTime.Now - Convert.ToDateTime(djDt);
// if ((ts.Hours > 1 && ts.Days == 0) || ts.Days >= 1)
// {
// CommonHelper.MsgShowInfo("数据已超过1小时不允许修改...");
// return;
// }
//}
}
if (string.IsNullOrEmpty(txtInCash.Text.Trim()))
{
CommonHelper.MsgShowInfo("请输入正确开票金额...");
return;
}
if (string.IsNullOrEmpty(txtBillSeqNo.Text))
{
CommonHelper.MsgShowInfo("请输入正确票据代码...");
return;
}
if (string.IsNullOrEmpty(cmbBillKind.SelectedItem.Value) || string.IsNullOrEmpty(cmbBillType.SelectedItem.Value) || string.IsNullOrEmpty(cmbBillUsingType.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("请选择发票类型/发票种类/使用类别...");
return;
}
if (string.IsNullOrEmpty(txtClassDt.Text.Trim()) || string.IsNullOrEmpty(cmbClassNo.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("请输入正确统计日/班次...");
return;
}
if (string.IsNullOrEmpty(cmbBillName.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("请选择票据名称...");
return;
}
if (string.IsNullOrEmpty(txtAcarno.Text.Trim()))
{
CommonHelper.MsgShowInfo("请输入正确车牌...");
return;
}
else
{
string str = @"^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$";
Regex rg = new Regex(str);
if (!rg.IsMatch(txtAcarno.Text.Trim()))
{
CommonHelper.MsgShowInfo("请输入正确车牌...");
return;
}
}
int cash = 0;
int ct = 0;
if (string.IsNullOrEmpty(txtInCash.Text.Trim()))
{
CommonHelper.MsgShowInfo("请输入开票金额...");
return;
}
else
{
bool f = int.TryParse(txtInCash.Text.Trim(), out ct);
if (f)
{
cash = Convert.ToInt32(Convert.ToDecimal(txtInCash.Text.Trim()) * 100);
}
else
{
CommonHelper.MsgShowInfo("请输入正确的开票金额...");
return;
}
}
CB_BILLINFO_TABLE mdl = new CB_BILLINFO_TABLE();
mdl.SUBCOMNO = int.Parse(hdSubCmno.Value.ToString());
mdl.STANO = int.Parse(hdStano.Value.ToString());
mdl.BILLNO = long.Parse(hdBillNo.Value.ToString());
mdl.ACARNO = txtAcarno.Text.Trim();
mdl.INCASH = cash;
mdl.KIND = int.Parse(cmbBillType.SelectedItem.Value);
mdl.BILLTYPE = int.Parse(cmbBillUsingType.SelectedItem.Value);
mdl.CLASSDATE = DateTime.Parse(txtClassDt.Text.Trim());
mdl.CLASSNO = int.Parse(cmbClassNo.SelectedItem.Value);
mdl.ADMANNO = int.Parse(hdUserId.Value.ToString());
mdl.ADMAN = hdMan.Value.ToString();
mdl.DATEMARK = DateTime.Now;
mdl.REMARK = txtRemark.Text.Trim();
mdl.USERTYPE = int.Parse(CommonHelper._userType);
mdl.BILLNAME = int.Parse(cmbBillName.SelectedItem.Value);
mdl.BILLSEQNO = txtBillSeqNo.Text.Trim();
if (billbll.UpdateBillInfo(mdl, CreateLog()))
{
CommonHelper.MsgShowInfo("票据信息修改成功");
}
else
{
CommonHelper.MsgShowInfo("票据信息修改失败,请重新操作...");
}
}
catch (Exception ex)
{
CommonHelper.MsgShowInfo("票据信息修改异常:" + ex.Message);
}
StCardInfo.DataBind();
wdEdit.Hide();
}
/// <summary>
/// 删除
/// </summary>
[DirectMethod]
public void Delete(string subcomno, string stano, string cardno, string incash)
{
try
{
string djDt = hdMKDt.Value.ToString();
TimeSpan ts = DateTime.Now - Convert.ToDateTime(djDt);
if (CommonHelper._userType == "1")
{
//if ((ts.Hours > 1 && ts.Days == 0) || ts.Days >= 1)
//{
// CommonHelper.MsgShowInfo("数据已超过1小时不允许删除...");
// return;
//}
if (hdoldManNo.Value != null && !string.IsNullOrEmpty(hdoldManNo.Value.ToString()))
{
if (!hdoldManNo.Value.Equals(hdUserId.Value.ToString()) || !hdoldUType.Value.ToString().Equals(CommonHelper._userType))
{
CommonHelper.MsgShowInfo("非本人/非本单位录入数据,不允许删除...");
return;
}
}
}
string sql = "delete from CB_BILLINFO_TABLE where 1=1 and SUBCOMNO='" + subcomno + "' and STANO='" + stano + "' and BILLNO='" + cardno + "' and INCASH='" + incash + "'";
if (billbll.ExcuteSql(sql))
{
CommonHelper.MsgShowInfo("卡信息删除成功");
}
else
{
CommonHelper.MsgShowInfo("卡信息删除失败,请重新操作...");
}
}
catch (Exception ex)
{
CommonHelper.MsgShowInfo("卡信息删除异常:" + ex.Message);
}
StCardInfo.DataBind();
}
/// <summary>
/// 构建日志
/// </summary>
/// <returns></returns>
public CB_OP_LOG CreateLog()
{
bool f = false;
CB_OP_LOG mdl = new CB_OP_LOG();
try
{
string new_subcomno = "0000" + hdSubCmno.Value.ToString();
string new_stano = "0000" + hdStano.Value.ToString();
mdl.KEYLISTNO = new_subcomno.Substring(new_subcomno.Length - 4) + new_stano.Substring(new_stano.Length - 4) + hdBillNo.Value.ToString();//主键集合
mdl.ID = CommonHelper._Prmis_Bill_BillInfo + new_subcomno.Substring(new_subcomno.Length - 4) + new_stano.Substring(new_stano.Length - 4) + DateTime.Now.ToString("yyyyMMddHHmmss");
mdl.TBNAME = CommonHelper.GetTbNameByPrmisid(CommonHelper._Prmis_Bill_BillInfo);//对应的表名称
mdl.TYPE = CommonHelper._OpLog_Jx;//1-根据字典表解析KEYLISTNO 2-不需要解析
mdl.PRMISID = CommonHelper._Prmis_Bill_BillInfo;//模块号
mdl.SUBCOMNO = int.Parse(hdSubCmno.Value.ToString());
mdl.STANO = int.Parse(CommonHelper._userStaNo);
mdl.OPTYPE = 1;//产生日志类型 1-修改
mdl.OLDT = Convert.ToDateTime(hdoldDt.Value.ToString());
mdl.OLMANNO = int.Parse(hdoldManNo.Value.ToString());
mdl.OLMAN = hdoldMan.Value.ToString();
mdl.OLUSERTYPE = int.Parse(hdoldUType.Value.ToString());
mdl.DATETIME = DateTime.Now;
mdl.UPMANNO = int.Parse(hdUserId.Value.ToString());
mdl.UPMAN = hdMan.Value.ToString();
mdl.UPUSERTYPE = int.Parse(CommonHelper._userType);
mdl.BAK1 = 0;
mdl.BAK2 = 0;
mdl.BAK3 = 0;
mdl.BAK4 = string.Empty;
mdl.BAK5 = string.Empty;
mdl.BAK6 = string.Empty;
}
catch (Exception ex)
{
mdl = null;
}
return mdl;
}
#endregion 增删改
}
}