您的位置:首页 > 其它

凯云水利水电工程造价管理系统技术解析(二) 项目属性

2015-05-27 20:02 691 查看

项目属性

项目属性: 项目属性主要是包括了导入调整系数, 设置计算公式(新增、删除、修改、查询、上移、下移),项目属性的修改、新增、删去、、、。不同的项目打开的项目属性不一样,刚新建的一个项目,你就需要对他进行新增项目属性,新增完项目属性之后,你就只能对现有的项目属性进行修改,而不能再新增多一个项目属性、、、




下面就是这界面的建表










接下来就是表之间的关系






控件名称
日期控件(easyui-datebox)
单行文本控件(easyui-textbox)
按钮(easyui-linkbutton)
//下面就是设置当前日期

//设置日期



function SetRiQi() {

var curr_time = newDate();//获取当前时间

var strDate = curr_time.getFullYear() + "-";//获取当前年

var vMon = curr_time.getMonth() + 1;//获取当前月

var vDay = curr_time.getDate();//获取当前日
strDate += (vMon < 10?
"0" + vMon : vMon) + "-";//这里有一个三目运运算符,vMon < 10是判断条件,如果符合条件就返回("0" +vMon),否则就返回(vMon)

strDate+= (vDay < 10 ?
"0" + vDay :vDay)
$('#DTPlaitTime').datebox('setValue',strDate);

}

//下面就是生成这个界面的Html
代码
<div id="w" class="easyui-dialog" title="Basic Window" data-options="maximized:true,toolbar:'#Cm'">
<table style="width:100%;background-color: #D2ECEE">
<tr>
<td align="right"> 工程名称:</td> <td><input id="TXTProjectName" style="width:600px" /></td>
</tr>
<tr>
<td align="right">编制人:</td><td><input id="TXTPlaitPeople" style="width:160px" /></td>
<td align="right">编制人证号:</td><td ><input id="TXTPlaitPeopleNumber"style="width:160px" /></td>
<td align="right"></td><td><input id="eere"  style="width:60px;background-color: #D2ECEE;border:2px"/></td>
</tr>
<tr >
<td align="right">编制单位:</td><td><input id="TXTPlaitUnit" style="width:600px"/></td>
</tr>
<tr>
<td align="right">审核人:</td><td><input id="TXTAxaminePeoPle" style="width:160px"/></td>
<td align="right">审核人证号:</td><td><input  id="TXTAxamineAttestation"style="width:160px"/></td>
</tr>
<tr>
<td align="right">审核单位:</td><td><input id="TXTAxamineUnit" style="width:600px" /></td>
</tr>
<tr>
<td align="right">编制时间:</td><td><input class="easyui-datebox"id="DTPlaitTime" data-options="formatter:myformatter,onSelect:onSelect"   style="width:160px"/></td>
<td><div ><span>选中的时间: </span>
<span id="XuanZhong"></span>
</div></td>
</tr>
<tr>
<td align="right">工程总造价:</td><td><input id="TXTProjectAllPrice" style="width:160px" /></td>
</tr>

<tr>
<td align="right">工程所在地:</td><td><input id="TXTProjectLocation" style="width:600px"/></td>
</tr>
</table>
<div style="height:20px;background-color: #D2ECEE">
</div>
<div style="width:100%;height:130px;background-color: #D2ECEE">
<fieldset style="border:1px solid #C0C0C0">
<legend >相关单位</legend>
<table>
<tr>
<td>
<div>
<table>
<tr>
<td align="right">建设单位:</td><td><input  id="TXTBuildUnit" style="width:600px;height:20px"/></td>
</tr>
<tr>
<td align="right">投标单位:</td><td><input id="TXTBidUnit" style="width:600px;height:20px" /></td>
</tr>
<tr>
<td align="right">监理单位:</td><td><input id="TXTSupervisionUnit" style="width:600px;height:20px"/></td>
</tr>
</table>
</div>
</td>
<td>
</td>
</tr>
</table>
</fieldset>
</div>
<div style="width:100%;height:120px;background-color: #D2ECEE ">
<fieldset style="border:1px solid #C0C0C0">
<legend>材料单价</legend>
<tr><td align="center" style="top:0px">计算公式 :</td></tr>
<tr>
<td> <textarea id="TXTCountFurmula" style="width:600px" cols="20" rows="2"></textarea></td>

