/// <summary> /// 根据ID返回 T_BudgetDetailEntity实体类 单笔资料 (预算明细) /// </summary> /// <param name="ID">ID ID</param> /// <returns>返回 T_BudgetDetailEntity实体类 ID为0则无记录</returns> public static T_BudgetDetailEntity T_BudgetDetailDisp(Int32 ID) { T_BudgetDetailEntity fam = new T_BudgetDetailEntity(); QueryParam qp = new QueryParam(); qp.PageIndex = 1; qp.PageSize = 1; qp.Where = string.Format(" Where {0}.{1} = {2}", "T_BudgetDetail", "ID", ID); int RecordCount = 0; List<T_BudgetDetailEntity> lst = T_BudgetDetailList(qp, out RecordCount); if (RecordCount > 0) { fam = lst[0]; } return fam; }
/// <summary> /// 初始化数据 /// </summary> /// <param name="ut"></param> private void OnStartData(T_BudgetDetailEntity ut) { ProjID_Input.Text = ProjID_Disp.Text = ut.ProjID.ToString(); EquipmentName_Input.Text = EquipmentName_Disp.Text = ut.EquipmentName.ToString(); BudgetRevenue_Input.Text = BudgetRevenue_Disp.Text = ut.BudgetRevenue.ToString(); Measurement_Input.Text = Measurement_Disp.Text = ut.Measurement.ToString(); BudgetPrice_Input.Text = BudgetPrice_Disp.Text = ut.BudgetPrice.ToString(); BudgetNumber_Input.Text = BudgetNumber_Disp.Text = ut.BudgetNumber.ToString(); BudgetExpenditure_Input.Text = BudgetExpenditure_Disp.Text = ut.BudgetExpenditure.ToString(); BalanceAmount_Input.Text = BalanceAmount_Disp.Text = ut.BalanceAmount.ToString(); Supplier_Input.Text = Supplier_Disp.Text = ut.Supplier.ToString(); Remark_Input.Text = Remark_Disp.Text = ut.Remark.ToString(); Sort_Input.Text = Sort_Disp.Text = ut.Sort.ToString(); }
/// <summary> /// 初始化数据 /// </summary> /// <param name="ut"></param> private void OnStartData(T_BudgetDetailEntity ut) { ProjID_Hidden.Value = ut.ProjID.ToString(); if (!ut.ProjID.Equals(0)) { ProjID_Disp.Text = BusinessFacadeShanlitech_Location.GetProjectBudgetFormat(BusinessFacadeShanlitech_Location.T_ProjectBudgetDisp(ut.ProjID)); } EquipmentName_Input.Text = EquipmentName_Disp.Text = ut.EquipmentName.ToString(); BudgetRevenue_Input.Text = BudgetRevenue_Disp.Text = ut.BudgetRevenue.ToString(); Measurement_Input.Text = Measurement_Disp.Text = ut.Measurement.ToString(); BudgetPrice_Input.Text = BudgetPrice_Disp.Text = ut.BudgetPrice.ToString(); BudgetNumber_Input.Text = BudgetNumber_Disp.Text = ut.BudgetNumber.ToString(); //BudgetExpenditure_Input.Text = BudgetExpenditure_Disp.Text = ut.BudgetExpenditure.ToString(); BalanceAmount_Input.Text = BalanceAmount_Disp.Text = ut.BalanceAmount.ToString(); Supplier_Input.Text = Supplier_Disp.Text = ut.Supplier.ToString(); Remark_Input.Text = Remark_Disp.Text = ut.Remark.ToString(); }
/// <summary> /// 新增/删除/修改 T_BudgetDetailEntity (预算明细) /// </summary> /// <param name="fam">T_BudgetDetailEntity实体类</param> /// <returns>-1:存储过程执行失败,-2:存在相同的主键,Insert:返回插入自动ID,Update:返回更新记录数,Delete:返回删除记录数</returns> public static Int32 T_BudgetDetailInsertUpdateDelete(T_BudgetDetailEntity fam) { return DataProvider.Instance().T_BudgetDetailInsertUpdateDelete(fam); }
protected void Button2_Click(object sender, EventArgs e) { string Checkbox_Value = (string)Common.sink("Checkbox", MethodType.Post, 2000, 1, DataType.Str); string[] Checkbox_Value_Array = Checkbox_Value.Split(','); Int32 IDX = 0; for (int i = 0; i < Checkbox_Value_Array.Length; i++) { if (Int32.TryParse(Checkbox_Value_Array[i], out IDX)) { T_BudgetDetailEntity et = new T_BudgetDetailEntity(); et.DataTable_Action_ = DataTable_Action.Delete; et.ID = IDX; BusinessFacadeShanlitech_Location.T_BudgetDetailInsertUpdateDelete(et); } } EventMessage.MessageBox(1, "批量删除成功", string.Format("批量删除({0})成功!", Checkbox_Value), Icon_Type.OK, Common.GetHomeBaseUrl("default.aspx")); }
/// <summary> /// 将记录集转为T_BudgetDetailEntity实体类 (预算明细) /// </summary> /// <param name="dr">记录集</param> /// <param name="Fileds">字段名列表</param> /// <returns>T_BudgetDetailEntity</returns> protected T_BudgetDetailEntity PopulateT_BudgetDetailEntity(IDataReader dr, Dictionary<string, string> Fileds) { T_BudgetDetailEntity nc = new T_BudgetDetailEntity(); if (Fileds.ContainsKey("ID") && !Convert.IsDBNull(dr["ID"])) nc.ID = Convert.ToInt32(dr["ID"]); // ID if (Fileds.ContainsKey("ProjID") && !Convert.IsDBNull(dr["ProjID"])) nc.ProjID = Convert.ToInt32(dr["ProjID"]); // 所属项目 if (Fileds.ContainsKey("EquipmentName") && !Convert.IsDBNull(dr["EquipmentName"])) nc.EquipmentName = Convert.ToString(dr["EquipmentName"]).Trim(); // 器材名称 if (Fileds.ContainsKey("BudgetRevenue") && !Convert.IsDBNull(dr["BudgetRevenue"])) nc.BudgetRevenue = Convert.ToDouble(dr["BudgetRevenue"]); // 预算收入 if (Fileds.ContainsKey("Measurement") && !Convert.IsDBNull(dr["Measurement"])) nc.Measurement = Convert.ToString(dr["Measurement"]).Trim(); // 计量单位 if (Fileds.ContainsKey("BudgetPrice") && !Convert.IsDBNull(dr["BudgetPrice"])) nc.BudgetPrice = Convert.ToDouble(dr["BudgetPrice"]); // 预算单价 if (Fileds.ContainsKey("BudgetNumber") && !Convert.IsDBNull(dr["BudgetNumber"])) nc.BudgetNumber = Convert.ToInt32(dr["BudgetNumber"]); // 预算数量 if (Fileds.ContainsKey("BudgetExpenditure") && !Convert.IsDBNull(dr["BudgetExpenditure"])) nc.BudgetExpenditure = Convert.ToDouble(dr["BudgetExpenditure"]); // 预算支出 if (Fileds.ContainsKey("BalanceAmount") && !Convert.IsDBNull(dr["BalanceAmount"])) nc.BalanceAmount = Convert.ToDouble(dr["BalanceAmount"]); // 经费余额 if (Fileds.ContainsKey("Supplier") && !Convert.IsDBNull(dr["Supplier"])) nc.Supplier = Convert.ToString(dr["Supplier"]).Trim(); // 供货单位 if (Fileds.ContainsKey("Remark") && !Convert.IsDBNull(dr["Remark"])) nc.Remark = Convert.ToString(dr["Remark"]).Trim(); // 备注 if (Fileds.ContainsKey("Sort") && !Convert.IsDBNull(dr["Sort"])) nc.Sort = Convert.ToInt32(dr["Sort"]); // 递增排序 return nc; }
/// <summary> /// 新增/删除/修改 T_BudgetDetailEntity (预算明细) /// </summary> /// <param name="fam">T_BudgetDetail实体类</param> /// <returns>-1:存储过程执行失败,-2:存在相同的主键,Insert:返回插入自动ID,Update:返回更新记录数,Delete:返回删除记录数</returns> public abstract Int32 T_BudgetDetailInsertUpdateDelete(T_BudgetDetailEntity fam);
/// <summary> /// 批量导入预算明细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnImportYSMX_Click(object sender, EventArgs e) { #region 检查上传文件格式是否正确 sys_UserTable curruser = UserData.GetUserDate; if (curruser.U_LoginName != null) { try { string creatPath = System.Web.HttpContext.Current.Server.MapPath("/FJ/YSMX").ToString(); if (!System.IO.Directory.Exists(creatPath)) { System.IO.Directory.CreateDirectory(creatPath); } } catch { throw; } } string strBaseLocation = Server.MapPath("/FJ/YSMX/"); string LocalFile = string.Empty;//本地文件名 string newfilename = DateTime.Now.ToString("yyyyMMddHHmmss"); string clientFilename = System.IO.Path.GetFileName(Filename.PostedFile.FileName); string serverFilename = ""; if (clientFilename == "") { EventMessage.Show(this.Page, "您上传的文件名不能为空!"); return; } if (clientFilename.ToLower().IndexOf(".xlsx") > 0) { serverFilename = ".xlsx"; } else { if (clientFilename.ToLower().IndexOf(".xls") > 0 && clientFilename.EndsWith("xls")) { serverFilename = ".xls"; } else { EventMessage.Show(this.Page, "您上传的文件必须为Excel文件!"); return; } } //设置文件名 LocalFile = strBaseLocation + newfilename + serverFilename; //保存文件 Filename.PostedFile.SaveAs(LocalFile); #endregion #region 数据导入库中 StringBuilder msg = new StringBuilder(); DataTable dt = new DataTable(); if (this.Filename.HasFile) { try { //读取Excel资料流并转换成DataTable dt = ExcelHelper.RenderDataTableFromExcel(this.Filename.FileContent, 0, 4); int success = 0; //成功的个数 int unsucess = 0;//失败的个数 int t_proID=0; bool IsInsertTPro = true; foreach (DataRow dr in dt.Rows) { try { #region 给个字段赋值 string lbmc = ""; string kmmc = ""; string xmmc = ""; //判断此项目是否已添加到项目预算表中 if (!dr[2].ToString().Trim().Equals("")) { lbmc = BusinessFacadeShanlitech_Location.GetIDByClassName(dr[0].ToString().Trim()).ToString(); //类别ID kmmc = BusinessFacadeShanlitech_Location.GetIDBySubjectName(dr[1].ToString().Trim()).ToString();//科目名称 xmmc = BusinessFacadeShanlitech_Location.GetIDByProjectName(dr[2].ToString().Trim()).ToString();//项目名称 IsInsertTPro = true; } else { IsInsertTPro = false; } float xmje; if (dr[3].ToString().Trim().Length > 0) { xmje = float.Parse(dr[3].ToString().Trim());//项目金额 } else { xmje = 0f;//项目金额 } string qcmc = dr[4].ToString().Trim();//器材名称 float yssr; if (dr[5].ToString().Trim().Length > 0) { yssr = float.Parse(dr[5].ToString().Trim());//预算收入 } else { yssr = 0f;//预算收入 } string jldw = dr[6].ToString().Trim();//计量单位 float dj; if (dr[7].ToString().Trim().Length > 0) { dj = float.Parse(dr[7].ToString().Trim());//单价 } else { dj = 0f;//单价 } int sl; if (dr[8].ToString().Trim().Length > 0) { sl = Convert.ToInt32(dr[8].ToString().Trim());//数量 } else { sl = 0;//数量 } float je; if (dr[9].ToString().Trim().Length > 0) { je = float.Parse(dr[9].ToString().Trim());//金额 } else { je = 0f;//金额 } string ghdw = dr[10].ToString().Trim();//供货单位 float ysye; if (dr[11].ToString().Trim().Length > 0) { ysye = float.Parse(dr[11].ToString().Trim());//预算余额 } else { ysye = 0f;//预算余额 } string bz = dr[12].ToString().Trim();//备注 #endregion #region 项目预算表插入数据 if (IsInsertTPro) { T_ProjectBudgetEntity t_proEntity = new T_ProjectBudgetEntity(); t_proEntity.DataTable_Action_ = DataTable_Action.Insert; t_proEntity.ClassNO = lbmc; t_proEntity.SubjectNO = kmmc; t_proEntity.ProjectNO = xmmc; t_proEntity.BudgetExpenditure = xmje; t_proID = BusinessFacadeShanlitech_Location.T_ProjectBudgetInsertUpdateDelete(t_proEntity); } #endregion #region 预算明细表插入数据 if (t_proID > 0) { T_BudgetDetailEntity t_budEntity = new T_BudgetDetailEntity(); t_budEntity.DataTable_Action_ = DataTable_Action.Insert; t_budEntity.ProjID = t_proID; t_budEntity.EquipmentName = qcmc; t_budEntity.BudgetRevenue = yssr; t_budEntity.Measurement = jldw; t_budEntity.BudgetPrice = dj; t_budEntity.BudgetNumber = sl; t_budEntity.BudgetExpenditure = je; t_budEntity.Supplier = ghdw; t_budEntity.BalanceAmount = ysye; t_budEntity.Remark = bz; int t_budID = BusinessFacadeShanlitech_Location.T_BudgetDetailInsertUpdateDelete(t_budEntity); if (t_budID > 0) { success += 1; } } #endregion } catch (Exception) { unsucess += 1; continue; } } msg.Append("添加成功个数:" + success + "!\\n"); msg.Append("添加失败个数:" + unsucess + "!\\n"); EventMessage.Show(this.Page, "操作结果:\\n" + msg.ToString(), "Default.aspx"); this.TabOptionWebControls1.SelectIndex = 1; } catch (Exception ex) { EventMessage.MessageBox(1, "操作无效", "上传文件导入数据失败!", Icon_Type.Error, Common.GetHomeBaseUrl("Default.aspx")); } } else { EventMessage.Show(this.Page, "此文件为空!"); } #endregion }