admin 管理员组文章数量: 893559
凯云水利水电工程造价管理系统 技术解析(四)取费管理(一)
取费管理
3.7-1 功能实现
取费管理的数据处理主要有:添加、删除、复制、粘贴、导出、导入
取费管理的添加,会弹出一个窗体,里面只有取费分类列表名,而其它的字段可以双击列名为名称和单位那两列时,会弹出一个小窗体,双击小窗体就能添加数据。删除就是选择一行进行删除。
取费管理的复制、粘贴:对现有的数据进行复制、粘贴,为了进行区分,粘贴后的数据,代号会自动跟着”复制“二字,只要是通过最后的几位整数来区分取费分类列表名,不让其重复。
取费管理的导出、导入:系统将自动给出一个路径,把取费的所有数据导入到一张Excel表。导入:先手动填写一些数据,这些数据要根据数据库的参数来写,一一对应才能导入
取费明细的数据处理主要有,添加父节、同级插入、下级插入、升级、删去。
点击添加,他就会自动新增一行数据,我们可以对那一行数据进行一些修改操作,我们还可以对数据做下级插入,同级插入数据,删去数据。
表和关系:
//下面就是生成界面的html代码
<div id="Xa"><tr><td><a οnclick="openwindow()" ><input type="submit" value="添加" /></a></td><td><a οnclick="deleterow()" ><input type="submit" value="删除" /></a></td><td><a οnclick="copyrow()" ><input type="submit" value="复制" /></a></td><td><a οnclick="pasterow()" ><input type="submit" value="粘贴" /></a></td><td><a οnclick="daochu()" ><input type="submit" value="导出" /></a></td><form action="/QuFeiGuanLi/GetTableFromExcel" method="post" enctype="multipart/form-data"> <text>选择上传文件</text><input name="file1" type="file" id="file" /><input type="submit" name="Upload" value="导入" /> </form></tr></div> <div id="as"><tr><td><a οnclick="addparampanelPoint()" ><input type="submit" value="添加" /></a></td><td><a οnclick="deletree()" ><input type="submit" value="删除" /></a></td><td><a οnclick="togetherInsert()" ><input type="submit" value="同级插入" /></a></td><td><a οnclick="belowInsert()" ><input type="submit" value="下级插入" /></a></td><td><a οnclick="Upgrade()" ><input type="submit" value="升级" /></a></td><td><a οnclick="Demotion()" ><input type="submit" value="降级" /></a></td><td><a οnclick="ModificationALine()" ><input type="submit" value="修改一行" /></a></td> </tr></div><div ><table style="margin-top:0px;padding-top:0px;"><tr><td><table id="getpriceclasify" class="easyui-datagrid" title="取费分类列表" data-options="onClickRow:onClickRowxin,onDblClickRow:onDblClickRow,singleSelect:true,onRowContextMenu:onRowContextMenu2,toolbar:'#Xa'" style="width:500px;height:480px;padding-left:0px;background-color: #00FFFF"><thead frozen="true"><tr><th data-options="field:'BuildProjectID',width:80,hidden:true" >建立项目ID</th><th field="GetPriceClassifyID" hidden="true">取费分类列表ID</th><th field="QuoteEditionID" hidden="true">定额ID</th><th field="GetPriceClassifyName" width="150">取费分类列表</th></tr></thead><thead> <tr ><th colspan="3" ><div class="datagrid-cell-group" style="width:350px">调整系数</div></th></tr><tr><th data-options="field:'AdjustFactorID',width:80,hidden:true" >高程调整系数ID</th><th field="ManpowerFactor" width="120" align="center">人工系数</th><th field="MaterialFacto" width="120" align="center">材料系数</th><th field="MachineFactor" width="120" align="center">机械系数</th></tr></thead> </table></td><td> <div class="easyui-panel" style="width:800px;height:480px; background-color: #D5F9F2; font-size:12px;" data-options="noheader:true"> 费用明细表 <a οnclick="CalculateFormula1()" class="easyui-linkbutton">设置计算单价公式</a> <input id="CalculateFormula" style="width:150px"/><table id="Tbl_treedetailed" class="easyui-treegrid" style="width:800px;height:400px"data-options="iconCls: 'icon-ok',rownumbers: true,animate: true,collapsible: true, onClickRow:onClickRowdetailed,onAfterEdit:onAfter,onHeaderContextMenu:onRowContextMenu2,fitColumns:true,lines:true, idField: 'id', treeField: 'text',toolbar:'#as'"><thead> <tr> <th data-options="field:'rr',width:30" ></th><th data-options="field:'text',width:60,align:'center',editor:'text'">名称</th> <th data-options="field:'id',width:80,hidden:true" >取费明细ID</th><th data-options="field:'GetPriceClassifyID',width:80,align:'center',hidden:true">取费分类列表ID</th><th data-options="field:'GetPriceNumber',width:60,align:'center',editor:'text'">编号</th> <th data-options="field:'Unit',align:'center',width:60,formatter:formatterUnit,editor:{type:'combobox',options:{ valueField:'NatureGatherDetailID',textField:'NatureGatherDetailName',url:'/QuFeiGuanLi/boundGetPricedetailed/'}}"> 单位</th> <th data-options="field:'CountBase',width:80,align:'center',formatter:treedetailed_Text">计算基础</th> <th data-options="field:'Rate',width:60,arign:'center',editor:'text'">费率</th><th data-options="field:'IfPrint',width:50,arign:'center',formatter:IfPrint" >是否打印</th> </tr></thead> </table> </div></td></tr><br /></table> </div>
//下面就是一打开项目就开始查询取费分类列表的代码
//第一步-存储过程
第二步:逻辑层查询取费分类列表
DALPublic.DALMethod getprice = new DALPublic.DALMethod();//引用DAL层的代码// 执行查询取费分类列表public DataTable Selectgetprice(int Int_BuildProjectID, int Int_QuoteEditionID){SqlParameter[] mySQL = {new SqlParameter("@type",SqlDbType.Char), new SqlParameter("@BuildProjectID",SqlDbType.Int),new SqlParameter("@QuoteEditionID",SqlDbType.Int),};mySQL[0].Value = "Selectgetprice";//这第一个数组要对应存储过程里面的@type类型mySQL[1].Value = Int_BuildProjectID;mySQL[2].Value = Int_QuoteEditionID;DataTable dt = getprice.DAL_SelectDB_Par("GetPriceManage", mySQL);return dt;}
//第三步;到控制器查询取费分类
// 执行查询取费分类列表public ActionResult Selectgetprice(string Int_BuildProjectID, string Int_QuoteEditionID){DataTable dt = getprice.Selectgetprice(Convert.ToInt32(Int_BuildProjectID), Convert.ToInt32(Int_QuoteEditionID));//这就是获取逻辑层返回的值List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);//就是把从逻辑层传过来的值转换成json格式 return Json(listReturn, JsonRequestBehavior.AllowGet);返回给界面层}
//下面就是查询取费分类列表界面层的代码
//一进来就执行查询取费分类列表function GetPriceClassifyInquire() { $.getJSON("/QuFeiGuanLi/Selectgetprice/?Int_BuildProjectID="+@Session["项目ID"]+"&"+"Int_QuoteEditionID="+ @Session["QuoteEditionID"],function (data) {$('#getpriceclasify').datagrid('loadData', data); //data就是从控制器返回的值//这就是把数据绑定给指定的datagrid});}
//下面就是取费分类列表添加的窗体
//下面就是弹出那个窗体生成界面的html代码:
<div id="Pnl_add"class="easyui-window" style="width:400px;height:200px;top:50px;left:500px" ><table style="width:300px;height:100px"><tr> <td style="width:10px"></td><td>分类列表名称:<input id="Txt_getpricename" /></td></tr><tr><td style="width:10px"></td><td><input type="submit"value="确定" οnclick="comfrim()"/></td><td><input type="submit"value="取消" οnclick="cancel()"/></td> </tr></table></div>
//第一步:接下来就开始写一些添加的存储过程了
//第二步就到了逻辑层添加取费分类了
public int comfrim_addClasssify(string Str_GetPriceClassifyName, int Int_BuildProjectID){SqlParameter[] mySQL = {new SqlParameter("@type",SqlDbType.Char), new SqlParameter("@GetPriceClassifyName",SqlDbType.Char),// new SqlParameter("@BuildProjectID",SqlDbType.Int), };mySQL[0].Value = "comfrim_addClasssify";//这类型一定要对应存储过程的@typemySQL[1].Value = Str_GetPriceClassifyName;mySQL[2].Value = Int_BuildProjectID;int i = getprice.DAL_OPTableDB_Par("GetPriceManage", mySQL);//这就是存储过程名GetPriceManagereturn i;}
//第三步就到了控制器添加取费分类
//点击确定添加分类列表
public ContentResult comfrim_addClasssify(string Str_GetPriceClassifyName, string Int_BuildProjectID){int i = getprice.comfrim_addClasssify(Str_GetPriceClassifyName, Convert.ToInt32(Int_BuildProjectID));//这就是添加成功就从数据库返回的一个1,失败就返回-1,0string k = i.ToString();//这相当于把数据转换成字符窜return Content(k);//这就是把那个值返回给界面}
// 第四步就到了界面层
//点击确定进行添加分类列表var AddPanDuan=0;function comfrim(){for(var i=0;i<$('#getpriceclasify').datagrid('getData').rows.length;i++){//这是把datagrid里面的行全部循环出来 if($('#getpriceclasify').datagrid('getData').rows[i]["GetPriceClassifyName"].trim()==$('#Txt_getpricename').val().trim()){ AddPanDuan=1//这就是用来判断的,如果它等于1,就说明它有重复}else{AddPanDuan=0;//等于0就没有重复}}if(AddPanDuan==0){$.getJSON("/QuFeiGuanLi/comfrim_addClasssify?Str_GetPriceClassifyName="+$('#Txt_getpricename').val()+"&"+"Int_BuildProjectID="+@Session["项目ID"],function(data){ if(data>0){//data这就是控制器传回来的1,0,-1,如果大于0,就添加成功,否则就添加失败alert("添加成功");AddPanDuan=0;//添加成功$('#Pnl_add').window('close');//添加完成就关闭窗体$.getJSON("/QuFeiGuanLi/Selectgetprice/?Int_BuildProjectID="+@Session["项目ID"]+"&"+"Int_QuoteEditionID="+ @Session["QuoteEditionID"],function (data) {$('#getpriceclasify').datagrid('loadData', data); //这就是查出数据给相应的datagrid赋值});}else{Alert("添加失败");
} });}else{AddPanDuan=0;//再次清0;下次执行这方法还是0开始alert("名称重复,不能添加");}}
//下面就是取费分类列表里面的删去
第一步:存储过程的写法
第二步就到了逻辑层写删去的代码
//删去取费分类public int deleterow(int Int_GetPriceClassifyID){SqlParameter[] mySQL = {new SqlParameter("@type",SqlDbType.Char), new SqlParameter("@GetPriceClassifyID",SqlDbType.Int),};mySQL[0].Value = "deleterow";//这类型要对应存储过程的@type类型,他才能找到你要执行的存储过程mySQL[1].Value = Int_GetPriceClassifyID;int i = getprice.DAL_OPTableDB_Par("GetPriceManage", mySQL);//这就是存储过程名GetPriceManagereturn i;}
//第三步就到了控制器写删去的代码
//删去取费分类public ContentResult deleterow(string Int_GetPriceClassifyID){int i = getprice.deleterow(Convert.ToInt32(Int_GetPriceClassifyID));//这就是从逻辑层返回的值如果它为1,就是删去成功,否则为0,-1就删去失败string k = i.ToString();return Content(k);//这就是返回给界面的值}
//第四步就到了界面层
//删去取费分类function deleterow(){//deleterow()这方法是写在删去按钮的点击事件里面的if($('#getpriceclasify').datagrid('getSelected').QuoteEditionID==null){//这是用来判断,如果数据是自己设定的定额,是不能删的,那么就不能删去,所以就要判断来限制$.getJSON("/QuFeiGuanLi/deleterow?Int_GetPriceClassifyID="+ $('#getpriceclasify').datagrid('getSelected').GetPriceClassifyID,function(data){ if(data>0){这就是在控制器传回来的值,如果等于1,就说明删去成功,小于1,就失败alert("删去成功");$.getJSON("/QuFeiGuanLi/Selectgetprice/?Int_BuildProjectID="+@Session["项目ID"]+"&"+"Int_QuoteEditionID="+ @Session["QuoteEditionID"],function (data) {//删去完一行数据就进行查询$('#getpriceclasify').datagrid('loadData', data); //这就是把值绑定给相应的datagrid});}else{alert("删去失败");
} }); }else{alert("不能删去定额取费");}}
//接下来就到了复制
//复制取费分类var GetPriceClassifyName="";//方法外声明就是这个界面的全局变量var AdjustFactorID="";var copy7=0;function copyrow(){//copyrow()这方法是写在复制按钮的点击时间里面的if($('#getpriceclasify').datagrid('getSelected').AdjustFactorID!=null){//这是用来判断如果调整系数的ID不为空才能复制,因为在我这系统里面,粘贴一定要用到调整系数ID,如果它为null,粘贴就会出错GetPriceClassifyName = $('#getpriceclasify').datagrid('getSelected').GetPriceClassifyName;//复制名称赋值给这个界面的全局变量GetPriceClassifyNameAdjustFactorID =$('#getpriceclasify').datagrid('getSelected').AdjustFactorID;//复制调整系数的ID,赋值给这个界面的全局变量AdjustFactorID alert("复制成功");copy7=1;//这是用来判断它是否复制了,如果没有复制就不能粘贴}else{alert("请导入调整系数");}}
//复制完就到粘贴的代码
// 第一步;就是粘贴存储过程的代码
第二步:粘贴的逻辑层的代码
public int pasterow(int Str_AdjustFactorID, string Str_GetPriceClassifyName, int Int_BuildProjectID){SqlParameter[] mySQL = {new SqlParameter("@type",SqlDbType.Char), new SqlParameter("@AdjustFactorID",SqlDbType.Int),new SqlParameter("@GetPriceClassifyName",SqlDbType.Char),new SqlParameter("@BuildProjectID",SqlDbType.Int),};mySQL[0].Value = "pasterow";//这类型要对应存储过程的@type类型,他才能找到你要执行的存储过程mySQL[1].Value = Str_AdjustFactorID;mySQL[2].Value = Str_GetPriceClassifyName;mySQL[3].Value = Int_BuildProjectID;int i = getprice.DAL_OPTableDB_Par("GetPriceManage", mySQL);这就是存储过程名GetPriceManagereturn i;}
第三步:就到了控制器
//粘贴取费public ContentResult pasterow(string Str_AdjustFactorID, string Str_GetPriceClassifyName, string Int_BuildProjectID){ int i = getprice.pasterow(Convert.ToInt32(Str_AdjustFactorID), Str_GetPriceClassifyName, Convert.ToInt32(Int_BuildProjectID));//这就是从逻辑层返回的值用它来判断是否粘贴成功string k = i.ToString();return Content(k);//这就是返回给界面的值}
第四步:就到了界面程的粘贴
//下面就回忆一下复制了什么?
//下面就是粘贴复制的行
//粘贴复制的行var pastePanDuan=0; function pasterow(){if(copy7==1){//这是用来判断它是否是复制了,如果没有复制就不能粘贴$.getJSON("/JiXieDanJia/oddnumbers/" ,function (data) { //这是一个查询代号自增的方法var t="_复制_"+data[0].oddnumbers; //这就是把查出来的代号+复制两字var tr= GetPriceClassifyName.trim()+t; //最后再把它们拼接字符窜,合并起来for(var i=0;i<$('#getpriceclasify').datagrid('getData').rows.length;i++){ if($('#getpriceclasify').datagrid('getData').rows[i]["GetPriceClassifyName"]==tr){ pastePanDuan=1//这是用来判断他它是否有重复,如果有重复不能粘贴}else{pastePanDuan=0;}}if(pastePanDuan==0){ if(confirm('是否需要粘贴?')){ $.getJSON("/QuFeiGuanLi/pasterow?Str_AdjustFactorID="+ AdjustFactorID+"&"+"Str_GetPriceClassifyName="+ tr+"&"+"Int_BuildProjectID="+@Session["项目ID"],function(data){ alert("粘贴成功");copy7=0;//粘贴完有要请0,这样可以方便下次,不复制就不能粘贴 $.getJSON("/QuFeiGuanLi/Selectgetprice/?Int_BuildProjectID="+@Session["项目ID"]+"&"+"Int_QuoteEditionID="+ @Session["QuoteEditionID"],function (data) {//粘贴完进行一遍查询$('#getpriceclasify').datagrid('loadData', data); //把查出来的数据绑定到相应的datagrid;});}); }}else{pastePanDuan=0;//如果有重复,就是为了要区分下一次粘贴,又要重0开始;alert("这次粘贴有重复取费列表名,请再次粘贴");}}); }else{alert("请先复制");}}
//接下来就到了导出:
界面层的代码:
<td><a οnclick="DaoChu()" ><input type="submit" value="导出" /></a></td>
function DaoChu() { window.location.href="/QuFeiGuanLi/DownloadFile/?Int_BuildProjectID="+@Session["项目ID"]+"&"+"Int_QuoteEditionID="+ @Session["QuoteEditionID"];//这是一个连接跳到控制器}
//第二步;控制器 public FileResult DownloadFile(string Int_BuildProjectID, string Int_QuoteEditionID){DataSet ds = new DataSet();DataTable dt = getprice.ForUpLoad(Convert.ToInt32(Int_BuildProjectID), Convert.ToInt32(Int_QuoteEditionID));//这是调用逻辑层的方法,获取从数据库查出来的数据,然后将其导出//ds.Tables.Add(dt);//创建Excel文件的对象NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();//添加一个sheetNPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");//获取list数据//List<TB_STUDENTINFOModel> listRainInfo = dt.t(schoolname);//给sheet1添加第一行的头部标题NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);for (int i = 0; i < dt.Columns.Count; i++){row1.CreateCell(i).SetCellValue(dt.Columns[i].ColumnName);}//将数据逐步写入sheet1各个行for (int i = 0; i < dt.Rows.Count; i++){NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);for (int j = 0; j < dt.Columns.Count; j++){rowtemp.CreateCell(j).SetCellValue(dt.Rows[i][j].ToString().Trim());}}// 写入到客户端 System.IO.MemoryStream ms = new System.IO.MemoryStream();book.Write(ms);ms.Seek(0, SeekOrigin.Begin);return File(ms, "application/vnd.ms-excel", "导出.xls");}
第三步:逻辑层
public DataTable ForUpLoad(int Int_BuildProjectID, int Int_QuoteEditionID){SqlParameter[] mySQL = {new SqlParameter("@type",SqlDbType.Char), new SqlParameter("@BuildProjectID",SqlDbType.Int),new SqlParameter("@QuoteEditionID",SqlDbType.Int),};mySQL[0].Value = "Selectgetpriceleadout";mySQL[1].Value = Int_BuildProjectID;mySQL[2].Value = Int_QuoteEditionID;DataTable dt = getprice.DAL_SelectDB_Par("GetPriceManage", mySQL);return dt;//从数据库把数据给查出来,返回给控制器}
第四步:导出的存储过程
//下面就是导入界面程的代码
第一步:界面代码
<form action="/QuFeiGuanLi/GetTableFromExcel" method="post" enctype="multipart/form-data"><text>选择上传文件</text><input name="file1" type="file" id="file" /><input type="submit" name="Upload" value="导入" /></form>
//第二步:导入控制器的代码;
//导入代码public ActionResult GetTableFromExcel(){try{HttpPostedFileBase fostFile = Request.Files["file1"];Stream streamfile = fostFile.InputStream;if (streamfile == null){return Content("1");}else{HSSFWorkbook hssfworkbook = new HSSFWorkbook(streamfile);using (NPOI.SS.UserModel.ISheet sheet = hssfworkbook.GetSheetAt(0)){DataTable table = new DataTable();IRow headerRow = sheet.GetRow(0);//第一行为标题行int cellCount = headerRow.LastCellNum;//LastCellNum = PhysicalNumberOfCellsint rowCount = sheet.LastRowNum;//LastRowNum = PhysicalNumberOfRows - 1//handling header.for (int i = headerRow.FirstCellNum; i < cellCount; i++){DataColumn column = new DataColumn(headerRow.GetCell(i).StringCellValue);table.Columns.Add(column);}for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++){IRow row = sheet.GetRow(i);DataRow dataRow = table.NewRow();if (row != null){for (int j = row.FirstCellNum; j < cellCount; j++){if (row.GetCell(j) != null)dataRow[j] = GetCellValue(row.GetCell(j));}}table.Rows.Add(dataRow);}for (int i = 0; i < table.Rows.Count; i++){getprice.ForDownLoad(table.Rows[i][0].ToString(), Convert.ToInt32(table.Rows[i][4]), Convert.ToInt32(table.Rows[i][7]));//这就是调用逻辑层的方法,将这些数据增加进数据库}}return Content("");}}catch {return Content("");}}private static string GetCellValue(ICell cell){if (cell == null)return string.Empty;switch (cell.CellType){case CellType.BLANK:return string.Empty;case CellType.BOOLEAN:return cell.BooleanCellValue.ToString();case CellType.ERROR:return cell.ErrorCellValue.ToString();case CellType.NUMERIC:case CellType.Unknown:default:return cell.ToString();case CellType.STRING:return cell.StringCellValue;case CellType.FORMULA:try{HSSFFormulaEvaluator e = new HSSFFormulaEvaluator(cell.Sheet.Workbook);e.EvaluateInCell(cell);return cell.ToString();}catch{return cell.NumericCellValue.ToString();}}}
第三步:逻辑层的代码:
public int ForDownLoad(string GetPriceClassifyName, int AdjustFactorID, int BuildProjectID){SqlParameter[] SQlCMDpas = {new SqlParameter("@type", SqlDbType.Char),new SqlParameter("@GetPriceClassifyName", SqlDbType.Char),new SqlParameter("@AdjustFactorID",SqlDbType.Int),new SqlParameter("@BuildProjectID",SqlDbType.Int),};SQlCMDpas[0].Value = "tolead";//这类型一定要对应存储过程@type类型SQlCMDpas[1].Value = GetPriceClassifyName;SQlCMDpas[2].Value = AdjustFactorID;SQlCMDpas[3].Value = BuildProjectID;int i = getprice.DAL_OPTableDB_Par("GetPriceManage", SQlCMDpas);//这就是把数据传回数据库,进行新增return i;}
第四步:存储过程新增的写法
仅用于学习,禁止用于商业用途
本文标签: 凯云水利水电工程造价管理系统 技术解析(四)取费管理(一)
版权声明:本文标题:凯云水利水电工程造价管理系统 技术解析(四)取费管理(一) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1687330602h90336.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论