CeramicProject/newyt/Common/cgrk_dy.aspx.cs

184 lines
6.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Ajax;
public partial class Common_cgrk : System.Web.UI.Page
{
//创建一个共用的送货单bll层
Maticsoft.BLL.nr_z_cgrk cgrkbll = new Maticsoft.BLL.nr_z_cgrk();
//创建一个共用的生产单模板
Maticsoft.Model.nr_z_cgrk cgrkmodel = new Maticsoft.Model.nr_z_cgrk();
//创建一个共用的订单bll层
Maticsoft.BLL.nr_z_dd ddbll = new Maticsoft.BLL.nr_z_dd();
//创建一个共用的客户bll层
Maticsoft.BLL.nr_z_kehu kehubll = new Maticsoft.BLL.nr_z_kehu();
//创建一个操作记录模板
Maticsoft.Model.nr_sys_rizhi rizhi = new Maticsoft.Model.nr_sys_rizhi();
//创建一个操作记录bll
Maticsoft.BLL.nr_sys_rizhi rizhibll = new Maticsoft.BLL.nr_sys_rizhi();
public string userinfo = "";
protected void Page_Load(object sender, EventArgs e)
{
Utility.RegisterTypeForAjax(typeof(Common_cgrk));
if (!IsPostBack)
{
if (Session["user"] == null)
{
Response.Redirect("../index.aspx");
}
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
string uid = Request["uid"].ToString();
initdata(uid);
}
DataTable dtuserinfo = DBHlper.Execute("select mingcheng,logourl from nr_sysuserinfo").Tables[0];
if (dtuserinfo.Rows.Count > 0)
{
userinfo = dtuserinfo.Rows[0]["mingcheng"].ToString();
img_logo.Src = "../UseFile/" + dtuserinfo.Rows[0]["logourl"].ToString();
}
else
{
img_logo.Visible = false;
}
}
#region
private void initdata(string sid)
{
int shdid=Convert.ToInt32(sid);
DataTable dt = DBHlper.Execute("select * from view_nr_z_cgrk where id=" + shdid).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
gysmc.Text = dt.Rows[0]["gysmc"].ToString();
jsr.Text = dt.Rows[0]["jsr"].ToString();
}
}
#endregion
#region
[Ajax.AjaxMethod]
public string getms(string ids)
{
//修改页面时,首先吧项目明细的表头加载出来
string biao = "<table width='100%' id='ddxm' style='margin-top:-1px; border:1px solid #000000;'> <tr id='0' >"
+ "<td class='head3'><font>采购单号</font></td>"
+ "<td class='head3'><font>物料名称</font></td><td class='head3'><font>库房</font></td><td class='head3'><font>物料种类</font></td><td class='head3'>"
+ "<font>物料规格</font></td><td class='head3'><font>物料单位</font></td>"
+ "<td class='head3'><font>数量</font></td><td class='head3 je'><font>单价</font></td><td class='head3 je'><font>金额</font></td></tr>";
//查询数据视图,获取当前订单下的所有明细
string cmd = "select * from view_nr_z_cgrk where id in(" + ids + ") order by id ";
DataSet ds = DBHlper.Execute(cmd);
DataTable dtgx = new DataTable();
string bz = "";
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
//如果当前订单下存在明细就加载成tr行
foreach (DataRow r in ds.Tables[0].Rows)
{
biao += "<tr>"
+ "<td class='head4'><font>" + r["cgdh"].ToString() + "</font></td>"
+ "<td class='head4'><font>" + r["mingcheng"].ToString() + "</font></td>"
+ "<td class='head4'><font>" + r["kufang"].ToString() + "</font></td>"
+ "<td class='head4'><font>" + r["zhonglei"].ToString() + "</font></td>"
+ "<td class='head4'><font>" + r["guige"].ToString() + "</font></td>"
+ "<td class='head4'><font>" + r["danwei"].ToString() + "</font></td>"
+ "<td class='head4'><font>" + r["sl"].ToString() + "</font> </td>"
+ "<td class='head4 je'><font>¥" + r["dj"].ToString() + "</font></td>"
+ "<td class='head4 je'><font>¥" + r["je"].ToString() + "</font></td></tr>";
if (r["bz"].ToString()!="") {
bz += "" + r["bz"].ToString() + "";
}
}
}
string zje = DBHlper.getfirstcolmn("select sum(je) from view_nr_z_cgrk where id in(" + ids + ") ");
string dxzje = DBHlper.ConvertToChineseNum(zje);
biao += "<tr class='je'><td class='head4'>合计大写</td><td class='head4' colspan='4'>" + dxzje + "</td><td class='head4'>合计</td><td class='head4' colspan='3'>¥" + zje + "</td></tr>";
if (bz != "")
{
biao += "<tr><td class='head4'>备注</td><td class='head4' colspan='8'>" + bz + "</td></tr>";
}
else {
biao += "<tr><td class='head4'>备注</td><td class='head4' colspan='8'></td></tr>";
}
biao += "</table>";
return biao;
}
#endregion
#region
[Ajax.AjaxMethod]
public string getls()
{
string ls = "";
DataTable dt = DBHlper.Execute("select ls from nr_z_ls where mokuan='送货单'").Tables[0];
if (dt.Rows.Count == 0)
{
DBHlper.excutecmd("insert into nr_z_ls(mokuan,ls) values('送货单','')");
}
else
{
ls = dt.Rows[0]["ls"].ToString();
}
return ls;
}
#endregion
#region
[Ajax.AjaxMethod]
public void savels(string ls)
{
DBHlper.excutecmd("update nr_z_ls set ls='" + ls + "' where mokuan='送货单'");
}
#endregion
#region
[Ajax.AjaxMethod]
public string gettk()
{
string ls = "";
DataTable dt = DBHlper.Execute("select ls from nr_z_ls where mokuan='送货条款'").Tables[0];
ls = dt.Rows[0]["ls"].ToString();
return ls;
}
#endregion
#region
[Ajax.AjaxMethod]
public void savetk(string ls)
{
DBHlper.excutecmd("update nr_z_ls set ls='" + ls + "' where mokuan='送货条款'");
}
#endregion
}