</tr>
<td><a onclick="$('#w材料单价组成项').window('open')" ><input type="submit" value="设置公式"/></a></td>
</fieldset>
</div>
<div style="width:100%;height:100px;background-color: #D2ECEE">
<fieldset style="border:1px solid #C0C0C0">
<legend>单价统调系数</legend>
<tr>
<td align="right">人工系数:</td><td><input id="TXTManpowerFactor" style="width:183px"/> <a style="width:10%"></a></td>
      <td align="right">材料系数:</td><td><input id="TXTMaterialFacto"  style="width:183px"/> <a style="width:10%"></a></td>
<td align="right">机械系数:</td><td><input id="TXTMachineFactor" style="width:183px"/> <a style="width:10%"></a></td>
<td><a onclick="setadjustfactor()" ><input type="submit" value="按机械分类设置调整系数"/></a></td>
</tr>
</fieldset>
</div>
</div>







下面就是绑定数据的代码;
首先要从数据库里面查出数据才能进行绑定
第一步:存储过程



第二步:
//这是绑定数据逻辑层的代码
public class XianMuShuXing
{
DALPublic.DALMethod nihao = new DALPublic.DALMethod();
public DataTable Selectprojectproperty(int BuildProjectID)
{
SqlParameter[] mySQL = {
new SqlParameter("@type",SqlDbType.Char),//这变量就是存储过层里的@type
new SqlParameter("@BuildProjectID",SqlDbType.Int)
};
mySQL[0].Value = "xingmushuxing";//这第一个数组一定要对应存储过程type类型
mySQL[1].Value = BuildProjectID;
DataTable dt = nihao.DAL_SelectDB_Par("XianMuShuXing", mySQL);
return dt;
}



第三步:


//下面就是控制器的代码

public ActionResult Selectprojectproperty(string BuildProjectID)
{
DataTable dt = xiangmushuxing.Selectprojectproperty(Convert.ToInt32(BuildProjectID));//这就是调用了逻辑层的方法
dt.Columns.Add("BianZhiShiJian1", typeof(string));//这就是在DataTable表格里面增加•一列,列名为BianZhiShiJian1

for (int i = 0; i < dt.Rows.Count; i++)
{
Session["项目属性ID"] = dt.Rows[0]["ProjectNatureID"].ToString();//这就是把从逻辑层里面查出来的数据赋值给全局变量Session["项目属性ID"],
dt.Rows[i]["PlaitTime"] = dt.Rows[i]["PlaitTime"].ToString().Substring(0, 10).Replace(" ","-");//这就是截取日期的长度// Substring(),这就是截取的方法

}
List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);//这就是转成Json格式
return Json(listReturn, JsonRequestBehavior.AllowGet);//返回给界面层
}


第四步: //就是界面层的代码
var i=0;//在这方法外面声明可以在整个界面里都可以用它的值的
function bangdingprojectproperty() {

$.getJSON("/XiangMuShuXing/Selectprojectproperty?BuildProjectID=" + @Session["项目ID"],

function (data) {
i =   data[0].ProjectNatureID;//这就是给它赋值

$('#TXTProjectName').attr('Value', data[0].ProjectName.trim());//这就是给文本赋值的一种方法,还有一种赋值的方法 ,
$('#TXTPlaitPeople').attr('Value', data[0].PlaitPeople.trim());
$('#TXTPlaitPeopleNumber').attr('Value', data[0].PlaitPeopleNumber.trim());

$('#TXTPlaitUnit').attr('Value', data[0].PlaitUnit.trim());
$('#TXTAxaminePeoPle').attr('Value', data[0].AxaminePeoPle.trim());

$('#TXTAxamineAttestation').attr('Value', data[0].AxamineAttestation.trim());
$('#TXTAxamineUnit').attr('Value', data[0].AxamineUnit.trim());
$('#TXTProjectLocation').attr('Value', data[0].ProjectLocation.trim());

$('#TXTProjectAllPrice').attr('value', data[0].ProjectAllPrice.trim());
$('#TXTBuildUnit').attr('Value', data[0].BuildUnit.trim());
$('#TXTBidUnit').attr('Value', data[0].BidUnit.trim());
$('#TXTSupervisionUnit').attr('Value', data[0].SupervisionUnit.trim());
$('#DTPlaitTime').datebox('setValue', data[0].PlaitTime.trim());//这就是给日期设置值得方法

$('#TXTCountFurmula').val( data[0].CountFurmula.trim());
$('#TXTManpowerFactor').attr('Value', data[0].ManpowerFactor.trim());//这就是文本赋值得令一种方法
$('#TXTMachineFactor').attr('Value', data[0].MachineFactor.trim());
$('#TXTMaterialFacto').attr('Value', data[0].MaterialFacto.trim());

});
}




