ERP产品采购申请管理(三十八)

BLL层代码:

 public   class BioPurchaseBLL
{
/// <summary>
/// 购进申请添加
/// </summary>
/// <param name="appinfo">申请对象</param>
/// <returns>编号</returns>
public int ProPurchaseAdd(BioPurchaseAppInfo appinfo)
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@PurchaseID",SqlDbType.Int),
new SqlParameter("@Subject",appinfo.Subject),
new SqlParameter("@DepartMentID",appinfo.DepartMentID),
new SqlParameter("@AppUserId",appinfo.AppUserId),
new SqlParameter("@RealUserID",appinfo.RealUserID),
new SqlParameter("@OrderCom",appinfo.OrderCom),
new SqlParameter("@SendComID",appinfo.SendComID),
new SqlParameter("@OrderTime",appinfo.OrderTime),
new SqlParameter("@sendType",appinfo.sendType),
new SqlParameter("@WholeType",appinfo.WholeType)
};
//输出参数
pars[0].Direction = ParameterDirection.Output; int count= DataBaseHelper.ExcuteSqlReturnInt("BioPurchaseAppInfo_ADD", CommandType.StoredProcedure, pars);
if (count != 0)
{
return int.Parse(pars[0].Value.ToString());
}
else
{
return 0;
}
} /// <summary>
/// 添加购进产品信息
/// </summary>
/// <param name="pro">购进产品对象</param>
/// <returns>int</returns>
public int BioPurchaseProADD(BioPurchasePro pro)
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@PurchaseID",pro.PurchaseID),
new SqlParameter("@ProID",pro.ProID),
new SqlParameter("@ProCount",pro.ProCount),
new SqlParameter("@ProPrice",pro.ProPrice),
new SqlParameter("@InvoicePrice",pro.InvoicePrice)
};
return DataBaseHelper.ExcuteSqlReturnInt("BioPurchasePro_ADD", CommandType.StoredProcedure, pars); }
}

前端的代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProPurchaseNew.aspx.cs" Inherits="BioErpWeb.WholeSaleSystem.ProPurchase.ProPurchaseNew" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" /> <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script> <script src="../../Scripts/validateExtender.js" type="text/javascript"></script>
<script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.metadata.js" type="text/javascript"></script> <link href="../../Styles/InputStyle1.css" rel="stylesheet" type="text/css" />
<script src="../../JS/CheckDepartMent.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.7.custom.min.js" type="text/javascript"></script>
<link href="../../Scripts/jquery-ui-1.7.custom.css" rel="stylesheet" type="text/css" /> <script src="../../JS/CheckUserName.js" type="text/javascript"></script>
<script src="../../JS/CustomerName.js" type="text/javascript"></script>
<script src="../../JS/ProNameChoose.js" type="text/javascript"></script> <script type="text/javascript">
$(document).ready(function () {
$("#form1").validate();
}); function addrow() {
var tr = '<tr><td><input type="text" name="proName" class="required" style=" width:294px"/>
<input type="hidden" name="proID" /><input value="选择" type="button" onclick="showProName()" class="btnchoose"/>
</td><td><input type="text" name="proCount" class="{required:true,min:1,digits:true}" style=" width:150px"/></td>
<td><input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" width:150px"/></td>
<td><input type="button" value="添加行" onclick="addrow()" class="btnchoose"/>
<input type="button" value="删除行" onclick="deleterow()" class="btnchoose"/></td></tr>';
var obj = window.event.srcElement;
var parenttr = obj.parentNode.parentNode;
$(parenttr).after(tr);
} function deleterow() {
var obj = window.event.srcElement;
var parenttr = obj.parentNode.parentNode;
$(parenttr).remove(); }
</script> </head>
<body>
<form id="form1" runat="server"> <div>
<table class="maintable Inupttable" style=" width:900px;">
<tr>
<td colspan="8" class="titlebar">商品采购申请单</td>
</tr>
<tr>
<td>申请部门</td>
<td>
<asp:DropDownList ID="ddlDepartMent" runat="server">
</asp:DropDownList>
</td><td>
制表人</td>
<td class="style1">
<asp:Label ID="lbApplayUser" runat="server" ></asp:Label>
</td>
<td>经手人</td><td>
<asp:TextBox ID="txtRealUserID" CssClass="{required:true,digits:true, min:1}"
runat="server" Width="78px"></asp:TextBox>
<input id="btnUser" type="button" value="选择" class="btnchoose" onclick="showDialog3()" /></td>
<td>制表时间</td><td>
<asp:Label ID="lbTime" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>发货(订货)单位</td>
<td>
<asp:TextBox ID="txtSendCom" runat="server" Width="102px"></asp:TextBox>
<input id="btnUser1" type="button" value="选择" class="btnchoose"
onclick="showCustomerDialog3()" /></td><td>
入库单位</td>
<td class="style1">
<asp:DropDownList ID="ddlOrderCom" runat="server">
<asp:ListItem>上海某某公司</asp:ListItem>
<asp:ListItem>成都某某公司</asp:ListItem>
<asp:ListItem>北京某某公司</asp:ListItem>
<asp:ListItem>雅安某某公司</asp:ListItem>
</asp:DropDownList>
</td>
<td>采购方式</td><td>
<asp:DropDownList ID="ddlSaleType" runat="server">
<asp:ListItem>经销</asp:ListItem>
<asp:ListItem>代销</asp:ListItem>
</asp:DropDownList>
</td>
<td>入库方式</td><td>
<asp:DropDownList ID="ddlTypes" runat="server">
<asp:ListItem>零星采购</asp:ListItem>
<asp:ListItem>采购入库</asp:ListItem>
</asp:DropDownList>
</td>
</tr> <tr>
<td colspan="8" style="border:none;">
<div>
<table style="width:95%; border:solid 1px; border-collapse:collapse; line-height:25px;">
<tr><td>产品名称及规格</td><td>数量</td><td>单价</td>
<td>操作</td></tr>
<tr><td><input type="text" name="proName" class="required" style=" width:294px"/>
<input type="hidden" name="proID" /><input value="选择" type="button" onclick="showProName()"
class="btnchoose"/></td><td><input type="text" name="proCount" class="{required:true,min:1,digits:true}"
style=" width:150px"/></td><td><input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" width:150px"/></td>
<td class="style1"><input type="button" value="添加一行" onclick="addrow()" class="btnchoose"/> </td></tr>
</table> </div>
</td>
</tr>
<tr>
<td>备注:</td>
<td colspan="5">
<asp:TextBox ID="txtRemark" runat="server" Width="523px"></asp:TextBox>
</td> <td>审批核人</td>
<td>
<asp:TextBox ID="txtNetUserId" CssClass="{required:true,digits:true, min:1}"
runat="server" Width="70px"></asp:TextBox>
<input id="btnUser0" type="button" value="选择" class="btnchoose"
onclick="showDialog3()" /></td>
</tr>
<tr>
<td colspan="8" class="bottomtd">
<asp:HiddenField ID="hf_applayUserid" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="保存"
onclick="btnSubmit_Click" /> </td>
</tr> </table> </div>
</form>
</body>
</html>

