📄 reckoning.aspx.cs
字号:
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;
using System.Data.SqlClient;
public partial class Reckoning : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HeardConfig();
if (!IsPostBack)
{
PersonInfo.Return_SessionPerson();//判断是否登陆,详细操作在类里面
IsPage_Bind();
}
}
#region 页面初始化必需的内容
public void HeardConfig()
{
Header.Title = "销售订单管理系统-账务管理";
HeaderTextInfo.GetHeader(this, null);
}
#endregion
public void IsPage_Bind()
{
string Flag = QueryString.Get_Flag;//根据传入的type来显示标题
string typ = "";
switch (Flag)
{
case ("1"):
Flag = "进货信息";
typ = "商品进货结账";
break;
case ("2"):
Flag = "销售信息";
typ = "商品销售结账";
break;
case ("3"):
Flag = "销售退货";
typ = "销售退货结账";
break;
case ("4"):
Flag = "进货退货";
typ = "进货退货结账";
break;
default:
Flag = "销售信息";
typ = "商品销售结账";
break;
}
Label1.Text = typ;
SqlConnection strcon = new SqlConnection(ConfigurationManager.ConnectionStrings["SellOrder_ConnectionString"].ConnectionString);
strcon.Open();
SqlDataAdapter sda = new SqlDataAdapter("select * from View_Reckoning where type='" + Flag + "' order by id desc", strcon);
DataSet ds = new DataSet();
sda.Fill(ds, "Reckoning");
GridView1.DataSource = ds.Tables["Reckoning"];
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataBind();
}
//单击翻页
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.IsPage_Bind();
}
//单击结账
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
string Url = "Open.aspx?Id=" + id + "&Flag=" + QueryString.Get_Flag + "";
JScript.OpenWebFormSize(Url, 400, 250, 400, 500);//打开指定窗体大小
}
//表格内文字长度固定 格式化文字
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//根据长度格式化
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
//根据状态格式化
string id = e.Row.Cells[3].Text.ToString();
stockClass sc = new stockClass();
int not = sc.not(id);
if (not == 0)
{
e.Row.Cells[3].Text = "<font color=red>已结款</font>";
((Button)(e.Row.Cells[6].Controls[0])).Enabled = false;
}
else
{
e.Row.Cells[3].Text = Convert.ToString(not);
}
SqlConnection strcon = new SqlConnection(ConfigurationManager.ConnectionStrings["SellOrder_ConnectionString"].ConnectionString);
strcon.Open();
SqlCommand scd = new SqlCommand("select count(*) from Reckoning where CommodityId=" + id + "", strcon);
string count = Convert.ToString(Convert.ToInt32(scd.ExecuteScalar()) + 1);
e.Row.Cells[4].Text = count;
//单据编号
string month = Convert.ToDateTime(((HyperLink)(e.Row.Cells[5].Controls[0])).Text).Month.ToString();
if (month.Length < 2)
{
month = "0" + month;
}
string day = Convert.ToDateTime(((HyperLink)(e.Row.Cells[5].Controls[0])).Text).Day.ToString();
if (day.Length < 2)
{
day = "0" + day;
}
string zero = "";
for (int i = 1; i < (10 - id.Length); i++)
{
zero = zero + "0";
}
string uid = zero + id;
((HyperLink)(e.Row.Cells[5].Controls[0])).Text = Convert.ToDateTime(((HyperLink)(e.Row.Cells[5].Controls[0])).Text).Year.ToString() + month + day + uid;
if (e.Row.Cells[0].Text.ToString() == "销售信息" || e.Row.Cells[0].Text.ToString() == "销售退货")
{
((HyperLink)(e.Row.Cells[5].Controls[0])).NavigateUrl = "Show_Sell.aspx?Flag=see&Id=" + id + "";
}
else
{
((HyperLink)(e.Row.Cells[5].Controls[0])).NavigateUrl = "Show_Stock.aspx?Flag=see&Id=" + id + "";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -