// 向datatable中加行 // 向表中添加一行然后返回表用于放到逻辑层进行判断用以确定是存入费用表还是待摊费用表 private DataTable AddDateTable() { if ((!cmbEquipmentName.Text.Trim().Equals("")) && (!cmbEquipmentName.Text.Trim().Equals(""))) { bitumenExpenditureClass info = new bitumenExpenditureClass(); info = GetValueExpenditure(); DataRow row = tempDataTable.NewRow(); ExpenditureToDataRow(info, ref row); tempDataTable.Rows.Add(row); } else { bitumenWaitDetachExpenditureClass waitDetachInfo = new bitumenWaitDetachExpenditureClass(); waitDetachInfo = GetValueWaitDetachExpenditure(); DataRow row1 = tempDataTable.NewRow(); WaitDetachExpenditureToDataRow(waitDetachInfo, ref row1); tempDataTable.Rows.Add(row1); } return(tempDataTable); }
//窗体上的值装入实体类expenditureClass private bitumenWaitDetachExpenditureClass GetValueWaitDetachExpenditure() { bitumenWaitDetachExpenditureClass recInfo = new bitumenWaitDetachExpenditureClass(); 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.Text; recInfo.inputDate = dateTimePicker1.Value.ToString(); recInfo.inputMan = "测试"; recInfo.convert = cmbConvertQuotiety.Text; recInfo.remark = richTextRemark.Text; return(recInfo); }
/* * 方法名称:WaitDetachExpenditureToDataRow * 方法功能描述:实体类信息转换为DataRow * 参数: * * * 创建人:付中华 * 创建时间:2009-03-25 * * 修改人: * 修改时间: * 修改内容: * */ public void WaitDetachExpenditureToDataRow(bitumenWaitDetachExpenditureClass 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; }