产品选择功能:(弹出窗体选择,返回产品和编号)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProList.aspx.cs" Inherits="BioErpWeb.PersonList.ProList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript">
function search() {
if (document.getElementById("txtSearchName").value == "") {
alert("请输入产品名");
return;
}
document.getElementById("PersonIframeList")
.src = "ProListSelect.aspx?ProName=" + encodeURIComponent(document.getElementById("txtSearchName").value); } function choose() {
var index = PersonIframeList.document.getElementById("sltUserList").selectedIndex; var text = PersonIframeList.document.getElementById("sltUserList").options[index].innerText; var value = PersonIframeList.document.getElementById("sltUserList").value;
window.returnValue = value+"-"+text;
window.close();
}
</script>
<style type="text/css">
.style1
{
width: 196px;
}
#PersonIframeList
{
width: 174px;
}
.style2
{
width: 194px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style=" width:324px; ">
<tr>
<td class="style1">产品姓名
</td>
<td class="style2">
<input id="txtSearchName" name="txtSearchName" type="text" size="10" maxlength="10"/>
<input type="button" value="查询" onclick="search()" />
</td>
</tr>
<tr>
<td class="style1">
<iframe id="PersonIframeList" frameborder="0" src="ProListSelect.aspx"
height="310px" > </iframe>
</td>
<td style=" vertical-align:bottom; padding-bottom:20px;" class="style2">
<span id="chooseProName"></span>
<input type="button" value="选择" onclick="choose()"/>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

取出产品的名称:

function showProName() {
var re = showModalDialog("../../PersonList/ProList.aspx", "", "dialogWidth=350px;dialogHeight=400px");
var valuetext = re.split("-");
var obj = window.event.srcElement;
var td = obj.parentNode;
var txts = td.getElementsByTagName('input');
if (re == null || re == "") { if (txts[0].value == "" || txts[0].value == null) {
txts[0].value = "请选择"; }
}
else {
txts[0].value = valuetext[1];
txts[1].value = valuetext[0];
}
}

选择的后台代码:

 public string GetUserList
{
get {
string strHtml = "";
if (Request.QueryString["ProName"] == null)
{
DataSet ds = SqlComm.GetDataByCondition("BiotbProduct", "top 10 ProID,ProName", " 1=1 order by ProID");
foreach (DataRow dr in ds.Tables[0].Rows)
{
strHtml += "<option value='" + dr["ProID"] + "'>" + dr["ProName"] + "</option>";
} }
else
{
DataSet ds = SqlComm.GetDataByCondition("BiotbProduct", "top 10 ProID,ProName",
" ProName like '" + Request.QueryString["ProName"].ToString() + "%' order by ProID");
foreach (DataRow dr in ds.Tables[0].Rows)
{
strHtml += "<option value='" + dr["ProID"] + "'>" + dr["ProName"] + "</option>";
}
} return strHtml;
}
}

定义枚举类型:

 public  enum TaskNavigateEmun
{
/// <summary>
/// 合同管理 1
/// </summary>
CRMContract=1,
/// <summary>
/// 产品购进 2
/// </summary>
ProPurchase=2,
/// <summary>
/// 产品发货3
/// </summary>
ProSend=3,
/// <summary>
/// 产品退货4
/// </summary>
ProBackSend=4
}

添加的后台页面:

  protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.lbApplayUser.Text = Web.UserLogin.user.UserName;
this.lbApplayUser.ToolTip = Web.UserLogin.user.UserId.ToString();
this.hf_applayUserid.Value = Web.UserLogin.user.UserId.ToString();
DepartMentBand();
this.lbTime.Text = DateTime.Now.ToString();
} }
/// <summary>
/// 绑定部门信息
/// </summary>
private void DepartMentBand()
{
ddlDepartMent.DataSource = SqlComm.getDepartMent();
ddlDepartMent.DataTextField = "DepartmentName";
ddlDepartMent.DataValueField = "DepartmentId";
ddlDepartMent.DataBind();
ddlDepartMent.Items.Add(new ListItem("--请选择部门--", "0"));
ddlDepartMent.SelectedValue = "0";
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
int taskid=0; BioPurchaseAppInfo appinfo = new BioPurchaseAppInfo();
BioPurchaseBLL puchasebll = new BioPurchaseBLL(); string proname = Request["proName"].ToString();
string[] pronames = proname.Split(',');
appinfo.Subject = pronames[0]+ "-采购申请单";
appinfo.DepartMentID =int.Parse( ddlDepartMent.SelectedValue.ToString());
appinfo.AppUserId = int.Parse(Session["Userid"].ToString());
appinfo.RealUserID = int.Parse(txtRealUserID.Text.Trim());
appinfo.OrderCom = this.ddlOrderCom.SelectedItem.Text;
appinfo.SendComID =int.Parse( this.txtSendCom.Text.Trim());
appinfo.OrderTime = Convert.ToDateTime(this.lbTime.Text);
appinfo.sendType=this.ddlTypes.Text;
appinfo.WholeType = this.ddlSaleType.Text;
taskid= puchasebll.ProPurchaseAdd(appinfo);
bool proadd = false;
if (taskid != 0)
{
string proid = Request["proID"].ToString();
string procount = Request["proCount"].ToString();
string proprice = Request["proPrice"].ToString();
string[] proids = proid.Split(',');
string[] procounts = procount.Split(',');
string[] proprices = proprice.Split(',');
for (int i = 0; i < proids.Length; i++)
{
BioPurchasePro pro=new BioPurchasePro();
pro.PurchaseID=taskid;
pro.ProID=int.Parse(proids[i]);
pro.ProCount=int.Parse(procounts[i]);
pro.ProPrice=decimal.Parse(proprices[i]);
pro.InvoicePrice=pro.ProCount* pro.ProPrice;
puchasebll.BioPurchaseProADD(pro); }
proadd = true; }
if (taskid != 0 && proadd==true)
{
TaskListRecord record = new TaskListRecord();
record.Accepter = int.Parse(this.txtNetUserId.Text.Trim());
record.AuditingSate = 0;
record.DepartMentId = int.Parse(this.ddlDepartMent.SelectedValue.ToString());
record.FirstAccepter = int.Parse(this.txtNetUserId.Text.Trim());
record.FirstSumitTime = Convert.ToDateTime(this.lbTime.Text);
record.FirstTransmitter = int.Parse(Session["Userid"].ToString());
record.Mind = this.txtRemark.Text;
record.Pass = 1;
record.Subject = pronames[0] + "-采购申请单";
record.SumitTime = DateTime.Now;
record.TaskID = taskid;
record.TaskTableID =(int)TaskNavigateEmun.ProPurchase;
record.Transmitter = int.Parse(Session["Userid"].ToString());
SqlComm.TaskListRecordAdd(record);
} Response.Redirect("~/Web/Desk.aspx");
}

js的公用方法封装:

function showobj(objID) {
// var obj = document.getElementById(objID);
// obj.style.display = "";
$("#" + objID).show();
}

查询购进批号表中审核的产品数量:

CREATE PROC [dbo].[getauditingProBatchCountByPurchaseID]
(
@PurchaseID INT
)
AS
BEGIN
SELECT COUNT(isauditing) FROM BioPuchaseProBatch WHERE purchaseProID
IN (SELECT PurchaseProID FROM dbo.BioPurchasePro WHERE
PurchaseID=@PurchaseID) AND isauditing=1
END

BLL层的代码:

 /// <summary>
/// 根据产品购进单编号获取对于产品批号的数量(已经审核的数量)
/// </summary>
/// <param name="PurchaseID">购进单编号</param>
/// <returns></returns>
public int getauditingProBatchCountByPurchaseID(string PurchaseID)
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@PurchaseID",int.Parse(PurchaseID))
};
object o = DataBaseHelper.SelectSQLReturnObject("getauditingProBatchCountByPurchaseID", CommandType.StoredProcedure, pars);
if (o != null)
{
return int.Parse(o.ToString());
}
else
{
return 0;
}
}

