232 lines
10 KiB
C#
232 lines
10 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;
|
|
|
|
public partial class Supply_BuyOrder : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
ZWL.Common.PublicMethod.CheckSession();
|
|
DataBindToGridview();
|
|
|
|
//设定按钮权限
|
|
ImageButton1.Visible = ZWL.Common.PublicMethod.StrIFIn("|A016A|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
|
|
ImageButton5.Visible = ZWL.Common.PublicMethod.StrIFIn("|A016M|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
|
|
ImageButton3.Visible = ZWL.Common.PublicMethod.StrIFIn("|A016D|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
|
|
ImageButton2.Visible = ZWL.Common.PublicMethod.StrIFIn("|A016E|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void DataBindToGridview()
|
|
{
|
|
ZWL.BLL.ERPBuyOrder MyModel = new ZWL.BLL.ERPBuyOrder();
|
|
MyModel.HZ();
|
|
string XiaShuUser = ZWL.DBUtility.DbHelperSQL.GetSHSLInt("select top 1 XiaShuUser from ERPUser where UserName='" + ZWL.Common.PublicMethod.GetSessionValue("UserName") + "'");
|
|
string SSTempSTR = "";
|
|
if (XiaShuUser != "全部")
|
|
{
|
|
SSTempSTR = "and UserName in(" + "'" + XiaShuUser.Replace(",", "','") + "'" + ")";
|
|
}
|
|
string sql = "";
|
|
if (!string.IsNullOrEmpty(this.TextBox1.Text))
|
|
{
|
|
sql += "(OrderName Like '%" + this.TextBox1.Text + "%' or GongYingShangName Like '%" + this.TextBox1.Text + "%' or Serils Like '%" + this.TextBox1.Text + "%' or DingDanLeiXing Like '%" + this.TextBox1.Text + "%' or UserName Like '%" + this.TextBox1.Text + "%' or SFJF Like '%" + this.TextBox1.Text + "%')";
|
|
}
|
|
if (!string.IsNullOrEmpty(this.TextBox3.Text))
|
|
{
|
|
if (string.IsNullOrEmpty(sql))
|
|
{
|
|
sql += " (TimeStr >='" + this.TextBox3.Text.Trim() + " 00:00:00' and TimeStr<='" + this.TextBox4.Text.Trim() + " 23:59:59') or (LaiHuoDate >='" + this.TextBox3.Text.Trim() + " 00:00:00' and LaiHuoDate<='" + this.TextBox4.Text.Trim() + " 23:59:59') or (TiXingDate >='" + this.TextBox3.Text.Trim() + " 00:00:00' and TiXingDate<='" + this.TextBox4.Text.Trim() + " 23:59:59') ";
|
|
}
|
|
else
|
|
{
|
|
sql += "and (TimeStr >='" + this.TextBox3.Text.Trim() + " 00:00:00' and TimeStr<='" + this.TextBox4.Text.Trim() + " 23:59:59') or (LaiHuoDate >='" + this.TextBox3.Text.Trim() + " 00:00:00' and LaiHuoDate<='" + this.TextBox4.Text.Trim() + " 23:59:59') or (TiXingDate >='" + this.TextBox3.Text.Trim() + " 00:00:00' and TiXingDate<='" + this.TextBox4.Text.Trim() + " 23:59:59')";
|
|
}
|
|
sql += " " + SSTempSTR + " order by ID desc";
|
|
|
|
}
|
|
GVData.DataSource = MyModel.GetList(sql);
|
|
GVData.DataBind();
|
|
LabPageSum.Text = Convert.ToString(GVData.PageCount);
|
|
LabCurrentPage.Text = Convert.ToString(((int)GVData.PageIndex + 1));
|
|
this.GoPage.Text = LabCurrentPage.Text.ToString();
|
|
}
|
|
#region 分页方法
|
|
protected void ButtonGo_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (GoPage.Text.Trim().ToString() == "")
|
|
{
|
|
Response.Write("<script language='javascript'>alert('页码不可以为空!');</script>");
|
|
}
|
|
else if (GoPage.Text.Trim().ToString() == "0" || Convert.ToInt32(GoPage.Text.Trim().ToString()) > GVData.PageCount)
|
|
{
|
|
Response.Write("<script language='javascript'>alert('页码不是一个有效值!');</script>");
|
|
}
|
|
else if (GoPage.Text.Trim() != "")
|
|
{
|
|
int PageI = Int32.Parse(GoPage.Text.Trim()) - 1;
|
|
if (PageI >= 0 && PageI < (GVData.PageCount))
|
|
{
|
|
GVData.PageIndex = PageI;
|
|
}
|
|
}
|
|
|
|
if (TxtPageSize.Text.Trim().ToString() == "")
|
|
{
|
|
Response.Write("<script language='javascript'>alert('每页显示行数不可以为空!');</script>");
|
|
}
|
|
else if (TxtPageSize.Text.Trim().ToString() == "0")
|
|
{
|
|
Response.Write("<script language='javascript'>alert('每页显示行数不是一个有效值!');</script>");
|
|
}
|
|
else if (TxtPageSize.Text.Trim() != "")
|
|
{
|
|
try
|
|
{
|
|
int MyPageSize = int.Parse(TxtPageSize.Text.ToString().Trim());
|
|
this.GVData.PageSize = MyPageSize;
|
|
}
|
|
catch
|
|
{
|
|
Response.Write("<script language='javascript'>alert('每页显示行数不是一个有效值!');</script>");
|
|
}
|
|
}
|
|
|
|
DataBindToGridview();
|
|
}
|
|
catch
|
|
{
|
|
DataBindToGridview();
|
|
Response.Write("<script language='javascript'>alert('请输入有效数字!');</script>");
|
|
}
|
|
}
|
|
protected void PagerButtonClick(object sender, ImageClickEventArgs e)
|
|
{
|
|
//获得Button的参数值
|
|
string arg = ((ImageButton)sender).CommandName.ToString();
|
|
switch (arg)
|
|
{
|
|
case ("Next"):
|
|
if (this.GVData.PageIndex < (GVData.PageCount - 1))
|
|
GVData.PageIndex++;
|
|
break;
|
|
case ("Pre"):
|
|
if (GVData.PageIndex > 0)
|
|
GVData.PageIndex--;
|
|
break;
|
|
case ("Last"):
|
|
try
|
|
{
|
|
GVData.PageIndex = (GVData.PageCount - 1);
|
|
}
|
|
catch
|
|
{
|
|
GVData.PageIndex = 0;
|
|
}
|
|
|
|
break;
|
|
default:
|
|
//本页值
|
|
GVData.PageIndex = 0;
|
|
break;
|
|
}
|
|
DataBindToGridview();
|
|
}
|
|
#endregion
|
|
protected void GVData_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
ZWL.Common.PublicMethod.GridViewRowDataBound(e);
|
|
}
|
|
protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
DataBindToGridview();
|
|
}
|
|
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
//通过审批
|
|
string IDlist = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible");
|
|
if (ZWL.DBUtility.DbHelperSQL.ExecuteSQL("update ERPBuyOrder set NowState='通过审核' where ID in (" + IDlist + ")") == -1)
|
|
{
|
|
Response.Write("<script>alert('审批选中记录时发生错误!请重新登陆后重试!');</script>");
|
|
}
|
|
else
|
|
{
|
|
DataBindToGridview();
|
|
//写系统日志
|
|
ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
|
|
MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
|
|
MyRiZhi.DoSomething = "用户批准通过采购订单";
|
|
MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
|
|
MyRiZhi.Add();
|
|
}
|
|
}
|
|
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
string IDlist = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible");
|
|
if (ZWL.DBUtility.DbHelperSQL.ExecuteSQL("delete from ERPBuyOrder where ID in (" + IDlist + ")") == -1)
|
|
{
|
|
Response.Write("<script>alert('删除选中记录时发生错误!请重新登陆后重试!');</script>");
|
|
}
|
|
else
|
|
{
|
|
DataBindToGridview();
|
|
//写系统日志
|
|
ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
|
|
MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
|
|
MyRiZhi.DoSomething = "用户删除采购订单信息";
|
|
MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
|
|
MyRiZhi.Add();
|
|
}
|
|
}
|
|
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
string IDList = "0";
|
|
for (int i = 0; i < GVData.Rows.Count; i++)
|
|
{
|
|
Label LabVis = (Label)GVData.Rows[i].FindControl("LabVisible");
|
|
IDList = IDList + "," + LabVis.Text.ToString();
|
|
}
|
|
Hashtable MyTable = new Hashtable();
|
|
MyTable.Add("OrderName", "订单名称");
|
|
MyTable.Add("Serils", "订单编码");
|
|
MyTable.Add("DingDanLeiXing", "订单类别");
|
|
MyTable.Add("GongYingShangName", "供应商");
|
|
MyTable.Add("ChuangJianRen", "创建人");
|
|
MyTable.Add("CreateDate", "创建时间");
|
|
MyTable.Add("NowState", "当前状态");
|
|
|
|
ZWL.Common.DataToExcel.GridViewToExcel(ZWL.DBUtility.DbHelperSQL.GetDataSet("select OrderName,Serils,DingDanLeiXing,GongYingShangName,ChuangJianRen,CreateDate,NowState from ERPBuyOrder where ID in (" + IDList + ") order by ID desc"), MyTable, "Excel报表");
|
|
}
|
|
protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
//拒绝审批
|
|
string IDlist = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible");
|
|
if (ZWL.DBUtility.DbHelperSQL.ExecuteSQL("update ERPBuyOrder set NowState='审核未通过' where ID in (" + IDlist + ")") == -1)
|
|
{
|
|
Response.Write("<script>alert('审批选中记录时发生错误!请重新登陆后重试!');</script>");
|
|
}
|
|
else
|
|
{
|
|
DataBindToGridview();
|
|
//写系统日志
|
|
ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
|
|
MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
|
|
MyRiZhi.DoSomething = "用户审核未通过采购订单信息";
|
|
MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
|
|
MyRiZhi.Add();
|
|
}
|
|
}
|
|
} |