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.

479 lines
17 KiB
C#

using BLL.CardBill;
using BLL.Sys;
using Ext.Net;
using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CPCBILLSYS
{
public partial class BillKindMg : System.Web.UI.Page
{
DictionaryBLL dicbll = new DictionaryBLL(CommonHelper._dbType, CommonHelper.DbConStr);
/// <summary>
/// cpc
/// </summary>
BILLBLL bbll = new BILLBLL(CommonHelper._dbType, CommonHelper.DbConStr);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindKind();
BindBillKind();
BindIsHigh();
stBillName.AutoLoadParams.Add(new Ext.Net.Parameter("Start", "0"));
stBillName.AutoLoadParams.Add(new Ext.Net.Parameter("Limit", ptbar.PageSize.ToString()));
stBillSeqNO.AutoLoadParams.Add(new Ext.Net.Parameter("Start", "0"));
stBillSeqNO.AutoLoadParams.Add(new Ext.Net.Parameter("Limit", PageSeqNO.PageSize.ToString()));
if (CommonHelper._userType == "1" || CommonHelper._userType == "2")
{
//票据代码
Button1.Hide();
Button2.Hide();
//票据名称
s_btnAdd.Hide();
s_btnDel.Hide();
}
else
{
s_btnAdd.Show();
s_btnDel.Show();
}
E_CmbIsHigh.Hide();
s_cmbSeq_IsHigh.Hide();
SeqNo_cmbIsHigh.Hide();
}
}
#region 绑定
public void BindKind()
{
DataTable dt = dicbll.GetCBKind(" and VALUE in(1,2)");
stEBillType.DataSource = dt;
stEBillType.DataBind();
}
public void BindBillKind()
{
DataTable dt = dicbll.GetCBBillKind("");
stEBillKind.DataSource = dt;
stEBillKind.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();
}
#endregion 绑定
#region 票据名称增删改
static string billNameToSeqNoSqlwhere = string.Empty;
/// <summary>
///
/// </summary>
[DirectMethod]
public void SearchSeqNo(string billtype, string billkind, string billname)
{
billNameToSeqNoSqlwhere = " and BILLNAME='" + billname + "' and BILLKIND='" + billkind + "' and KIND='" + billtype + "'";
stBillSeqNO.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void stBillName_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;
}
int ct = 0;
string sqlwhere = string.Empty;
if (CommonHelper._userType == "1")
{
sqlwhere += " and flag=" + CommonHelper._ishighway + "";
}
//sqlwhere += " and value<=16";
DataTable dt = bbll.GetBillNameLst(sqlwhere, start, start + limit, out ct);
e.Total = ct;
stBillName.DataSource = dt;
stBillName.DataBind();
}
public void E_btnAdd_Click(object sender, Ext.Net.DirectEventArgs e)
{
int v = 0;
try
{
string sqlStr = "insert into CB_BILLNAME_TEXT(VALUE,TEXT,TYPE,KIND,FLAG) VALUES('{0}','{1}','{2}','{3}','{4}')";
if (string.IsNullOrEmpty(E_CmbBillType.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("选取票据类型");
return;
}
if (string.IsNullOrEmpty(E_CmbBillKind.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("选取票据种类");
return;
}
//if (string.IsNullOrEmpty(E_CmbIsHigh.SelectedItem.Value))
//{
// CommonHelper.MsgShowInfo("输入票据信息");
// return;
//}
if (string.IsNullOrEmpty(E_txtBillName.Text.Trim()))
{
CommonHelper.MsgShowInfo("输入票据信息");
return;
}
string billName = string.Empty;
if (E_txtBillName.Text.Trim().Length > 99)
{
billName = E_txtBillName.Text.Trim().Substring(0, 99);
}
else
{
billName = E_txtBillName.Text.Trim();
}
object obj = dicbll.GetCBMaxBillName(" and type='" + E_CmbBillType.SelectedItem.Value + "' and kind='" + E_CmbBillKind.SelectedItem.Value + "'");
if (obj == null)
{
v = 0;
}
else
{
v = int.Parse(obj.ToString());
}
string sql = string.Format(sqlStr, v, billName, E_CmbBillType.SelectedItem.Value, E_CmbBillKind.SelectedItem.Value, '0');
if (dicbll.MyExcute(sql))
{
CommonHelper.MsgShowInfo("票据信息录入成功");
}
else
{
CommonHelper.MsgShowInfo("票据信息录入失败");
}
}
catch (Exception ex)
{
CommonHelper.MsgShowInfo("新增票据信息异常:" + ex.Message);
}
wdDetail.Hide();
stBillName.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="v"></param>
[DirectMethod]
public void E_Delete(string v, string type)
{
try
{
string[] sgpV = { "10", "11", "12", "13", "14", "15", "16", "21", "22", "23", "24", "25", "26", "27" };
if (type == CommonHelper._BillType_Hd.ToString())
{
if (sgpV.Contains(v))
{
CommonHelper.MsgShowInfo("固定手工票禁止删除");
return;
}
}
else if (type == CommonHelper._BillType_pc.ToString())
{
if (v == "1" || v == "2")
{
CommonHelper.MsgShowInfo("高速和一级道路固定微机票禁止删除");
return;
}
}
string sql = "delete from CB_BILLNAME_TEXT where VALUE='" + v + "'";
if (dicbll.MyExcute(sql))
{
CommonHelper.MsgShowInfo("票据信息删除成功");
}
else
{
CommonHelper.MsgShowInfo("票据信息删除失败");
}
}
catch (Exception ex)
{
CommonHelper.MsgShowInfo("删除票据信息异常:" + ex.Message);
}
stBillName.DataBind();
}
#endregion 票据名称增删改
#region 票据序列号
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void SeqNo_cmbBillKind_Select(object sender, Ext.Net.DirectEventArgs e)
{
if (SeqNo_cmbBillType.SelectedItem.Value == null)
{
CommonHelper.MsgShowInfo("请选择-票据类型");
return;
}
if (SeqNo_cmbBillKind.SelectedItem.Value == null)
{
CommonHelper.MsgShowInfo("请选择-票据种类");
return;
}
DataTable dt = dicbll.GetCBBillName(" and type='" + SeqNo_cmbBillType.SelectedItem.Value + "' and kind='" + SeqNo_cmbBillKind.SelectedItem.Value + "'");
stEBillName.DataSource = dt;
stEBillName.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void SeqNo_cmbIsHigh_Select(object sender, Ext.Net.DirectEventArgs e)
{
if (SeqNo_cmbBillType.SelectedItem.Value == null)
{
CommonHelper.MsgShowInfo("请选择-票据类型");
return;
}
if (SeqNo_cmbBillKind.SelectedItem.Value == null)
{
CommonHelper.MsgShowInfo("请选择-票据种类");
return;
}
DataTable dt = dicbll.GetCBBillName(" and type='" + SeqNo_cmbBillType.SelectedItem.Value + "' and kind='" + SeqNo_cmbBillKind.SelectedItem.Value + "' and flag='" + SeqNo_cmbIsHigh.SelectedItem.Value + "'");
stEBillName.DataSource = dt;
stEBillName.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void s_cmbSeq_IsHigh_Select(object sender, Ext.Net.DirectEventArgs e)
{
string sqlwhere = string.Empty;
if (s_cmbSeq_BillType.SelectedItem.Value == null)
{
CommonHelper.MsgShowInfo("请选择-票据类型");
return;
}
else
{
sqlwhere += " and type='" + s_cmbSeq_BillType.SelectedItem.Value + "'";
}
if (s_cmbSeq_BillKind.SelectedItem.Value == null)
{
CommonHelper.MsgShowInfo("请选择-票据种类");
return;
}
else
{
sqlwhere += " and kind='" + s_cmbSeq_BillKind.SelectedItem.Value + "'";
}
if (s_cmbSeq_BillType.SelectedItem.Value == "1")
{
sqlwhere += " and FLAG='" + CommonHelper._ishighway + "'";
}
//sqlwhere += " and value<=16";
DataTable dt = dicbll.GetCBBillName(sqlwhere);
stEBillName.DataSource = dt;
stEBillName.DataBind();
}
protected void S_btnSeqNoSearch_Click(object sender, Ext.Net.DirectEventArgs e)
{
billNameToSeqNoSqlwhere = string.Empty;
PageSeqNO.SetPageIndex(1);
stBillSeqNO.DataBind();
wdSeqNOSearch.Hide();
}
protected void stBillSeqNO_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;
}
string sqlwhere = string.Empty;
if (string.IsNullOrEmpty(billNameToSeqNoSqlwhere))
{
if (!string.IsNullOrEmpty(s_cmbSeq_BillType.SelectedItem.Value))
{
sqlwhere += " and KIND='" + s_cmbSeq_BillType.SelectedItem.Value + "'";
}
if (!string.IsNullOrEmpty(s_cmbSeq_BillName.SelectedItem.Value))
{
sqlwhere += " and BILLNAME='" + s_cmbSeq_BillName.SelectedItem.Value + "'";
}
if (!string.IsNullOrEmpty(s_cmbSeq_BillKind.SelectedItem.Value))
{
sqlwhere += " and BILLKIND='" + s_cmbSeq_BillKind.SelectedItem.Value + "'";
}
if (!string.IsNullOrEmpty(s_cmbSeq_txtBillSeqNO.Text.Trim()))
{
sqlwhere += " and BILLSEQNO='" + s_cmbSeq_txtBillSeqNO.Text.Trim() + "'";
}
}
else
{
sqlwhere += billNameToSeqNoSqlwhere;
}
//if (CommonHelper._userType == "1")
//{
// if (CommonHelper._ishighway == "1")
// {
// sqlwhere += " and BAK1=" + CommonHelper._ishighway + "";
// }
//}
//else
//{
// if (!string.IsNullOrEmpty(s_cmbSeq_IsHigh.Text.Trim()))
// {
// sqlwhere += " and BAK1='" + s_cmbSeq_IsHigh.Text.Trim() + "'";
// }
//}
int ct = 0;
DataTable dt = bbll.GetBillSeqNoLst(sqlwhere, start, start + limit, out ct);
e.Total = ct;
stBillSeqNO.DataSource = dt;
stBillSeqNO.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void E_btnSeqNoAdd_Click(object sender, Ext.Net.DirectEventArgs e)
{
int v = 0;
try
{
if (string.IsNullOrEmpty(SeqNo_cmbBillKind.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("选取票据种类");
return;
}
if (string.IsNullOrEmpty(SeqNo_cmbBillType.SelectedItem.Value))
{
CommonHelper.MsgShowInfo("选取票据类型");
return;
}
if (string.IsNullOrEmpty(SeqNo_cmbBillName.Text.Trim()))
{
CommonHelper.MsgShowInfo("选取票据名称");
return;
}
//if (string.IsNullOrEmpty(SeqNo_cmbIsHigh.Text.Trim()))
//{
// CommonHelper.MsgShowInfo("选取单位类型");
// return;
//}
if (string.IsNullOrEmpty(SeqNo_txtBillSeqNo.Text.Trim()))
{
CommonHelper.MsgShowInfo("输入正确的票据代码");
return;
}
CB_BILLSEQNO_TABLE mdl = new CB_BILLSEQNO_TABLE();
mdl.BILLNAME = int.Parse(SeqNo_cmbBillName.SelectedItem.Value);
mdl.BILLKIND = int.Parse(SeqNo_cmbBillKind.SelectedItem.Value);
mdl.BILLSEQNO = SeqNo_txtBillSeqNo.Text.Trim();
mdl.KIND = int.Parse(SeqNo_cmbBillType.SelectedItem.Value);
mdl.DATEMAKE = DateTime.Now;
mdl.BAK1 = 0; //int.Parse(SeqNo_cmbIsHigh.SelectedItem.Value);
mdl.BAK2 = "";
if (bbll.IsExistBillSeqNo(" and BILLNAME='" + mdl.BILLNAME + "' AND BILLKIND='" + mdl.BILLKIND + "' AND BILLSEQNO='" + mdl.BILLSEQNO + "'"))
{
CommonHelper.MsgShowInfo(mdl.BILLNAME + "-" + mdl.BILLKIND + "</br>发票代码" + mdl.BILLSEQNO + "-信息已录入");
}
else
{
if (bbll.AddBillSeqNO(mdl))
{
CommonHelper.MsgShowInfo("票据代码(" + mdl.BILLSEQNO + ")信息录入成功");
}
else
{
CommonHelper.MsgShowInfo("票据代码(" + mdl.BILLSEQNO + ")信息录入失败");
}
}
}
catch (Exception ex)
{
CommonHelper.MsgShowInfo("新增票据代码(" + SeqNo_txtBillSeqNo.Text.Trim() + ")信息异常:" + ex.Message);
}
wdBillSeqNo.Hide();
stBillSeqNO.DataBind();
}
/// <summary>
///
/// </summary>
/// <param name="v"></param>
[DirectMethod]
public void E_SeqNoDelete(string v)
{
try
{
string sql = "delete from CB_BILLSEQNO_TABLE where BILLSEQNO='" + v + "'";
if (dicbll.MyExcute(sql))
{
CommonHelper.MsgShowInfo("票据信息删除成功");
}
else
{
CommonHelper.MsgShowInfo("票据信息删除失败");
}
}
catch (Exception ex)
{
CommonHelper.MsgShowInfo("删除票据信息异常:" + ex.Message);
}
stBillSeqNO.DataBind();
}
#endregion 票据序列号
}
}