添加产品批次到产品库存表:

-- Description:	添加产品批次到产品库存表
-- =============================================
CREATE PROCEDURE [dbo].[BioProStockAdd]
@ProID INT,
@BathNum NVARCHAR(50),
@ProCout INT,
@StockPrice MONEY,
@MakeDate DATETIME,
@ExpirateDate DATETIME,
@StockID INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT BioProStock
(
ProID,
BathNum,
ProCout,
StockPrice,
MakeDate,
ExpirateDate,
StockID
)
VALUES
(
@ProID,
@BathNum,
@ProCout,
@StockPrice ,
@MakeDate,
@ExpirateDate,
@StockID
) END

BLL层代码:

     /// <summary>
/// 给产品库存表添加一条记录
/// </summary>
/// <param name="prostock"></param>
/// <returns></returns>
public int BioProStockAdd(BioProStock prostock)
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@ProID",prostock.ProID),
new SqlParameter("@BathNum",prostock.BathNum),
new SqlParameter("@ProCout",prostock.ProCout),
new SqlParameter("@StockPrice",prostock.StockPrice),
new SqlParameter("@MakeDate",prostock.MakeDate),
new SqlParameter("@ExpirateDate",prostock.ExpirateDate),
new SqlParameter("@StockID",prostock.StockID)
};
return DataBaseHelper.ExcuteSqlReturnInt("BioProStockAdd", CommandType.StoredProcedure, pars);
}
}

查询购进批号表中审核的产品数量:

--查询购进批号表中审核的产品数量
CREATE PROC [dbo].[getauditingProBatchCountByPurchaseID]
(
@PurchaseID INT
)
AS
BEGIN
SELECT COUNT(isauditing) FROM BioPuchaseProBatch WHERE purchaseProID
IN (SELECT PurchaseProID FROM dbo.BioPurchasePro WHERE
PurchaseID=@PurchaseID) AND isauditing=1
END