绑定完的数据就要对它进行修改
第一步:存储过程



第二步:就到逻辑层。修改

public int Updateprojectproperty(int 项目属性ID, int BuildProjectID, string ProjectName, string PlaitPeople,
string PlaitPeopleNumber, string PlaitUnit, string AxaminePeoPle, string AxamineAttestation,
string AxamineUnit, string ProjectLocation, string ProjectAllPrice, string BuildUnit, string BidUnit,
string SupervisionUnit, DateTime PlaitTime, string CountFurmula, string ManpowerFactor,
string MachineFactor, string MaterialFacto)
{

SqlParameter[] mySQL = {
new SqlParameter("@type",SqlDbType.Char),

new SqlParameter("@ProjectName",SqlDbType.Char),
new SqlParameter("@PlaitPeople",SqlDbType.Char),
new SqlParameter("@PlaitPeopleNumber",SqlDbType.Char),
new SqlParameter("@PlaitUnit",SqlDbType.Char),
new SqlParameter("@AxaminePeoPle",SqlDbType.Char),
new SqlParameter("@AxamineAttestation",SqlDbType.Char),
new SqlParameter("@AxamineUnit",SqlDbType.Char),
new SqlParameter("@ProjectLocation",SqlDbType.Char),

new SqlParameter("@ProjectAllPrice",SqlDbType.Char),
new SqlParameter("@BuildUnit",SqlDbType.Char),
new SqlParameter("@BidUnit",SqlDbType.Char),
new SqlParameter("@SupervisionUnit",SqlDbType.Char),
new SqlParameter("@PlaitTime",SqlDbType.DateTime),

new SqlParameter("@CountFurmula",SqlDbType.Char),
new SqlParameter("@ManpowerFactor",SqlDbType.Char),
new SqlParameter("@MachineFactor",SqlDbType.Char),
new SqlParameter("@MaterialFacto",SqlDbType.Char),
new SqlParameter("@BuildProjectID",SqlDbType.Int),
new SqlParameter("@ProjectNatureID",SqlDbType.Int),

};
mySQL[0].Value = "UPDATEXIANGMUSHUXING";//对应存储过程里面的@type类型才可以被调用
mySQL[1].Value = ProjectName;
mySQL[2].Value = PlaitPeople;
mySQL[3].Value = PlaitPeopleNumber;
mySQL[4].Value = PlaitUnit;
mySQL[5].Value = AxaminePeoPle;
mySQL[6].Value = AxamineAttestation;
mySQL[7].Value = AxamineUnit;
mySQL[8].Value = ProjectLocation;
mySQL[9].Value = ProjectAllPrice;
mySQL[10].Value = BuildUnit;

mySQL[11].Value = BidUnit;
mySQL[12].Value = SupervisionUnit;
mySQL[13].Value = PlaitTime;
mySQL[14].Value = CountFurmula;
mySQL[15].Value = ManpowerFactor;
mySQL[16].Value = MachineFactor;
mySQL[17].Value = MaterialFacto;
mySQL[18].Value = BuildProjectID;
mySQL[19].Value = 项目属性ID;
int i = nihao.DAL_OPTableDB_Par("XianMuShuXing", mySQL);
return i;
}
第二步:就到逻辑层。新增
//在下面是新增数据逻辑层的代码
public int Insertprojectproperty(int BuildProjectID, string ProjectName,
string PlaitPeople, string PlaitPeopleNumber, string PlaitUnit,
string AxaminePeoPle, string AxamineAttestation, string AxamineUnit,
string ProjectLocation, string ProjectAllPrice, string BuildUnit, string BidUnit
, string SupervisionUnit, DateTime PlaitTime, string CountFurmula,
string ManpowerFactor, string MachineFactor, string MaterialFacto)
{

SqlParameter[] mySQL = {
new SqlParameter("@type",SqlDbType.Char),

new SqlParameter("@ProjectName",SqlDbType.Char),
new SqlParameter("@PlaitPeople",SqlDbType.Char),
new SqlParameter("@PlaitPeopleNumber",SqlDbType.Char),
new SqlParameter("@PlaitUnit",SqlDbType.Char),
new SqlParameter("@AxaminePeoPle",SqlDbType.Char),
new SqlParameter("@AxamineAttestation",SqlDbType.Char),
new SqlParameter("@AxamineUnit",SqlDbType.Char),
new SqlParameter("@ProjectLocation",SqlDbType.Char),

new SqlParameter("@ProjectAllPrice",SqlDbType.Char),
new SqlParameter("@BuildUnit",SqlDbType.Char),
new SqlParameter("@BidUnit",SqlDbType.Char),
new SqlParameter("@SupervisionUnit",SqlDbType.Char),
new SqlParameter("@PlaitTime",SqlDbType.Char),

new SqlParameter("@CountFurmula",SqlDbType.Char),
new SqlParameter("@ManpowerFactor",SqlDbType.Char),
new SqlParameter("@MachineFactor",SqlDbType.Char),
new SqlParameter("@MaterialFacto",SqlDbType.Char),
new SqlParameter("@BuildProjectID",SqlDbType.Int),

};
mySQL[0].Value = "Inserxiangmushuxing";//对应存储过程里面的@type类型才可以被调用

mySQL[1].Value = ProjectName;
mySQL[2].Value = PlaitPeople;
mySQL[3].Value = PlaitPeopleNumber;
mySQL[4].Value = PlaitUnit;
mySQL[5].Value = AxaminePeoPle;
mySQL[6].Value = AxamineAttestation;
mySQL[7].Value = AxamineUnit;
mySQL[8].Value = ProjectLocation;
mySQL[9].Value = ProjectAllPrice;
mySQL[10].Value = BuildUnit;

mySQL[11].Value = BidUnit;
mySQL[12].Value = SupervisionUnit;
mySQL[13].Value = PlaitTime;
mySQL[14].Value = CountFurmula;
mySQL[15].Value = ManpowerFactor;
mySQL[16].Value = MachineFactor;
mySQL[17].Value = MaterialFacto;
mySQL[18].Value = BuildProjectID;
int i = nihao.DAL_OPTableDB_Par("XianMuShuXing", mySQL);// ‘XianMuShuXing’就是存储过程名
return i;
}
第三步 就到控制器。修改
public ContentResult Updateprojectproperty(string 项目属性ID, string BuildProjectID, string ProjectName, string PlaitPeople, string PlaitPeopleNumber, string PlaitUnit, string AxaminePeoPle, string AxamineAttestation, string AxamineUnit, string ProjectLocation, string ProjectAllPrice, string BuildUnit, string BidUnit, string SupervisionUnit, DateTime PlaitTime, string CountFurmula, string ManpowerFactor, string MachineFactor, string MaterialFacto)
{
int i = xiangmushuxing.Updateprojectproperty(Convert.ToInt32(项目属性ID), Convert.ToInt32(BuildProjectID), ProjectName, PlaitPeople, PlaitPeopleNumber, PlaitUnit,
AxaminePeoPle, AxamineAttestation, AxamineUnit,
ProjectLocation, ProjectAllPrice, BuildUnit, BidUnit
, SupervisionUnit, Convert.ToDateTime(PlaitTime), CountFurmula.Replace(" ","+"), ManpowerFactor, MachineFactor, MaterialFacto);
string k = i.ToString();
return Content(k);//这就是返回给界面的值,用它来可以判断是否修改成功还是失败

}

