// JScript 文件
//------------------------------新增行-----------------------------//
function myonkeydown()
{
var eObj=event.srcElement;
var tr;
if(eObj.tagName!="INPUT"||event.keyCode!=13)
{
return true;
}
event.returnValue=false;
tr=eObj.parentElement.parentElement;
add_row(tr);
document.all["txtpartname"].select();
// var tab1=$get('GridView2')
// if(tab1.rows.length==2)
// {
// }
GetInAll();
}
function add_row(tr)
{
var tableobj=document.getElementById("GridView1");
tableobj.style.width='120%';
// var x=parseFloat(tr.cells[7].all[0].value);
var v=parseFloat(tr.cells[8].all[0].value);
var l=parseFloat(tr.cells[10].all[0].value);
var price=parseFloat(tr.cells[12].all[0].value);
var q=tr.cells[2].innerText.replace(' ',"");
if(document.getElementById("TextBox2").value.indexOf("五金")<0)
{
// if(isNaN(x))
// {
// alert("规格宽输入为空或非数字");
// tr.cells[7].all[0].select();
// return false;
// }
if(isNaN(v))
{
alert("剪片长输入为空或非数字");
tr.cells[8].all[0].select();
return false;
}
switch(q)
{
case "主料":
break;
case "配料":
break;
case "里布":
break
default :
if(isNaN(price))
{
alert("单价输入为空或非数字");
tr.cells[12].all[0].select();
return;
}
}
}else{
if(isNaN(price))
{
alert("单价输入为空或非数字");
tr.cells[12].all[0].select();
return false;
}
}
if(isNaN(l))
{
alert("件数输入为空或非数字");
tr.cells[10].all[0].select();
return false;
}
else
{
if(tableobj.rows.length>1)
{
var rowsCount=0;
for(var i=0;i<tableobj.rows.length;i++)
{
if(tr.cells[0].innerText.replace(//s/g,"")==tableobj.rows[i].cells[2].innerText.replace(//s/g,""))
{
// alert("该部件已经存在,不能重复添加!!");
//tableobj.rows[i].style.backgroundColor='#8DB6CD';
// return;
rowsCount=rowsCount+1;
}
}
if(rowsCount>0)
{
if(!window.confirm("该部件已经存在是否继续添加?"))
{
return true;
}
}
}
}
//---------------------------------------------
if(tableobj.innerText.replace(' ','')=="")
{
if(tableobj.rows.length>0)
{
tableobj.deleteRow(0);
}
var newtr=tableobj.insertRow();
newtr.style.backgroundColor='#C1DAD7';
var array=new Array("","","","","","部件名","料码","","规格长","规格宽","裁片长","裁片宽","件数","托底","规格","损耗","实际量","含损量","单价","金额","","单位","备注");
for(var i=0;i<array.length;i++)
{
var cell=newtr.insertCell();
cell.innerText=array[i];
}
newtr.style.backgroundColor='#C1DAD7';
}
var rowobj=tableobj.insertRow();
//控制行样式
if(rowobj.rowIndex % 2 == 0)
{
rowobj.className="GridViewAlternatingRowStyle";
}
else
{
rowobj.className="GridViewRowStyle";
}
var cell0=rowobj.insertCell(rowobj.cells.length);
var cell1=rowobj.insertCell(rowobj.cells.length);
var cell2=rowobj.insertCell(rowobj.cells.length);
var cell3=rowobj.insertCell(rowobj.cells.length);
var cell4=rowobj.insertCell(rowobj.cells.length);
var cell5=rowobj.insertCell(rowobj.cells.length);
var cell6=rowobj.insertCell(rowobj.cells.length);
var cell7=rowobj.insertCell(rowobj.cells.length);
var cell8=rowobj.insertCell(rowobj.cells.length);
var cell9=rowobj.insertCell(rowobj.cells.length);
var cell10=rowobj.insertCell(rowobj.cells.length);
var cell11=rowobj.insertCell(rowobj.cells.length);
var cell12=rowobj.insertCell(rowobj.cells.length);
var cell13=rowobj.insertCell(rowobj.cells.length);
var cell14=rowobj.insertCell(rowobj.cells.length);
var cell15=rowobj.insertCell(rowobj.cells.length);
var cell16=rowobj.insertCell(rowobj.cells.length);
var cell17=rowobj.insertCell(rowobj.cells.length);
var cell18=rowobj.insertCell(rowobj.cells.length);
var cell19=rowobj.insertCell(rowobj.cells.length);
var cell20=rowobj.insertCell(rowobj.cells.length);
var cell21=rowobj.insertCell(rowobj.cells.length);
var cell22=rowobj.insertCell(rowobj.cells.length);
cell0.innerText=tableobj.rows.length-1;
cell0.noWrap=true;
cell1.innerHTML="<input id=/"chbChild/" type=/"checkbox/" onclick='checkbox();enableItemButton();'/>";
cell2.innerText=tr.cells[0].innerHTML;
cell2.noWrap=true;
cell3.innerText=tr.cells[1].innerHTML;
cell3.noWrap=true;
cell4.innerText=tr.cells[2].innerHTML;
cell4.noWrap=true;
cell5.innerHTML=tr.cells[3].innerHTML;
cell5.noWrap=true;
cell6.innerHTML=tr.cells[4].innerHTML;
cell6.noWrap=true;
cell7.innerHTML=tr.cells[5].innerHTML;
var jianshuo=parseFloat(tr.cells[10].all[0].value.replace(//s/g,""));
var sizewidth="";
var sizelength="";
var slicelength="";
var slicewidth="";
var size="";
var waster="";
var realnum="";
var wasternum="";
var singleprice="";
var subamt="";
// var main="";
//var mainname="";
// var assist="";
if(document.getElementById("TextBox2").value.indexOf("五金")<0)
{
sizelength=(tr.cells[6].all[0].value.replace(//s/g,"").length==0)?36:tr.cells[6].all[0].value.replace(//s/g,"");
//sizewidth=tr.cells[7].all[0].value.replace(//s/g,"");
slicelength=tr.cells[8].all[0].value.replace(//s/g,"");
slicewidth=tr.cells[9].all[0].value.replace(//s/g,"");
//
switch(tr.cells[2].innerText.replace(' ',""))
{
case "配料":
singleprice=document.getElementById("txtassistprice").value;
//main=document.getElementById("txtassistno").value;
sizewidth=(tr.cells[7].all[0].value.replace(//s/g,"").length==0)?document.getElementById("txtassistsize").value:tr.cells[7].all[0].value.replace(//s/g,"");
size=parseFloat(sizelength)*parseFloat(sizewidth);
break;
case "主料":
singleprice=document.getElementById("txtmainprice").value; //
//main=document.getElementById("txtmainmano").value;
sizewidth=(tr.cells[7].all[0].value.replace(//s/g,"").length==0)?document.getElementById("txtmainsize").value:tr.cells[7].all[0].value.replace(//s/g,"");
size=parseFloat(sizelength)*parseFloat(sizewidth);
break;
case "里布":
singleprice=document.getElementById("txtlibu").value;
// main=document.getElementById("txtmylibu").value;
sizewidth=(tr.cells[7].all[0].value.replace(//s/g,"").length==0)?document.getElementById("txtlibusize").value:tr.cells[7].all[0].value.replace(//s/g,"");
size=parseFloat(sizelength)*parseFloat(sizewidth);
break;
default:
singleprice=tr.cells[12].all[0].value.replace(//s/g,"");
sizewidth=(tr.cells[7].all[0].value.replace(//s/g,"").length==0)?"":tr.cells[7].all[0].value.replace(//s/g,"");
size=parseFloat(sizelength)*parseFloat((sizewidth=="")?1:sizewidth);
break;
}
waster=(tr.cells[11].all[0].value.replace(//s/g,"").length==0)?1.10:tr.cells[11].all[0].value.replace(//s/g,"");
realnum=decimaltest(parseFloat(slicelength)*parseFloat((slicewidth=="")?1:slicewidth)*jianshuo/size,4);
wasternum=decimaltest(parseFloat(slicelength)*parseFloat((slicewidth=="")?1:slicewidth)*jianshuo*parseFloat(waster)/size,4);
}
else{
singleprice=tr.cells[12].all[0].value.replace(//s/g,"");
waster=(tr.cells[11].all[0].value.replace(//s/g,"").length==0)?0:tr.cells[11].all[0].value.replace(//s/g,"");
if(parseFloat(waster)==0)
{
realnum=jianshuo*1;
wasternum=realnum;
}
else{
realnum=jianshuo;
wasternum=jianshuo*waster;
}
}
subamt=decimaltest(parseFloat(wasternum)*parseFloat(singleprice),4);
cell8.innerHTML="<input id=/"txtsizelength/" type=/"TextBox/" ondblclick='OpentypePage();' title='双击更改类别' onbkeyup='if(isNaN(value))execCommand(/"undo/");autoCount();' value='"+sizelength+"' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell9.innerHTML="<input id=/"txta/" type=/"TextBox/" onkeyup='if(isNaN(value))execCommand(/"undo/");autoCount();' ondblclick='OpenPart();' title='双击更改部件' value='"+sizewidth+"' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell10.innerHTML="<input id=/"txtb/" type=/"TextBox/" onkeyup='if(isNaN(value))execCommand(/"undo/");autoCount();' value='"+slicelength+"' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell11.innerHTML="<input id=/"txtc/" type=/"TextBox/" onkeyup='if(isNaN(value))execCommand(/"undo/");autoCount();' value='"+slicewidth+"' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell12.innerHTML="<input id=/"txtslicelength/" type=/"TextBox/" onkeyup='if(isNaN(value))execCommand(/"undo/");autoCount();' value='"+jianshuo+"' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell13.innerHTML="<input id=/"txtbottom/" type=/"TextBox/" value='' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: black 1px solid'/>";
cell14.innerHTML="<input id=/"txtsize/" type=/"TextBox/" value='"+size+"' onkeydown='event.returnValue=false;' onkeyup='if(isNaN(value))execCommand(/"undo/")' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell15.innerHTML="<input id=/"txtwaster/" type=/"TextBox/" value='"+waster+"' onkeyup='if(isNaN(value))execCommand(/"undo/");autoCount();' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell16.innerHTML="<input id=/"txtreal/" type=/"TextBox/" value='"+realnum+"' onkeydown='event.returnValue=false' onkeyup='if(isNaN(value))execCommand(/"undo/")' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell17.innerHTML="<input id=/"txtwaster/" type=/"TextBox/" value='"+wasternum+"' onkeydown='event.returnValue=false' onkeyup='if(isNaN(value))execCommand(/"undo/")' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell18.innerHTML="<input id=/"txtprice/" type=/"TextBox/" value='"+singleprice+"' onkeyup='if(isNaN(value))execCommand(/"undo/");autoCount();' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: black 1px solid'/>";
cell19.innerHTML="<input id=/"txtsubamt/" type=/"TextBox/" value='"+subamt+"' onkeydown='event.returnValue=false' onkeyup='if(isNaN(value))execCommand(/"undo/")' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell20.innerText="";
cell21.innerHTML="<input id=/"txtunit/" type=/"TextBox/" value='' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
cell22.innerHTML="<input id=/"txtother/" type=/"TextBox/" value='' style='width:60px ;border-right: #f1f0f4 1px solid;border-top: #f1f0f4 1px solid;border-left: #f1f0f4 1px solid;border-bottom: #696969 1px solid'/>";
alert("添加成功!!");
document.all["txtpartname"].select();
}
//num表示要四舍五入的数,v表示要保留的小数位数。
function decimaltest(num,v)
{
var vv = Math.pow(10,v);
return Math.round(num*vv)/vv;
}
function enablebutton()
{
if(document.getElementById('btnsave').disabled==true)
{
document.getElementById('btnsave').disabled=false;
}
}
function enableItemButton()
{
if(document.getElementById('btndelitem').disabled==true)
{
document.getElementById('btndelitem').disabled=false;
}
}
//------------------------------删除行------------------------------//
function leo()
{
//当删除一行后,对各行重新建立索引 leo
var tableobj=document.getElementById("GridView1");
for(i=1;i<tableobj.rows.length;i++)
{
if(tableobj.rows[i].rowIndex % 2 == 0)
{
tableobj.rows[i].className="GridViewAlternatingRowStyle";
}
else
{
tableobj.rows[i].className="GridViewRowStyle";
}
}
}
function checkbox()
{
var p=document.getElementById("GridView1");
for(var i=1;i<p.rows.length;i++)
{
if(p.rows[i].cells[1].childNodes[0].checked)
{
p.rows[i].style.backgroundColor='#8DB6CD';
}
else
{
p.rows[i].style.backgroundColor="";
}
}
}
function DeleteItems()
{
var items="";
var tableobj=document.getElementById("GridView1");
for(var i=1;i<tableobj.rows.length;i++)
{
if(tableobj.rows[i].cells[1].childNodes[0].checked)
{
items=items+(tableobj.rows[i].cells[2].innerText)+";";
}
}
document.getElementById("txtsale").value=items;
}
function DeleteRows()
{
var tableobj=document.getElementById("GridView1");
var arrays=new Array();
for(var i=1;i<tableobj.rows.length;i++)
{
if(tableobj.rows[i].cells[1].childNodes[0].checked)
{
arrays.push(i);
}
}
if(arrays.length==0)
{
alert('请选择要删除的项!');
document.getElementById("btndelitem").disabled=true;
return;
}
else
{
DeleteRow(arrays);
for(var j=1; j<tableobj.rows.length;j++)
{
tableobj.rows[j].cells[0].innerText=j;
}
}
}
function DeleteRow(arrays)
{
arrays.reverse();
var tableobj=document.getElementById("GridView1");
for(var i=0;i<arrays.length;i++)
{
tableobj.deleteRow(arrays[i]);
}
}
function ReSetRowNumber()
{
var tableobj=document.getElementById("GridView1");
for(var j=1; j<tableobj.rows.length;j++)
{
tableobj.rows[j].cells[0].innerText=j;
}
}
//----------------------------保存数据-------------------------------//
function IsNumber(v,type){ //数字类型判断
try { var x=2;x=v/2;
if(type=="0")
{
if(x.toString()=="NaN"||v.length==0||v.indexOf(".")>-1)
return false;
else
return true;
}
if(type=="1")
{
if(x.toString()=="NaN"||v.length==0)
return false;
else
return true;
}
}
catch(e){return false;}
}
//保存数据
function saveData()
{
var i,j, maxtab,txtSave,txtHtml;
txtSave= document.getElementById("txtsave");
maxtab=document.getElementById("GridView1");
var ma=document.getElementById("hdMa").value.split("②");
// alert(ma);
var dstr="";
for(var k=0;k<ma.length-1;k++)
{
column=ma[k].split("①");
// alert(column[0]);
for(i=1;i<maxtab.rows.length;i++)
{
dstr=dstr + (maxtab.rows[i].cells[2].innerText) + "۩";
dstr=dstr + (maxtab.rows[i].cells[3].innerText) + "۩";
dstr=dstr + ((maxtab.rows[i].cells[8].all[0].value.replace(' ',"").length==0)?0:maxtab.rows[i].cells[8].all[0].value)+"۩";
dstr=dstr + ((maxtab.rows[i].cells[9].all[0].value.replace(' ',"").length==0)?0:maxtab.rows[i].cells[9].all[0].value)+"۩";
dstr=dstr + ((maxtab.rows[i].cells[10].all[0].value.replace(' ',"").length==0)?0:maxtab.rows[i].cells[10].all[0].value)+"۩";
dstr=dstr + ((maxtab.rows[i].cells[11].all[0].value.replace(' ',"").length==0)?0:maxtab.rows[i].cells[11].all[0].value)+"۩";
dstr=dstr + (maxtab.rows[i].cells[12].all[0].value) + "۩";
dstr=dstr + (maxtab.rows[i].cells[13].all[0].value) + "۩";
dstr=dstr + ((maxtab.rows[i].cells[14].all[0].value.replace(' ',"").length==0)?0:maxtab.rows[i].cells[14].all[0].value)+"۩";
dstr=dstr + (maxtab.rows[i].cells[15].all[0].value) + "۩";
dstr=dstr + (maxtab.rows[i].cells[16].all[0].value) + "۩";
dstr=dstr + (maxtab.rows[i].cells[17].all[0].value) + "۩";
dstr=dstr + (maxtab.rows[i].cells[18].all[0].value) + "۩";
dstr=dstr + (maxtab.rows[i].cells[19].all[0].value) + "۩";
switch(maxtab.rows[i].cells[4].innerText.replace(' ',""))
{
case "主料":
dstr=dstr + (column[0]) + "۩";
//alert(dstr)
break;
case "配料":
dstr=dstr + (column[2]) + "۩";
break;
case "里布":
dstr=dstr + (column[4]) + "۩";
break;
default:
dstr=dstr + ("") + "۩";
break;
} //¶
dstr=dstr + (maxtab.rows[i].cells[21].all[0].value) + "۩";
dstr=dstr + (maxtab.rows[i].cells[22].all[0].value) + "۩";
switch(maxtab.rows[i].cells[4].innerText.replace(' ',""))
{
case "五金":
dstr=dstr + (column[6]) + "۩";
break;
default:
dstr=dstr + ("") + "۩";
break;
}
dstr=dstr + (column[7]) + "¶";
}
}
txtSave.value=dstr;
// alert(dstr);
}
function GetInAll()
{
var table=document.getElementById("GridView1");
var rows=table.rows;
var num=0;
var total=0;
var diffnum=0;
// var difftotal=0;
for(var i=1;i<rows.length;i++)
{
num +=parseFloat(rows[i].cells[16].all[0].value);
total+=parseFloat(rows[i].cells[17].all[0].value);
diffnum+=parseFloat(rows[i].cells[19].all[0].value);
//diffnum+=parseFloat(rows[i].cells[9].innerText);
}
var showtable=document.getElementById("dtfooter");
showtable.style.textAlign='left';
showtable.style.fontSize='6pt';
showtable.rows[0].cells[16].innerText=decimaltest(num,4);
showtable.rows[0].cells[17].innerText=decimaltest(total,4);
showtable.rows[0].cells[19].innerText=decimaltest(diffnum,4);
//showtable.rows[0].cells[11].innerText=decimaltest(difftotal,3);
}
//------------------------------------------物料添加----------------------------------------------------//
function AddRow()
{
//添加一行
var i =tab1.rows.length;
var Nam="'div1'";
var Cod="fuJ"+i;
var newTr=tab1.insertRow();
//添加列
var newTd0 = newTr.insertCell();
var newTd1 = newTr.insertCell();
var newTd2 = newTr.insertCell();
var newTd3 = newTr.insertCell();
var newTd4 = newTr.insertCell();
var newTd5 = newTr.insertCell();
var newTd6 = newTr.insertCell();
var newTd7 = newTr.insertCell();
var newTd8 = newTr.insertCell();
var newTd9 = newTr.insertCell();
var newTd10 =newTr.insertCell();
var newTd11 =newTr.insertCell();
//设置列内容和属性
newTd0.innerHTML = "<input width='100px' type='checkbox' id='box1' onClick='enableItemButton();'/>" ;
newTd1.innerText ="" ;
newTd2.innerText ="" ;
newTd3.innerHTML="<IMG SRC='../images/right3.gif' onClick='OpenMainPage(); enablebtn();'/>" ;
newTd4.innerText ="";
newTd5.innerHTML ="";
newTd6.innerHTML="<IMG SRC='../images/right3.gif' onClick='OpenAssistPage();enablebtn();'/>";
newTd7.innerText="";
newTd8.innerText="";
newTd9.innerHTML="<IMG SRC='../images/right3.gif' onClick='Openlibu();enablebtn();'/>" ;
newTd10.innerHTML="<input type ='text' onkeydown='if(event.keyCode==13){ AddRow();} event.returnValue=false;' ondblclick='OpenColor();' title='双击选择颜色' id ='costomerCode' onkeypress='enablebtn();' style='width:90px ;height:20px ;border-right: 0px ;border-top: 0px ;border-left: 0px ;border-bottom: #696969 1px solid'/>";
newTd11.innerHTML="<input type ='text' onkeydown='if(event.keyCode==13){ AddRow();}' id ='costomerCode' event.returnValue=false;' ondblclick='OpenColor1();' title='双击选择颜色' onkeypress='enablebtn();' title='此处要准确输入' style='width:90px ;height:20px ;border-right: 0px ;border-top: 0px ;border-left: 0px ;border-bottom: #696969 1px solid'/>";
}
//---------------------------弹出对话框-------------------------------------
function enableItemButton()
{
document.getElementById('delbag').disabled=false;
document.getElementById('btnprint').disabled=false;
}
function enablebtn()
{
$get('btnsave').disabled=false;
}
function OpenColor()
{
var url="../PopUpWindow/ColorInfo.aspx";
var result=window.showModalDialog(url,window,"DialogHeight=400px;dialogWidth:400px;status:no;scrollbars:auto;Resizable=no;");
if(result != null)
{
var row=window.event.srcElement.parentElement.parentElement
row.cells[10].innerHTML="<input type ='text' value='"+result[1].toString()+"' onkeydown='if(event.keyCode==13){ AddRow();} event.returnValue=false;' ondblclick='OpenColor();' title='双击选择颜色' id ='costomerCode' onkeypress='enablebtn();' style='width:90px ;height:20px ;border-right: 0px ;border-top: 0px ;border-left: 0px ;border-bottom: black 1px solid'/>";
//row.cells[5].innerText=result[1].toString();
}
return false;
}
function OpenColor1()
{
var url="../PopUpWindow/ColorInfo.aspx";
var result=window.showModalDialog(url,window,"DialogHeight=400px;dialogWidth:400px;status:no;scrollbars:auto;Resizable=no;");
if(result != null)
{
var row=window.event.srcElement.parentElement.parentElement
row.cells[11].innerHTML="<input type ='text' value='"+result[1].toString()+"' onkeydown='if(event.keyCode==13){ AddRow();} event.returnValue=false;' ondblclick='OpenColor();' title='双击选择颜色' id ='costomerCode' onkeypress='enablebtn();' style='width:90px ;height:20px ;border-right: 0px ;border-top: 0px ;border-left: 0px ;border-bottom: black 1px solid'/>";
//row.cells[5].innerText=result[1].toString();
}
return false;
}
function OpenMainPage()
{
var url="../PopUpWindow/MaDetails.aspx";
var result=window.showModalDialog(url,window,"DialogHeight=500px;dialogWidth:600px;status:no;scrollbars:auto;Resizable=no;");
var tab1=$get('tab1');
var j=0;
for(var i=1;i<tab1.rows.length;i++)
{
if(tab1.rows[i].cells[1].innerText.replace(' ',"")==result[0].replace(' ',"").toString())
{
j++;
}
}
if(j>0)
{
if(!window.confirm("该物料已添加,是否要重复添加?"))
{
return true;
}
}
if(result != null)
{
var row=window.event.srcElement.parentElement.parentElement
row.cells[1].innerText=result[0].toString();
row.cells[2].innerText=result[1].toString();
}
return false;
}
function OpenAssistPage()
{
var url="../PopUpWindow/MaDetails.aspx";
var result=window.showModalDialog(url,window,"DialogHeight=500px;dialogWidth:600px;status:no;scrollbars:auto;Resizable=no;");
var tab1=$get('tab1');
var j=0;
for(var i=1;i<tab1.rows.length;i++)
{
if(tab1.rows[i].cells[4].innerText.replace(' ',"")==result[0].replace(' ',"").toString())
{
j++;
}
}
if(j>0)
{
if(!window.confirm("该物料已添加,是否要重复添加?"))
{
return true;
}
}
if(result != null)
{
var row=window.event.srcElement.parentElement.parentElement
row.cells[4].innerText=result[0].toString();
row.cells[5].innerText=result[1].toString();
}
return false;
}
function Openlibu()
{
var url="../PopUpWindow/MaDetails.aspx";
var result=window.showModalDialog(url,window,"DialogHeight=500px;dialogWidth:600px;status:no;scrollbars:auto;Resizable=no;");
var tab1=$get('tab1');
var j=0;
for(var i=1;i<tab1.rows.length;i++)
{
if(tab1.rows[i].cells[7].innerText.replace(' ',"")==result[0].replace(' ',"").toString())
{
j++;
}
}
if(j>0)
{
if(!window.confirm("该物料已添加,是否要重复添加?"))
{
return true;
}
}
if(result != null)
{
var row=window.event.srcElement.parentElement.parentElement
row.cells[7].innerText=result[0].toString();
row.cells[8].innerText=result[1].toString();
row.cells[10].all[0].select();
}
return false;
}
//-------------------------------------------删除项-----------------------------------//
function DeleteRows1()
{
var tableobj=document.getElementById("tab1");
var arrays=new Array();
for(var i=1;i<tableobj.rows.length;i++)
{
if(tableobj.rows[i].cells[0].childNodes[0].checked)
{
arrays.push(i);
}
}
if(arrays.length==0)
{
alert('请选择要删除的项!');
document.getElementById("delbag").disabled=true;
return;
}
else
{
DeleteRow1(arrays);
}
}
function DeleteRow1(arrays)
{
arrays.reverse();
var tableobj=document.getElementById("tab1");
for(var i=0;i<arrays.length;i++)
{
tableobj.deleteRow(arrays[i]);
}
}
//-------------------------------保存数据------------------------------------
function SaveMa()
{
var tab1=$get('tab1');
var dstr="";
for(var i=1;i<tab1.rows.length; i++)
{
if(tab1.rows[i].cells[1].innerText.replace(' ',"").length==0)
{
alert('请选择主料!!');
$get('btnsave').disabled=true;
return;
}
if(tab1.rows[i].cells[4].innerText.replace(' ',"").length==0)
{
alert('请选择配料!!');
$get('btnsave').disabled=true;
return;
}
if(tab1.rows[i].cells[7].innerText.replace(' ',"").length==0)
{
alert('请选择配料!!');
$get('btnsave').disabled=true;
return;
}
if(tab1.rows[i].cells[10].all[0].value.replace(' ',"").length==0)
{
alert('请输入五金颜色!!');
$get('btnsave').disabled=true;
tab1.rows[i].cells[10].all[0].select();
return;
}
if(tab1.rows[i].cells[11].all[0].value.replace(' ',"").length==0)
{
alert('请输入成品颜色!!');
$get('btnsave').disabled=true;
tab1.rows[i].cells[11].all[0].select();
return;
}
dstr=dstr + (tab1.rows[i].cells[1].innerText.replace(' ',"")) + "①";
dstr=dstr + (tab1.rows[i].cells[2].innerText.replace(' ',"")) + "①";
dstr=dstr + (tab1.rows[i].cells[4].innerText.replace(' ',"")) + "①";
dstr=dstr + (tab1.rows[i].cells[5].innerText.replace(' ',"")) + "①";
dstr=dstr + (tab1.rows[i].cells[7].innerText.replace(' ',"")) + "①";
dstr=dstr + (tab1.rows[i].cells[8].innerText.replace(' ',"")) + "①";
dstr=dstr + (tab1.rows[i].cells[10].all[0].value.replace(' ',"")) + "①";
dstr=dstr + (tab1.rows[i].cells[11].all[0].value.replace(' ',"")) + "②";
}
$get('hdMa').value=dstr;
// alert(dstr);
}
function AddMaRow()
{
//添加一行
var hdbag=document.getElementById("tab1");
var ma=document.getElementById("hdMa").value.split("②");
var column= new Array();
for(var i=0;i<ma.length-1;i++)
{
column=ma[i].split("①");
var newTr=hdbag.insertRow();
//添加列
var newTd0 = newTr.insertCell();
var newTd1 = newTr.insertCell();
var newTd2 = newTr.insertCell();
var newTd3 = newTr.insertCell();
var newTd4 = newTr.insertCell();
var newTd5 = newTr.insertCell();
var newTd6 = newTr.insertCell();
var newTd7 = newTr.insertCell();
var newTd8 = newTr.insertCell();
var newTd9 = newTr.insertCell();
var newTd10 =newTr.insertCell();
var newTd11 =newTr.insertCell();
//设置列内容和属性
newTd0.innerHTML = "<input width='100px' type='checkbox' id='box1' onClick='enableItemButton();'/>" ;
newTd1.innerText =column[0];
newTd2.innerText =column[1];
newTd2.style.nowrap=true;
newTd3.innerHTML="<IMG SRC='../images/right3.gif' onClick='OpenMainPage(); enablebtn();'/>" ;
newTd4.innerText =column[2];
newTd5.innerHTML =column[3];
newTd5.style.nowrap=true;
newTd6.innerHTML="<IMG SRC='../images/right3.gif' onClick='OpenAssistPage();enablebtn();'/>";
newTd7.innerText=column[4];
newTd8.innerText=column[5];
newTd8.style.nowrap=true;
newTd9.innerHTML="<IMG SRC='../images/right3.gif' onClick='Openlibu();enablebtn();'/>" ;
newTd10.innerHTML="<input type ='text' value='"+column[6]+"' onkeydown='if(event.keyCode==13){ AddRow();} event.returnValue=false;' ondblclick='OpenColor();' title='双击选择颜色' id ='costomerCode' onkeypress='enablebtn();' style='width:90px ;height:20px ;border-right: 0px ;border-top: 0px ;border-left: 0px ;border-bottom: black 1px solid'/>";
newTd11.innerHTML="<input type ='text' value='"+column[7]+"' onkeydown='if(event.keyCode==13){ AddRow();} event.returnValue=false;' ondblclick='OpenColor1();' title='双击选择颜色' id ='costomerCode' onkeypress='enablebtn();' title='此处要准确输入' style='width:90px ;height:20px ;border-right: 0px ;border-top: 0px ;border-left: 0px ;border-bottom: black 1px solid'/>";
}
}
//-------------类别选择---------------------------------------------
function OpentypePage()
{
var url="../BasicInfo/BagYlType.aspx";
var result=window.showModalDialog(url,window,"DialogHeight=500px;dialogWidth:500px;status:no;scrollbars:auto;Resizable=no;");
if (result != null)
{
var row=window.event.srcElement.parentElement.parentElement
row.cells[3].innerText=result[0].toString();
row.cells[4].innerText=result[1].toString();
}
return false;
}
//------------------选择部件-----------------------------------
function OpenPart()
{
var url="../StockInfo/SelectPart.aspx";
var result=window.showModalDialog(url,window,"DialogHeight=450px;dialogWidth:400px;status:no;scrollbars:auto;Resizable=no;");
if (result != null)
{
var row=window.event.srcElement.parentElement.parentElement
row.cells[2].innerText=result[0].toString();
row.cells[5].innerText=result[1].toString();
}
return false;
}
//----------------------------------去零------------------------------//
function TrimGv()
{
var grid=$get('GridView1');
for(var i=1 ;i<grid.rows.length;i++)
{
grid.rows[i].cells[9].all[0].value=decimaltest(grid.rows[i].cells[9].all[0].value,1);
grid.rows[i].cells[10].all[0].value=decimaltest(grid.rows[i].cells[10].all[0].value,3);
grid.rows[i].cells[11].all[0].value=decimaltest(grid.rows[i].cells[11].all[0].value,3);
grid.rows[i].cells[15].all[0].value=decimaltest(grid.rows[i].cells[15].all[0].value,3);
grid.rows[i].cells[16].all[0].value=decimaltest(grid.rows[i].cells[16].all[0].value,3);
grid.rows[i].cells[17].all[0].value=decimaltest(grid.rows[i].cells[17].all[0].value,3);
grid.rows[i].cells[18].all[0].value=decimaltest(grid.rows[i].cells[18].all[0].value,3);
grid.rows[i].cells[19].all[0].value=decimaltest(grid.rows[i].cells[19].all[0].value,3);
}
}
function autoCount()
{
var length;
var width;
var slicelength;
var slicewidth;
var jianshu;
var waster;
var size;
var real;
var price;
var row=window.event.srcElement.parentElement.parentElement;
switch(row.cells[4].innerText.replace(' ',""))
{
default:
var length=(row.cells[8].all[0].value.replace(' ',"")=="")?1:row.cells[8].all[0].value.replace(' ',"");
var width=(row.cells[9].all[0].value.replace(' ',"")=="")?1:row.cells[9].all[0].value.replace(' ',"");
size=decimaltest(parseFloat(length)*parseFloat(width),1);
row.cells[14].all[0].value=size;
price=(row.cells[18].all[0].value.replace(' ',"")=="")?0:row.cells[18].all[0].value.replace(' ',"");
slicelength=(row.cells[10].all[0].value.replace(' ',"")=="")?1:row.cells[10].all[0].value.replace(' ',"");
slicewidth=(row.cells[11].all[0].value.replace(' ',"")=="")?1:row.cells[11].all[0].value.replace(' ',"");
jianshu=(row.cells[12].all[0].value.replace(' ',"")=="")?1:row.cells[12].all[0].value.replace(' ',"");
waster=(row.cells[15].all[0].value.replace(' ',"")=="")?1:row.cells[15].all[0].value.replace(' ',"");
row.cells[16].all[0].value=decimaltest(parseFloat(slicelength)*parseFloat(slicewidth)*parseFloat(jianshu)/size,4);
row.cells[17].all[0].value=decimaltest(parseFloat(slicelength)*parseFloat(slicewidth)*parseFloat(jianshu)*parseFloat(waster)/size,4);
row.cells[19].all[0].value=decimaltest(parseFloat(slicelength)*parseFloat(slicewidth)*parseFloat(jianshu)*parseFloat(waster)*parseFloat(price)/size,4);
break;
case "五金":
price=(row.cells[18].all[0].value.replace(' ',"")=="")?0:row.cells[18].all[0].value.replace(' ',"");
jianshu=(row.cells[12].all[0].value.replace(' ',"")=="")?0:row.cells[12].all[0].value.replace(' ',"");
waster=(row.cells[15].all[0].value.replace(' ',"")==""|| parseFloat(row.cells[15].all[0].value.replace(' ',""))==0)?1:row.cells[15].all[0].value.replace(' ',"");
row.cells[16].all[0].value=decimaltest(parseFloat(jianshu),4);
row.cells[17].all[0].value=decimaltest(parseFloat(jianshu)*parseFloat(waster),4);
row.cells[19].all[0].value=decimaltest(parseFloat(row.cells[17].all[0].value)*parseFloat(price),4);
break;
}
}