修改的前端代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProPurchaseEdit.aspx.cs"
Inherits="BioErpWeb.WholeSaleSystem.ProPurchase.ProPurchaseEdit" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/validateExtender.js" type="text/javascript"></script>
<script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.metadata.js" type="text/javascript"></script>
<link href="../../Styles/InputStyle1.css" rel="stylesheet" type="text/css" />
<script src="../../JS/CheckDepartMent.js" type="text/javascript"></script>
<link href="../../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/cld.js" type="text/javascript"></script>
<script src="../../JS/CheckUserName.js" type="text/javascript"></script>
<script src="../../JS/CustomerName.js" type="text/javascript"></script>
<script src="../../JS/ProNameChoose.js" type="text/javascript"></script>
<script src="../../Scripts/Comm.js" type="text/javascript"></script>
<script type="text/javascript">
var tri = 0;
$(document).ready(function () {
$("#form1").validate();
$("#addrow").click(function () {
tri++;
var tr = '<tr id="tr' + tri + '"><td><input type="text" name="proName" class="required" style=" width:294px"/>
<input type="hidden" name="proID" /><input value="选择" type="button" onclick="showProName()" class="btnchoose"/></td>
<td><input type="text" name="proCount" class="{required:true,min:1,digits:true}" style=" width:150px"/></td>
<td><input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" width:150px"/></td>
<td> <input type="button" value="添加批号" name="btnaddBacths" class="btnchoose" /></td></tr>';
$("#caption").before(tr);
sethidden();
});
$("#deleteRow").click(function () {
var name = '#tr' + tri;
$(name).remove();
if (tri > 0) {
tri--;
} else {
tri = 0;
}
}); });
function addrows(count) { for (var i = 0; i < count; i++) {
tri++;
var tr = '<tr id="tr' + tri + '">
<td><input type="text" name="proName" class="required" style=" width:294px"/>
<input type="hidden" name="proID" /><input value="选择" type="button" onclick="showProName()" name="chpro" class="btnchoose"/></td>
<td><input type="text" name="proCount" class="{required:true,min:1,digits:true}" style=" width:150px"/></td>
<td><input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style=" width:150px"/></td>
<td> <input type="hidden" name="purchaseProID"/><input type="button" value="添加批号" name="btnaddBacths" class="btnchoose" onclick="setbatch()" /></td>
</tr>';
var obj = $("#troption");
$(obj).after(tr); }
} //产品信息赋值
function setValues(proName, proID, proCount, proPrice, purchaseProID) { var proNames = proName.split(',');
var proIDs = proID.split(',');
var proCounts = proCount.split(',');
var proPrices = proPrice.split(',');
var purchaseProIDs=purchaseProID.split(',');
var txtProName = document.getElementsByName("proName");
var txtProID = document.getElementsByName("proID");
var txtProCount = document.getElementsByName("proCount");
var txtproPrice = document.getElementsByName("proPrice");
var txtpurchaseProID = document.getElementsByName("purchaseProID");
for (var i = 0; i <(proIDs.length-1); i++) {
txtProName[i].value = proNames[i];
txtProID[i].value = proIDs[i];
txtProCount[i].value = proCounts[i];
txtproPrice[i].value = proPrices[i];
txtpurchaseProID[i].value = purchaseProIDs[i]; } } function deleterow() {
var obj = window.event.srcElement;
var parenttr = obj.parentNode.parentNode;
$(parenttr).remove(); } function sethidden() { var name = '<%=this.hiddenName()%>';
if (name != null) {
var names = name.split("/"); for (var i = 0; i < names.length; i++) {
$(document).find("input[name='" + names[i] + "']").each(function () {
$(this).css("display", "none");
})
}
} } function setbatch() {
var procount = 0;
var boxnum = 1;
$("#divprobatch").css("display", "block");
var obj = window.event.srcElement;
var tr = obj.parentNode.parentNode;
var inputs = tr.getElementsByTagName("input"); $("#divprobatch").find("input[name='proIds']").each(function () {
if (inputs[1].value == $(this).val()) {
boxnum++;
procount += parseInt($(this).parent().parent().find("input[name='txtProCount0']").val());
if (procount > parseInt(inputs[3].value)) { $(this).parent().parent().find("input[name='txtProCount0']").attr("value", "0");
alert("产品总数已经达到,不能为此产品添加批号");
event.stopPropagation(); }
}
}) //2011年11月29日22:28:00
//新添加一个控件<input type="hidden" name="PurchaseProID2"/>
var trbatch = '<tr> <td id="td2"><input id="txtProName0" value="' + inputs[0].value + '" readonly="readonly" name="txtProName0"
style="width: 294px" type="text" class="input" size="50" /><input type="hidden" name="proIds" value="' + inputs[1].value + '"/> </td>';
trbatch += '<td><input id="txtProCount0" name="txtProCount0" class="{required:true,min:1,digits:true;}" type="text" size="5" /></td>
<td><input id="txtProBatch0" name="txtProBatch0" type="text" size="11" /> </td>';
trbatch += '<td><input id="txtProBoxNum0" name="txtProBoxNum0" value="' + boxnum + '" readonly="readonly" type="text" size="11" /> </td>';
trbatch += '<td><input id="txtMarkDate0" name="txtMarkDate0" onfocus="setday(this)" onclick="setday(this)" size="11"
class="{required:true,dateISO:true}" type="text" readonly="readonly" /></td>';
trbatch += '<td><input id="txtExPirationDate0" onfocus="setday(this)" onclick="setday(this)" name="txtExPirationDate0"
class="{required:true,dateISO:true}" size="11" type="text" readonly="readonly" />';
trbatch += '</td><td><input type="hidden" value="'+inputs[5].value+'" name="PurchaseProID2"/>
<input type="button" class="btn2" value="删除" onclick="deleterow()"/><input id="Hidden2" name="proID0" type="hidden" />
<input id="Hidden3" name="tb1RowIndex" type="hidden" />';
trbatch += '</td></tr>'; $("#probatchtr").after(trbatch);
} //根据后台传过来的产品批次个数,添加相应行数
function setaddbatchs(count) {
var trbatch = '<tr> <td id="td2"><input id="txtProName0" value="" readonly="readonly" name="txtProName0"
style="width: 294px" type="text" class="input" size="50" /><input type="hidden" name="proIds" value=""/> </td>';
trbatch += '<td><input id="txtProCount0" name="txtProCount0" class="{required:true,min:1,digits:true}" type="text" size="5" /></td>
<td><input id="txtProBatch0" name="txtProBatch0" type="text" size="11" /> </td>';
trbatch += '<td><input id="txtProBoxNum0" name="txtProBoxNum0" value="" readonly="readonly" type="text" size="11" /> </td>';
trbatch += '<td><input id="txtMarkDate0" name="txtMarkDate0" onfocus="setday(this)" onclick="setday(this)"
size="11" class="{required:true,dateISO:true}" type="text" readonly="readonly" /></td>';
trbatch += '<td><input id="txtExPirationDate0" onfocus="setday(this)" onclick="setday(this)"
name="txtExPirationDate0" class="{required:true,dateISO:true}" size="11" type="text" readonly="readonly" />';
trbatch += '</td><td><input type="hidden" value="" name="PurchaseProID2"/><input type="button" class="btn2" value="删除" onclick="deleterow()"/>
<input id="Hidden2" name="proID0" type="hidden" /><input id="Hidden3" name="tb1RowIndex" type="hidden" />';
trbatch += '</td></tr>';
for (var i = 0; i < count; i++) {
$("#probatchtr").after(trbatch);
}
} function setbatchsvalues(proname, proId, txtProCount, txtProBatch, txtProBoxNum, txtMarkDate, txtExPirationDate, PurchaseProID) { var pronames = proname.split(",");
var proIds = proId.split(",");
var ProCouns = txtProCount.split(",");
var ProBatchs = txtProBatch.split(",");
var ProBoxNums = txtProBoxNum.split(",");
var MarkDates = txtMarkDate.split(",");
var ExPirationDates = txtExPirationDate.split(",");
var PurchaseProIDs = PurchaseProID.split(","); var txtProName0s = document.getElementsByName("txtProName0");
var txtproIds = document.getElementsByName("proIds")
var txtProCount0 = document.getElementsByName("txtProCount0");
var txtProBatch0 = document.getElementsByName("txtProBatch0");
var txtProBoxNum0 = document.getElementsByName("txtProBoxNum0");
var txtMarkDate0 = document.getElementsByName("txtMarkDate0");
var txtExPirationDate0 = document.getElementsByName("txtExPirationDate0");
var PurchaseProID2 = document.getElementsByName("PurchaseProID2"); for (var i = 0; i < txtProName0s.length; i++) {
txtProName0s[i].value = pronames[i];
txtproIds[i].value = proIds[i];
txtProCount0[i].value = ProCouns[i];
txtProBatch0[i].value = ProBatchs[i];
txtProBoxNum0[i].value = ProBoxNums[i];
txtMarkDate0[i].value = MarkDates[i];
txtExPirationDate0[i].value = ExPirationDates[i];
PurchaseProID2[i].value = PurchaseProIDs[i]; } } // function showBatchsdiv() {
// $("#divprobatch").show();
// }
// </script>
<style type="text/css">
#pricetable
{
border: none;
width: 99%;
}
#pricetable td
{
border: none;
}
#divprobatch
{
width: 99%;
border: none;
}
#divprobatch table
{
width: 99%;
border: none;
}
#divprobatch table td
{
border: none;
padding-right: 2px;
}
</style>
</head>
<body onload="sethidden()">
<form id="form1" runat="server">
<div style=" width:99%; height:750px; overflow:scroll;">
<table class="maintable Inupttable" style="width: 900px;">
<tr>
<td colspan="8" class="titlebar">
商品采购审核单
</td>
</tr>
<tr>
<td>
申请部门
</td>
<td>
<asp:DropDownList ID="ddlDepartMent" runat="server">
</asp:DropDownList>
</td>
<td>
制表人
</td>
<td class="style1">
<asp:Label ID="lbApplayUser" runat="server"></asp:Label>
</td>
<td>
经手人
</td>
<td>
<asp:TextBox ID="txtRealUserID" CssClass="{required:true,digits:true, min:1}" runat="server"
Width="78px"></asp:TextBox>
<input id="btnUser" type="button" value="选择" class="btnchoose" onclick="showDialog3()" /><asp:Label
ID="lbOldRealName" runat="server" Text="Label"></asp:Label>
</td>
<td>
制表时间
</td>
<td>
<asp:Label ID="lbTime" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
发货(订货)单位
</td>
<td>
<asp:TextBox ID="txtSendCom" runat="server" Width="72px" CssClass="{required:true,digits:true, min:1}"></asp:TextBox>
<input id="btnUser1" type="button" value="选择" class="btnchoose" onclick="showCustomerDialog3()" /><asp:Label
ID="lbOldSenComName" runat="server" Text="Label"></asp:Label>
</td>
<td>
入库单位
</td>
<td class="style1">
<asp:DropDownList ID="ddlOrderCom" runat="server">
<asp:ListItem>上海某某公司</asp:ListItem>
<asp:ListItem>成都某某公司</asp:ListItem>
<asp:ListItem>北京某某公司</asp:ListItem>
<asp:ListItem>雅安某某公司</asp:ListItem>
</asp:DropDownList>
</td>
<td>
采购方式
</td>
<td>
<asp:DropDownList ID="ddlSaleType" runat="server">
<asp:ListItem>经销</asp:ListItem>
<asp:ListItem>代销</asp:ListItem>
</asp:DropDownList>
</td>
<td>
入库方式
</td>
<td>
<asp:DropDownList ID="ddlTypes" runat="server">
<asp:ListItem>零星采购</asp:ListItem>
<asp:ListItem>采购入库</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="8" style="border: none;" class="style2">
<div>
<table id="tableprolist" style="width: 95%; border: solid 1px; border-collapse: collapse;
line-height: 25px;">
<tr>
<td>
产品名称及规格
</td>
<td>
数量
</td>
<td>
单价
</td>
<td>
操作
</td>
</tr>
<tr id="troption">
<td>
<input type="text" name="proName" class="required" style="width: 294px" /><input
type="hidden" name="proID" /><input value="选择" type="button" name="chpro" onclick="showProName()"
class="btnchoose" />
</td>
<td>
<input type="text" name="proCount" class="{required:true,min:1,digits:true}" style="width: 150px" />
</td>
<td>
<input type="text" name="proPrice" class="{required:true,min:0.1,number:true}" style="width: 150px" />
</td>
<td class="style1">
<!--2011年11月29日22:37:47 添加 <input type="hidden" name="purchaseProID"/>-->
<input type="hidden" name="purchaseProID"/>
<input type="button" value="添加批号" onclick="setbatch()" name="btnaddBacths" class="btnchoose" />
</td>
</tr>
<tr id="caption">
<td colspan="4" style="text-align: right;">
<input type="button" value="添加一行" id="addrow" name="addrow" class="btnchoose" />
<input type="button" value="删除行" id="deleteRow" name="deleteRow" class="btnchoose" />
</td>
</tr>
<tr>
<td colspan="4">
<div id="divprobatch" style="display: none;">
<table id="tb2" align="left" cellpadding="0" border="0" cellspacing="0" class="style2">
<tr id="probatchtr">
<td style="width: 340px;">
订货产品名称及规格(只读)
</td>
<td style="width: 70px;">
数量
</td>
<td style="width: 95px;">
批号
</td>
<td style="width: 95px;">
货号(只读)
</td>
<td style="width: 150px;">
生产日期
</td>
<td style="width: 150px;">
有效期
</td>
<td style="width: 65px;">
 
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="4">
<table id="pricetable">
<tr>
<td>
<asp:Label ID="lbTotal" runat="server" Text="产品总额"></asp:Label>
<asp:Label ID="lbTotalInvoicePrice" runat="server" Text=""></asp:Label>
</td>
<td>
<asp:Label ID="lbisPay" Visible="false" runat="server" Text="是否付款:"></asp:Label><asp:CheckBox
ID="isPay" runat="server" Visible="false" />
</td>
<td>
<asp:Label ID="lbBill" runat="server" Text="账单编号:" Visible="false"></asp:Label>
<asp:TextBox ID="txtBillNo" runat="server" Visible="false"></asp:TextBox>
</td>
<td>
<asp:Label ID="lbPayuser" runat="server" Text=" 付款人:" Visible="false"></asp:Label>
<asp:TextBox ID="txtBillUser" runat="server" Visible="false"></asp:TextBox>
<input id="btnbilluserchoose" type="button" visible="false" runat="server" value="选择"
class="btnchoose" onclick="showDialog3()" /><asp:Label ID="lbBillUserName" runat="server"
Text="Label"></asp:Label>
 
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div id="proAuditing" style=" display:none;">
产品质量审核:<asp:CheckBox ID="cb_Auditing" Text="质量审核合格" runat="server" />
</div>
<div id="stockAuditing" style=" display:none;">
<span>仓库审核:<asp:CheckBox ID="cb_Stock" Text="仓库审核合格" runat="server" /></span>
<span>选择仓库:<asp:DropDownList ID="ddlStock" runat="server">
</asp:DropDownList>
</span>
</div>
</td>
</tr>
<tr>
<td>
备注
</td>
<td colspan="5">
<asp:TextBox ID="txtRemark" runat="server" Width="523px"></asp:TextBox>
</td>
<td>
审批核人
</td>
<td>
<asp:TextBox ID="txtNetUserId" CssClass="{required:true,digits:true, min:1}" runat="server"
Width="70px"></asp:TextBox>
<input id="btnUser0" type="button" value="选择" name="btnuser0" class="btnchoose" onclick="showDialog3()" />
</td>
</tr>
<tr>
<td>
历史审批意见
</td>
<td colspan="7">
<asp:Label ID="lbRemarks" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td colspan="8" class="bottomtd">
<asp:HiddenField ID="hf_applayUserid" runat="server" />
<asp:HiddenField ID="hf_subject" runat="server" />
<asp:HiddenField ID="hf_FirstAccepter" runat="server" />
<asp:HiddenField ID="hf_FirstTransmitter" runat="server" />
<asp:Button ID="btbRun" runat="server" Text="执行" Visible="false" UseSubmitBehavior="false" CssClass="btnchoose"
onclick="btbRun_Click"/>
<asp:Button ID="btnreject" Visible="false" name="btnreject" runat="server" Text="拒绝审核" UseSubmitBehavior="false"
OnClick="Button1_Click" />
 <asp:Button ID="btnSubmit" runat="server" Text="提交审核" OnClick="btnSubmit_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