第三步 就到控制器。新增

public ContentResult Insertprojectproperty(string BuildProjectID, string ProjectName, string PlaitPeople, string PlaitPeopleNumber, string PlaitUnit,
string AxaminePeoPle, string AxamineAttestation, string AxamineUnit,
string ProjectLocation, string ProjectAllPrice, string BuildUnit, string BidUnit
, string SupervisionUnit, DateTime PlaitTime, string CountFurmula, string ManpowerFactor, string MachineFactor, string MaterialFacto)
{
int i = xiangmushuxing.Insertprojectproperty(Convert.ToInt32(BuildProjectID), ProjectName, PlaitPeople, PlaitPeopleNumber, PlaitUnit,
AxaminePeoPle, AxamineAttestation, AxamineUnit,
ProjectLocation, ProjectAllPrice, BuildUnit, BidUnit
, SupervisionUnit, PlaitTime, CountFurmula.Replace(" ","+"), ManpowerFactor, MachineFactor, MaterialFacto);
string k = i.ToString();
return Content(k);//这就是返回给界面的值,也是在界面用来判断它是否新增成功
}
第四步 就到界面层、新增或修改

//下面就是在控制器返回值用来判断是新增还是修改的代码

public ActionResult Selectprojectproperty1(string BuildProjectID)
{
DataTable dt = xiangmushuxing.Selectprojectproperty(Convert.ToInt32(BuildProjectID));//这方法就是上面那个查询出数据然后绑定给项目属性每一个文本的方法。
if (dt.Rows.Count > 0)//这就是查出数据如果大于0,就说明数据库里面有着一条数据,那么就把1,返回给界面,对数据进行修改,否则就把0,返回给界面进行新增。
{
return Content("1");//
}
else
{
return Content("0");

}

}

