private ArrayList AlterBitumenDetachSql(alterBitumenExpenditureClass info, DataTable tempDetachDt) { CostCountDB costCountDB = new CostCountDB(); ArrayList sqlStr = new ArrayList(); double dSum = 0; string sumMoney = info.money.ToString(); tempDetachDt.Columns.Add("比例"); for (int i = 0; i < tempDetachDt.Rows.Count; i++) { dSum += Double.Parse(tempDetachDt.Rows[i]["工时"].ToString()); } for (int i = 0; i < tempDetachDt.Rows.Count; i++) { info.pId = tempDetachDt.Rows[i]["pId"].ToString(); info.eiId = tempDetachDt.Rows[i]["eiId"].ToString(); info.money = (StrtoDouble(sumMoney) * (StrtoDouble(tempDetachDt.Rows[i]["工时"].ToString()) / dSum)).ToString(); info.isFromDetach = "1"; sqlStr.Add(costCountDB.insertExpenditure(info)); } ArrayList fields = new ArrayList(); ArrayList values = new ArrayList(); ArrayList conds = new ArrayList(); fields.Add("isDetach"); values.Add("1"); conds.Add("id=" + info.id); sqlStr.Add(costCountDB.UpdateTeble("alterBitumenWaitDetachExpenditure", fields, values, conds)); return(sqlStr); }
// 向datatable中加行 // 向表中添加一行然后返回表用于放到逻辑层进行判断用以确定是存入费用表还是待摊费用表 private DataTable AddDateTable() { if ((!cmbEquipmentName.Text.Trim().Equals("")) && (!cmbEquipmentName.Text.Trim().Equals(""))) { alterBitumenExpenditureClass info = new alterBitumenExpenditureClass(); info = GetValueExpenditure(); DataRow row = tempDataTable.NewRow(); ExpenditureToDataRow(info, ref row); tempDataTable.Rows.Add(row); } else { alterBitumenWaitDetachExpenditureClass waitDetachInfo = new alterBitumenWaitDetachExpenditureClass(); waitDetachInfo = GetValueWaitDetachExpenditure(); DataRow row1 = tempDataTable.NewRow(); WaitDetachExpenditureToDataRow(waitDetachInfo, ref row1); tempDataTable.Rows.Add(row1); } return(tempDataTable); }
//窗体上的值装入实体类expenditureClass private alterBitumenExpenditureClass GetValueExpenditure() { alterBitumenExpenditureClass recInfo = new alterBitumenExpenditureClass(); recInfo.ekId = cmbExpenditureSort.SelectedValue == null ? null : cmbExpenditureSort.SelectedValue.ToString(); recInfo.enId = cmbExpenditureName.SelectedValue == null ? null : cmbExpenditureName.SelectedValue.ToString(); recInfo.ecId = cmbExpenditureDetail.SelectedValue == null ? null : cmbExpenditureDetail.SelectedValue.ToString(); recInfo.eiId = cmbEquipmentName.SelectedValue == null ? null : cmbEquipmentName.SelectedValue.ToString(); recInfo.expenditureDepict = cmbExpenditureDepict.Text; recInfo.year = cmbYear.Text; recInfo.month = cmbMonth.Text; recInfo.pId = cmbProductName.SelectedValue == null ? null : cmbProductName.SelectedValue.ToString(); recInfo.unitPrice = cmbExpenditureUnitPrice.Text; recInfo.number = upDownExpenditureQuantity.Value.ToString(); recInfo.money = cmbExpenditureMoney.Text; recInfo.inputDate = dateTimePicker1.Value.ToString(); recInfo.inputMan = "测试"; recInfo.convert = cmbConvertQuotiety.Text; recInfo.remark = richTextRemark.Text; return(recInfo); }
/* * 方法名称:ExpenditureToDataRow * 方法功能描述:实体类信息转换为DataRow * 参数: * * * 创建人:付中华 * 创建时间:2009-03-25 * * 修改人: * 修改时间: * 修改内容: * */ public void ExpenditureToDataRow(alterBitumenExpenditureClass info, ref DataRow dr) { dr["id"] = info.id == null ? "" : info.id; dr["ekId"] = info.ekId == null ? "" : info.ekId; dr["enId"] = info.enId == null ? "" : info.enId; dr["ecId"] = info.ecId == null ? "" : info.ecId; dr["expenditureDepict"] = info.expenditureDepict == null ? "" : info.expenditureDepict; dr["year"] = info.year == null ? "" : info.year; dr["month"] = info.month == null ? "" : info.month; dr["eiId"] = info.eiId == null ? "" : info.eiId; dr["pId"] = info.pId == null ? "" : info.pId; dr["number"] = info.number == null ? "" : info.number; dr["unitPrice"] = info.unitPrice == null ? "" : info.unitPrice; dr["money"] = info.money == null ? "" : info.money; dr["inputDate"] = info.inputDate == null ? "" : info.inputDate; dr["inputMan"] = info.inputMan == null ? "" : info.inputMan; dr["convert"] = info.convert == null ? "" : info.convert; dr["remark"] = info.remark == null ? "" : info.remark; dr["费用类别"] = cmbExpenditureSort.Text; dr["费用名称"] = cmbExpenditureName.Text; dr["费用明细"] = cmbExpenditureDetail.Text; dr["设备名称"] = cmbEquipmentName.Text; dr["产品名称"] = cmbProductName.Text; }
// 改性沥青和乳化沥青 public bool ExAlterBitumenDetachData(DataGridView grid, DataTable DetachDt, bool isSelected) { ArrayList sqlStr = new ArrayList(); if (isSelected == false) { for (int i = 0; i < grid.Rows.Count; i++) { //确定分配基数,分滩是否能确定设备 DataTable tempDetachDt = new DataTable(); tempDetachDt.Columns.Add("pId"); tempDetachDt.Columns.Add("设备编号"); tempDetachDt.Columns.Add("eiId"); tempDetachDt.Columns.Add("工时"); if (grid.Rows[i].Cells["eiId"].Value.ToString().Trim().Equals("")) { tempDetachDt = DetachDt; } else { for (int j1 = 0; j1 < DetachDt.Rows.Count; j1++) { if (DetachDt.Rows[j1]["eiId"].ToString().Trim().Equals(grid.Rows[i].Cells["eiId"].Value.ToString().Trim())) { DataRow row = tempDetachDt.NewRow(); row["pid"] = DetachDt.Rows[j1]["pid"].ToString(); row["设备编号"] = DetachDt.Rows[j1]["设备编号"].ToString(); row["eiId"] = DetachDt.Rows[j1]["eiId"].ToString(); row["工时"] = DetachDt.Rows[j1]["工时"].ToString(); tempDetachDt.Rows.Add(row); } } } /////////////////////////////////// alterBitumenExpenditureClass info = new alterBitumenExpenditureClass(); info.id = grid.Rows[i].Cells["Id"].Value.ToString(); info.ekId = grid.Rows[i].Cells["ekId"].Value.ToString(); info.enId = grid.Rows[i].Cells["enId"].Value.ToString(); info.ecId = grid.Rows[i].Cells["ecId"].Value.ToString(); info.expenditureDepict = grid.Rows[i].Cells["费用描述"].Value.ToString(); info.year = grid.Rows[i].Cells["年"].Value.ToString(); info.month = grid.Rows[i].Cells["月"].Value.ToString(); info.eiId = grid.Rows[i].Cells["eiId"].Value.ToString(); info.pId = grid.Rows[i].Cells["pId"].Value.ToString(); info.number = grid.Rows[i].Cells["数量"].Value.ToString(); info.unitPrice = grid.Rows[i].Cells["单价"].Value.ToString(); info.money = grid.Rows[i].Cells["金额"].Value.ToString(); info.inputDate = grid.Rows[i].Cells["录入时间"].Value.ToString(); info.inputMan = grid.Rows[i].Cells["录入人"].Value.ToString(); info.assessor = grid.Rows[i].Cells["审核人"].Value.ToString(); info.checkupMan = grid.Rows[i].Cells["审批人"].Value.ToString(); info.convert = grid.Rows[i].Cells["折算系数"].Value.ToString(); info.isAuto = grid.Rows[i].Cells["自动还是手工"].Value.ToString(); info.remark = grid.Rows[i].Cells["备注"].Value.ToString(); ArrayList list = AlterBitumenDetachSql(info, tempDetachDt); foreach (string s in list) { sqlStr.Add(s); } } } else { for (int i = 0; i < grid.Rows.Count; i++) { if ((grid.Rows[i].Cells["Column1"].Value != null) && (grid.Rows[i].Cells["Column1"].Value.Equals(true))) //确定分配基数,分滩是否能确定设备 { DataTable tempDetachDt = new DataTable(); tempDetachDt.Columns.Add("pId"); tempDetachDt.Columns.Add("设备编号"); tempDetachDt.Columns.Add("eiId"); tempDetachDt.Columns.Add("工时"); if (grid.Rows[i].Cells["eiId"].Value.ToString().Trim().Equals("")) { tempDetachDt = DetachDt; } else { for (int j1 = 0; j1 < DetachDt.Rows.Count; j1++) { if (DetachDt.Rows[j1]["eiId"].ToString().Trim().Equals(grid.Rows[i].Cells["eiId"].Value.ToString().Trim())) { DataRow row = tempDetachDt.NewRow(); row["pid"] = DetachDt.Rows[j1]["pid"].ToString(); row["设备编号"] = DetachDt.Rows[j1]["设备编号"].ToString(); row["eiId"] = DetachDt.Rows[j1]["eiId"].ToString(); row["工时"] = DetachDt.Rows[j1]["工时"].ToString(); tempDetachDt.Rows.Add(row); } } } /////////////////////////////////// alterBitumenExpenditureClass info = new alterBitumenExpenditureClass(); info.id = grid.Rows[i].Cells["Id"].Value.ToString(); info.ekId = grid.Rows[i].Cells["ekId"].Value.ToString(); info.enId = grid.Rows[i].Cells["enId"].Value.ToString(); info.ecId = grid.Rows[i].Cells["ecId"].Value.ToString(); info.expenditureDepict = grid.Rows[i].Cells["费用描述"].Value.ToString(); info.year = grid.Rows[i].Cells["年"].Value.ToString(); info.month = grid.Rows[i].Cells["月"].Value.ToString(); info.eiId = grid.Rows[i].Cells["eiId"].Value.ToString(); info.pId = grid.Rows[i].Cells["pId"].Value.ToString(); info.number = grid.Rows[i].Cells["数量"].Value.ToString(); info.unitPrice = grid.Rows[i].Cells["单价"].Value.ToString(); info.money = grid.Rows[i].Cells["金额"].Value.ToString(); info.inputDate = grid.Rows[i].Cells["录入时间"].Value.ToString(); info.inputMan = grid.Rows[i].Cells["录入人"].Value.ToString(); info.assessor = grid.Rows[i].Cells["审核人"].Value.ToString(); info.checkupMan = grid.Rows[i].Cells["审批人"].Value.ToString(); info.convert = grid.Rows[i].Cells["折算系数"].Value.ToString(); info.isAuto = grid.Rows[i].Cells["自动还是手工"].Value.ToString(); info.remark = grid.Rows[i].Cells["备注"].Value.ToString(); ArrayList list = AlterBitumenDetachSql(info, tempDetachDt); foreach (string s in list) { sqlStr.Add(s); } } } } if (sqlStr.Count > 0) { if (sqlHelperObj.ExecuteTransaction(sqlStr)) { return(true); } } return(false); }