根据产品批号获取此产品名称:

-- Description:	根据产品批号编号获取此产品名称
-- =============================================
CREATE FUNCTION [dbo].[FN_GetProNameByProBatchID]
(
@ProBatchID INT
)
RETURNS NVARCHAR(100)
AS
BEGIN
-- Declare the return variable here
DECLARE @proName NVARCHAR(100)
DECLARE @purchaseProID INT
DECLARE @ProID INT
SELECT @purchaseProID= purchaseProID FROM dbo.BioPuchaseProBatch
WHERE ProBatchID=@ProBatchID SELECT @ProID=ProID FROM BioPurchasePro WHERE PurchaseProID=@purchaseProID
SELECT @proName=ProName FROM dbo.BiotbProduct
WHERE ProID=@ProID
RETURN @proName
END

根据购进单编号获取相应批次详细信息:

 public DataTable getProBatchDetailByPurchaseID(string PurchaseID)
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@PurchaseID",int.Parse(PurchaseID))
}; return DataBaseHelper.SelectSQLReturnTable("getProBatchDetailByPurchaseID", CommandType.StoredProcedure, pars);
}

存储过程的封装:

CREATE PROC [dbo].[getProBatchDetailByPurchaseID]
(
@PurchaseID INT
)
AS
SELECT
ProBatchID,
proName=dbo.FN_GetProNameByProBatchID(ProBatchID),
proID=[dbo].FN_GetProIDByProBatchID(ProBatchID),
purchaseProID,
batchNum,
boxNum,
proCount,
realityProCount,
stockDate,
expirationDate,
makeDate,
isDeleteSate,
isAuditing,
isprinted
FROM
BioPuchaseProBatch WHERE purchaseProID
IN (
SELECT PurchaseProID FROM dbo.BioPurchasePro
WHERE dbo.BioPurchasePro.PurchaseID=@PurchaseID
)

根据产品批号 获取此产品编号:

CREATE FUNCTION [dbo].[FN_GetProIDByProBatchID]
(
-- Add the parameters for the function here
@ProBatchID INT
)
RETURNS NVARCHAR(100)
AS
BEGIN
DECLARE @purchaseProID INT
DECLARE @ProID INT
SELECT @purchaseProID= purchaseProID FROM dbo.BioPuchaseProBatch
WHERE ProBatchID=@ProBatchID
SELECT @ProID=ProID FROM BioPurchasePro WHERE PurchaseProID=@purchaseProID RETURN @ProID
END

添加产品批号的BLL:

  /// <summary>
/// 添加产品批号
/// </summary>
/// <param name="batch"></param>
/// <returns></returns>
public int BioPuchaseProBatchAdd(BioPuchaseProBatch batch)
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@purchaseProID",batch.purchaseProID),
new SqlParameter("@batchNum",batch.boxNum),
new SqlParameter("@boxNum",batch.boxNum),
new SqlParameter("@proCount",batch.proCount),
new SqlParameter("@realityProCount",batch.realityProCount),
new SqlParameter("@expirationDate",batch.expirationDate),
new SqlParameter("@makeDate",batch.makeDate),
};
return DataBaseHelper.ExcuteSqlReturnInt("BioPuchaseProBatch_ADD", CommandType.StoredProcedure, pars);

共用方法的封装:

 /// <summary>