//下面就是界面层通过返回的数据是1就是修改,是0就是新增的操作;
//点击之后判断是否新增还是修改
function save(){

$.getJSON("/XiangMuShuXing/Selectprojectproperty1?BuildProjectID=" + @Session["项目ID"],
function (data) {//这就是查询数据库,看数据库是否有一条数据,如果有一条数据就进行修改,没有就新增

if(data==1){

if (confirm('修改项目属性?')) {

$.getJSON("/XiangMuShuXing/Updateprojectproperty?项目属性ID="+i+"&"//i就是上面声明的变量
+ "BuildProjectID="+ @Session["项目ID"]+"&"
+"ProjectName=" + $('#TXTProjectName').val() + "&"
+ "PlaitPeople=" + $('#TXTPlaitPeople').val() + "&"
+ "PlaitPeopleNumber=" + $('#TXTPlaitPeopleNumber').val() + "&"
+ "PlaitUnit=" + $('#TXTPlaitUnit').val() + "&"
+ "AxaminePeoPle=" +  $('#TXTAxaminePeoPle').val() + "&"
+ "AxamineAttestation=" +$('#TXTAxamineAttestation').val() + "&"
+ "AxamineUnit=" +$('#TXTAxamineUnit').val() + "&"
+ "ProjectLocation=" +$('#TXTProjectLocation').val() + "&"
+ "ProjectAllPrice=" + $('#TXTProjectAllPrice').val() + "&"
+ "BuildUnit=" + $('#TXTBuildUnit').val()+"&"
+ "BidUnit=" + $('#TXTBidUnit').val() + "&"
+ "SupervisionUnit=" + $('#TXTSupervisionUnit').val() + "&"
+ "PlaitTime=" + $('#DTPlaitTime').datebox('getValue') + "&"
+ "CountFurmula=" +  $('#TXTCountFurmula').val() + "&"
+ "ManpowerFactor=" +  $('#TXTManpowerFactor').val() + "&"
+ "MachineFactor=" +   $('#TXTMachineFactor').val() + "&"
+ "MaterialFacto=" +   $('#TXTMaterialFacto').val() + "&",
function (data) {
if (data > 0) {
alert("修改成功");

}
else { alert("修改失败") }

});
}

}else{

if (confirm('添加项目属性?')) {
$.getJSON("/XiangMuShuXing/Insertprojectproperty?BuildProjectID="+ @Session["项目ID"]+"&"
+"ProjectName=" + $('#TXTProjectName').val() + "&"
+ "PlaitPeople=" + $('#TXTPlaitPeople').val() + "&"
+ "PlaitPeopleNumber=" + $('#TXTPlaitPeopleNumber').val() + "&"
+ "PlaitUnit=" + $('#TXTPlaitUnit').val() + "&"
+ "AxaminePeoPle=" +  $('#TXTAxaminePeoPle').val() + "&"
+ "AxamineAttestation=" +  $('#TXTAxamineAttestation').val() + "&"
+ "AxamineUnit=" +   $('#TXTAxamineUnit').val() + "&"
+ "ProjectLocation=" +   $('#TXTProjectLocation').val() + "&"
+ "ProjectAllPrice=" +   $('#TXTProjectAllPrice').val() + "&"
+ "BuildUnit=" +   $('#TXTBuildUnit').val()+"&"

+ "BidUnit=" + $('#TXTBidUnit').val() + "&"
+ "SupervisionUnit=" + $('#TXTSupervisionUnit').val() + "&"
+ "PlaitTime=" + $('#DTPlaitTime').datebox('getValue') + "&"
+ "CountFurmula=" +  $('#TXTCountFurmula').val() + "&"
+ "ManpowerFactor=" +  $('#TXTManpowerFactor').val() + "&"
+ "MachineFactor=" +   $('#TXTMachineFactor').val() + "&"
+ "MaterialFacto=" +   $('#TXTMaterialFacto').val() + "&",

function (data) {
if (data > 0) {

alert("添加成功");
$.getJSON("/XiangMuShuXing/Selectprojectproperty?BuildProjectID=" + @Session["项目ID"],

function (data) {
i =   data[0].ProjectNatureID;});

}
else { alert("添加失败") }

});
}

}

});
}
仅供学习,禁止用于商业用途
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