/// 根据任务表单编号,和 任务表编号进行查询返回数据表
/// </summary>
/// <param name="TaskID">TaskID:如合同管理单号为5</param>
/// <param name="TaskTableID">TaskTableID:如合同管理单(1)、商品供货单(2)、商品采购申请单(3)</param>
/// <returns></returns>
public static DataTable getTaskListRecordsByCondition(string TaskID, string TaskTableID)
{
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@tableName","TaskListRecord"),
new SqlParameter("@columns"," *,UserName=dbo.getUserNameByUserID(Transmitter) "),
new SqlParameter("@condition"," TaskID='"+TaskID+"' and TaskTableID='"+TaskTableID+"'")
};
return DataBaseHelper.SelectSQLReturnTable("GetDataByCondition", CommandType.StoredProcedure, pars);
} /// <summary>
/// 根据任务表单编号,和 任务表编号进行查询返回数据表
/// </summary>
/// <param name="TaskID">TaskID:如合同管理单号为5</param>
/// <param name="TaskTableID">TaskTableID:如合同管理单(1)、商品供货单(2)、商品采购申请单(3)</param>
/// <returns></returns>
public static String getTaskListRecordsMindsByCondition(string TaskID, string TaskTableID)
{
DataTable dt= getTaskListRecordsByCondition(TaskID, TaskTableID);
string historys = "";
for (int i = 1; i < dt.Rows.Count; i++)
{
historys += dt.Rows[i]["UserName"].ToString() +": "+dt.Rows[i]["Mind"].ToString() + " " +
Convert.ToDateTime(dt.Rows[i]["SumitTime"].ToString()).ToString("yyyy-MM-dd") + "</br>"; }
if (historys.Length == 0)
{
historys = "暂无审核意见";
}
return historys; }

查询视图:

CREATE VIEW [dbo].[View_BioPurchaseProInfo]
AS
SELECT a.*,b.PurchaseProID,
b.ProID,
ProName=dbo.FN_getProNameByProID(b.ProID),
b.ProCount,b.ProPrice,
b.isInvoice,b.isPay,
b.InvoicePrice FROM BioPurchaseAppInfo AS a INNER JOIN BioPurchasePro
AS b ON b.PurchaseID = a.PurchaseID

公用方法的封装:

 /// <summary>
/// 获取流程主题
/// </summary>
/// <param name="TaskID"></param>
/// <param name="TaskTableID"></param>
/// <returns></returns>
public static String getTaskListSubjectByCondition(string listid)
{
object obj= SqlComm.GetObjectByCondition("TaskListRecord", " TOP 1 Subject ", " ListID=" + listid + " ORDER BY ListID desc");
if (obj != null)
{
return obj.ToString();
}
else
{
return null;
}
} /// <summary>
/// 首次接受人
/// </summary>
/// <param name="listid"></param>
/// <returns></returns>
public static String getFirstAccpterByCondition(string listid)
{
object obj = SqlComm.GetObjectByCondition("TaskListRecord", " TOP 1 FirstAccepter ", " ListID=" + listid + " ORDER BY ListID desc");
if (obj != null)
{
return obj.ToString();
}
else
{
return null;
}
} /// <summary>
/// 首次传输人
/// </summary>
/// <param name="listid"></param>
/// <returns></returns>
public static String getFirstTransmitterByCondition(string listid)
{
object obj = SqlComm.GetObjectByCondition("TaskListRecord", " TOP 1 FirstTransmitter ", " ListID=" + listid + " ORDER BY ListID desc");
if (obj != null)
{
return obj.ToString();
}
else
{
return null;
}
}

修改的后台代码:

public partial class ProPurchaseEdit: BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DepartMentBand();
getdata();
hiddenName();
getprobatchDetail();
} }
/// <summary>
/// 批号信息加载
/// </summary>
public void getprobatchDetail()
{
BioPurchaseBLL pbll = new BioPurchaseBLL();
string id = Request.QueryString["taskid"];
DataTable dt = pbll.getProBatchDetailByPurchaseID(id);
#region 加载产品批号信息
if (dt.Rows.Count > 0)
{
int count = dt.Rows.Count;
//2011年12月2日19:27:17
//显示添加批号的前端方法修改为:showobj
ClientScript.RegisterStartupScript(this.GetType(), "showobj", "showobj('divprobatch');setaddbatchs(" + count + ");", true);
string proname = "";
string proId = "";
string txtProCount = "";
string txtProBatch = "";
string txtProBoxNum = "";
string txtMarkDate = "";
string txtExPirationDate = "";
string PurchaseProID = ""; for (int i = 0; i < dt.Rows.Count; i++)
{
proname += dt.Rows[i]["proName"].ToString() + ",";
proId += dt.Rows[i]["proID"].ToString() + ",";
txtProCount += dt.Rows[i]["proCount"].ToString() + ",";
txtProBatch += dt.Rows[i]["batchNum"].ToString() + ",";
txtProBoxNum += dt.Rows[i]["boxNum"].ToString() + ",";
txtMarkDate += Convert.ToDateTime(dt.Rows[i]["makeDate"].ToString()).ToString("yyyy-MM-dd") + ",";
txtExPirationDate += Convert.ToDateTime(dt.Rows[i]["expirationDate"].ToString()).ToString("yyyy-MM-dd") + ",";
PurchaseProID += dt.Rows[i]["purchaseProID"].ToString() + ","; } ClientScript.RegisterStartupScript(this.GetType(), "setbatchsvalues", "setbatchsvalues('" + proname + "','" + proId + "','"
+ txtProCount + "','" + txtProBatch + "','" + txtProBoxNum + "','" + txtMarkDate + "','" + txtExPirationDate + "','" + PurchaseProID + "');", true);
#endregion //判断是否存在此产品的批号信息
if (dt.Rows.Count>0)
{
//当前登录用户是否有产品质量审核权限 值50
if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",50,"))
{ ClientScript.RegisterStartupScript(this.GetType(), "test", "showobj('proAuditing');", true);
if (pbll.getauditingProBatchCountByPurchaseID(id) != 0)
{
this.cb_Auditing.Checked = true;
}
}
else
{
if (pbll.getauditingProBatchCountByPurchaseID(id) != 0)
{
ClientScript.RegisterStartupScript(this.GetType(), "test", "showobj('proAuditing');", true);
this.cb_Auditing.Checked = true;
this.cb_Auditing.Enabled = false;
} } //如果产品批号已经审核 并且 当前登录用户是仓库管理员 则显示相应控件
if (pbll.getauditingProBatchCountByPurchaseID(id) != 0 && SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",25,"))
{
ClientScript.RegisterStartupScript(this.GetType(), "test1", "showobj('stockAuditing');", true);
}
}
}
} /// <summary>
/// 隐藏指定name控件
/// </summary>
/// <returns></returns>
public string hiddenName()
{
if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",48,") ||
SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",49,"))
{
return "addrow/deleteRow/chpro";
}
else
{
return "abcdefg";
}
}
protected void getdata()
{
////如果获取阐述不存在直接跳转。
if (Request.QueryString["taskid"] == null || Request.QueryString["listid"] == null)
{
Response.Write("<script>window.history.go(-1);this.close()</script>");
}
string taskid = Request.QueryString["taskid"].ToString();
string listid = Request.QueryString["listid"].ToString();
//string taskid = "10";
//string listid = "50"; string rights= SqlComm.getUserRightsByUserId(Session["Userid"].ToString()); BioPurchaseBLL purchasebll=new BioPurchaseBLL();
ViewBioPurchaseAppInfo viewpurchase = purchasebll.getViewBioPurchaseAppInfo(taskid);
ddlDepartMent.SelectedValue = viewpurchase.DepartMentID.ToString();
this.lbApplayUser.Text = viewpurchase.AppUserName.ToString();
this.lbOldRealName.Text = viewpurchase.RealUserName;
this.txtRealUserID.Text = viewpurchase.RealUserID.ToString();
this.lbTime.Text = Convert.ToDateTime(viewpurchase.OrderTime).ToString("yyyy-MM-dd");
this.lbOldSenComName.Text = viewpurchase.CopanyName;
this.txtSendCom.Text = viewpurchase.sendComID.ToString();
this.ddlOrderCom.Text = viewpurchase.OrderCom.ToString();
this.ddlSaleType.Text = viewpurchase.WholeType;
this.ddlTypes.Text = viewpurchase.sendType; //判断是否数据库中已经添加了财务审核的记录
if (viewpurchase.BillNo != "" && viewpurchase.BillNo != null)
{
this.lbBill.Visible = true;
this.lbisPay.Visible = true;
this.isPay.Visible = true;
this.txtBillNo.Visible = true;
this.lbPayuser.Visible = true;
this.txtBillUser.Visible = true;
this.btnbilluserchoose.Visible = true;
this.txtBillUser.Text = viewpurchase.BillUserID.ToString();
this.txtBillNo.Text = viewpurchase.BillNo.ToString();
this.lbBillUserName.Text = viewpurchase.BillUserName.ToString();
int paycount= int.Parse(SqlComm.GetObjectByCondition("dbo.BioPurchasePro", "count(isPay)",
" PurchaseID=" + Request.QueryString["taskid"].ToString()).ToString());
if (paycount > 0)
{
this.isPay.Checked = true;
} }
else
{
if (rights.Contains(",48,"))
{
this.lbBill.Visible = true;
this.lbisPay.Visible = true;
this.isPay.Visible = true;
this.txtBillNo.Visible = true;
this.lbPayuser.Visible = true;
this.txtBillUser.Visible = true;
this.btnbilluserchoose.Visible = true;
this.txtBillUser.Text = Session["Userid"].ToString();
this.txtBillNo.Text = DateTime.Now.ToString("yyyyMMdd") + taskid;
this.btnreject.Visible = true;
}
} //判断当前用户是否有仓库管理权限值25
if (rights.Contains(",25,"))
{
this.btbRun.Visible = true;
this.ddlStock.DataSource = SqlComm.GetDataByCondition("BioErpStockTable", "ID,StockName", null);
this.ddlStock.DataTextField = "StockName";
this.ddlStock.DataValueField = "ID";
this.ddlStock.DataBind();
} //根据表单单号在流程表中查询历史审批记录绑定信息
this.lbRemarks.Text= SqlComm.getTaskListRecordsMindsByCondition(taskid, ((int)TaskNavigateEmun.ProPurchase).ToString());
this.hf_subject.Value = SqlComm.getTaskListSubjectByCondition(listid);
this.hf_FirstTransmitter.Value = SqlComm.getFirstTransmitterByCondition(listid);
this.hf_FirstAccepter.Value = SqlComm.getFirstAccpterByCondition(listid);
//根据表单编号查询产品基本信息并绑定
DataTable dt = SqlComm.GetDataByCondition("View_BioPurchaseProInfo",
"ProID,ProName,ProCount,ProPrice,InvoicePrice,purchaseProID", "PurchaseID=" + taskid).Tables[0];
int count = dt.Rows.Count;
ClientScript.RegisterStartupScript(this.GetType(), "addrows", "addrows(" + (count-1) + ");", true); string proNames = "";
string proIDs = "";
string proCounts = "";
string proPrices = "";
decimal totalInvoicePrice = 0;
string purchaseProIDs = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
proIDs+= dt.Rows[i]["ProID"].ToString()+",";
proNames+=dt.Rows[i]["ProName"].ToString()+",";
proCounts+= dt.Rows[i]["ProCount"].ToString()+",";
proPrices+= decimal.Parse(dt.Rows[i]["ProPrice"].ToString()).ToString("0.0")+",";
totalInvoicePrice += decimal.Parse(dt.Rows[i]["InvoicePrice"].ToString());
purchaseProIDs += dt.Rows[i]["purchaseProID"].ToString() + ",";
}
ClientScript.RegisterStartupScript(this.GetType(), "setValues",
"setValues('" + proNames + "','" + proIDs + "','" + proCounts + "','" + proPrices + "','" + purchaseProIDs + "');", true);
this.lbTotalInvoicePrice.Text = totalInvoicePrice.ToString("0.0");
} /// <summary>
/// 绑定部门信息
/// </summary>
private void DepartMentBand()
{
ddlDepartMent.DataSource = SqlComm.getDepartMent();
ddlDepartMent.DataTextField = "DepartmentName";
ddlDepartMent.DataValueField = "DepartmentId";
ddlDepartMent.DataBind();
ddlDepartMent.Items.Add(new ListItem("--请选择部门--", "0"));
ddlDepartMent.SelectedValue = "0";
}
protected void btnSubmit_Click(object sender, EventArgs e)
{ TaskListRecord record = new TaskListRecord();
record.Accepter = int.Parse(this.txtNetUserId.Text.Trim());
record.AuditingSate = 0;
record.DepartMentId = int.Parse(this.ddlDepartMent.SelectedValue.ToString());
record.FirstAccepter = int.Parse(this.hf_FirstAccepter.Value);
record.FirstSumitTime = Convert.ToDateTime(this.lbTime.Text);
record.FirstTransmitter = int.Parse(this.hf_FirstTransmitter.Value);
record.Mind = this.txtRemark.Text;
record.Pass = 1;
record.Subject = hf_subject.Value;
record.SumitTime = DateTime.Now;
record.TaskID = int.Parse(Request.QueryString["taskid"].ToString());
record.TaskTableID = (int)TaskNavigateEmun.ProPurchase;
record.Transmitter = int.Parse(Session["Userid"].ToString()); //财务审核
if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",48,"))
{
SqlComm.UpdateTableByCondition("BioPurchaseAppInfo", "BillUserID='" +
this.txtBillUser.Text.Trim() + "',BillNo='" + this.txtBillNo.Text.Trim() + "'", " PurchaseID=" + Request.QueryString["taskid"].ToString());
int ispay = 0;
if (isPay.Checked)
{
ispay = 1;
}
SqlComm.UpdateTableByCondition("BioPurchasePro", "ispay=" + ispay, "PurchaseID=" + Request.QueryString["taskid"].ToString()); } //有产品批号添加权限的人员来进行
if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",49,"))
{
SqlComm.DeleteTableByCondition("BioPuchaseProBatch", " where purchaseProID IN
(SELECT PurchaseProID FROM dbo.BioPurchasePro WHERE PurchaseID=" + Request.QueryString["taskid"].ToString() + ")"); //2011年11月29日22:30:00
// string proid = Request["PurchaseProID"]; 修改为 string proid = Request["PurchaseProID2"];
string proid = Request["PurchaseProID2"];
string procount = Request["txtProCount0"];
string txtProBatch = Request["txtProBatch0"];
string txtProBoxNum = Request["txtProBoxNum0"];
string txtMarkDate = Request["txtMarkDate0"];
string txtExPirationDate = Request["txtExPirationDate0"]; if (proid != null)
{
string[] proids = proid.Split(',');
string[] procounts = procount.Split(',');
string[] txtProBatchs = txtProBatch.Split(',');
string[] txtProBoxNums = txtProBoxNum.Split(',');
string[] txtMarkDates = txtMarkDate.Split(',');
string[] txtExPirationDates = txtExPirationDate.Split(',');
BioPurchaseBLL purchasebll = new BioPurchaseBLL();
for (int i = 0; i < proids.Length; i++)
{
BioPuchaseProBatch probatch = new BioPuchaseProBatch();
probatch.purchaseProID = int.Parse(proids[i]);
probatch.proCount = int.Parse(procounts[i]);
probatch.batchNum = txtProBatchs[i];
probatch.boxNum = txtProBoxNums[i];
probatch.makeDate = Convert.ToDateTime(txtMarkDates[i]);
probatch.expirationDate = Convert.ToDateTime(txtExPirationDates[i]);
probatch.realityProCount = int.Parse(procounts[i]);
purchasebll.BioPuchaseProBatchAdd(probatch);
}
}
} //如果有产品质量审核的权限
if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains(",50,"))
{
if (cb_Auditing.Checked)
{
//2011年12月3日
//修改条件 去掉了第一个"Where"
bool isok = SqlComm.UpdateTableByCondition("dbo.BioPuchaseProBatch", "isAuditing=1",
" ProBatchID IN (SELECT ProBatchID FROM dbo.BioPuchaseProBatch WHERE purchaseProID IN (SELECT PurchaseProID FROM dbo.BioPurchasePro WHERE PurchaseID="
+ Request.QueryString["taskid"].ToString() + "))");
}
} ////判断当前登录用户是否是部门经理,并且是否是当前部门
//if (Web.UserLogin.user.RoleId == ((int)RoseEmun.DepartMentManager) && Web.UserLogin.user.DepartmentId
== int.Parse(this.ddlDepartMent.SelectedValue.ToString()))
//{ if (SqlComm.TaskListRecordAdd(record) != 0)
{
SqlComm.UpdateTableByCondition("dbo.TaskListRecord", " AuditingSate=1", " ListID=" + Request.QueryString["listid"].ToString());
//ClientScript.RegisterStartupScript(this.GetType(), "test",
"alert('合同申请提交成功,下次审批人员编号:" + this.txtNetUserId.Text + "')", true);
} //} Response.Redirect("~/Web/Desk.aspx");
} //拒绝审核
protected void Button1_Click(object sender, EventArgs e)
{
TaskListRecord record = new TaskListRecord();
record.Accepter = int.Parse(this.hf_FirstTransmitter.Value);
record.AuditingSate = 0;
record.DepartMentId = int.Parse(this.ddlDepartMent.SelectedValue.ToString());
record.FirstAccepter = int.Parse(this.hf_FirstAccepter.Value);
record.FirstSumitTime = Convert.ToDateTime(this.lbTime.Text);
record.FirstTransmitter = int.Parse(this.hf_FirstTransmitter.Value);
record.Mind = this.txtRemark.Text;
record.Pass = 1;
record.Subject = hf_subject.Value;
record.SumitTime = DateTime.Now;
record.TaskID = int.Parse(Request.QueryString["taskid"].ToString());
record.TaskTableID = (int)TaskNavigateEmun.ProPurchase;
record.Transmitter = int.Parse(Session["Userid"].ToString()); //判断当前登录用户是否是部门经理,并且是否是当前部门
if (Web.UserLogin.user.RoleId == ((int)RoseEmun.DepartMentManager) && Web.UserLogin.user.DepartmentId
== int.Parse(this.ddlDepartMent.SelectedValue.ToString()))
{
if (SqlComm.TaskListRecordAdd(record) != 0)
{
SqlComm.UpdateTableByCondition("dbo.TaskListRecord", " AuditingSate=1", " ListID=" + Request.QueryString["listid"].ToString());
ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('购进审核请提交成功,下次审批人员编号:" + this.txtNetUserId.Text + "')", true);
}
}
Response.Redirect("~/Web/Desk.aspx"); } protected void btbRun_Click(object sender, EventArgs e)
{
//判断是否已经质量审核
if (cb_Auditing.Checked == false)
{
ClientScript.RegisterStartupScript(this.GetType(), "test3", "alert('请完成产品质量审核后才能入库')", true); return;
}
//判断是否选择了 仓库审核合格 if (cb_Stock.Checked == false)
{
ClientScript.RegisterStartupScript(this.GetType(), "test3", "alert('请先选择仓库审核合格,否则不能入库')", true);
return;
} string proId = Request["proIds"].ToString();
string procount = Request["txtProCount0"].ToString();
string ProBoxNum = Request["txtProBoxNum0"].ToString();
string ProBatch = Request["txtProBatch0"].ToString();
string MarkDate = Request["txtMarkDate0"].ToString();
string ExPirationDate = Request["txtExPirationDate0"].ToString();
string PurchaseProID = Request["PurchaseProID2"].ToString(); string[] proIds = proId.Split(',');
string[] procounts = procount.Split(',');
string[] ProBoxNums = ProBoxNum.Split(',');
string[] ProBatchs = ProBatch.Split(',');
string[] MarkDates = MarkDate.Split(',');
string[] ExPirationDates = ExPirationDate.Split(',');
string[] PurchaseProIDs = PurchaseProID.Split(','); ArrayList arraylist=new ArrayList();
for (int i = 0; i < PurchaseProIDs.Length; i++)
{ object o= SqlComm.GetObjectByCondition("BioPurchasePro", "ProPrice", " PurchaseProID=" + PurchaseProIDs[i]);
if (o != null)
{
arraylist.Add(o.ToString());
}
} BioProStock prostock = new BioProStock();
//添加产品批号等信息到产品库存表
BioPurchaseBLL pbll = new BioPurchaseBLL();
for (int i = 0; i < proIds.Length; i++)
{
prostock.ProID = int.Parse(proIds[i]);
prostock.BathNum = ProBatchs[i];
prostock.ProCout = int.Parse(procounts[i]);
prostock.StockPrice = decimal.Parse(arraylist[i].ToString());
prostock.MakeDate = Convert.ToDateTime(MarkDates[i]);
prostock.ExpirateDate = Convert.ToDateTime(ExPirationDates[i]);
prostock.StockID = int.Parse(this.ddlStock.SelectedValue.ToString());
pbll.BioProStockAdd(prostock);
} TaskListRecord record = new TaskListRecord();
record.Accepter = int.Parse(this.hf_FirstTransmitter.Value);
record.AuditingSate = 2;
record.DepartMentId = int.Parse(this.ddlDepartMent.SelectedValue.ToString());
record.FirstAccepter = int.Parse(this.hf_FirstAccepter.Value);
record.FirstSumitTime = Convert.ToDateTime(this.lbTime.Text);
record.FirstTransmitter = int.Parse(this.hf_FirstTransmitter.Value);
record.Mind = this.txtRemark.Text;
record.Pass = 1;
record.Subject = hf_subject.Value;
record.SumitTime = DateTime.Now;
record.TaskID = int.Parse(Request.QueryString["taskid"].ToString());
record.TaskTableID = (int)TaskNavigateEmun.ProPurchase;
record.Transmitter = int.Parse(Session["Userid"].ToString()); if (SqlComm.TaskListRecordAdd(record) != 0)
{
SqlComm.UpdateTableByCondition("dbo.TaskListRecord", " AuditingSate=1", " ListID=" + Request.QueryString["listid"].ToString()); }
}
}
上一篇:string 转 java对象、转map的方式


下一篇:为什么 String 在 Java 中是不可变的(终极答案)