public static BG_BudAppendix AddBG_BudAppendix(BG_BudAppendix bG_BudAppendix) { string sql = "INSERT BG_BudAppendix (BudID, APPath, ApName, ApTime)" + "VALUES (@BudID, @APPath, @ApName, @ApTime)"; sql += " ; SELECT @@IDENTITY"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@BudID", bG_BudAppendix.BudID), new SqlParameter("@APPath", bG_BudAppendix.APPath), new SqlParameter("@ApName", bG_BudAppendix.ApName), new SqlParameter("@ApTime", bG_BudAppendix.ApTime) }; string IdStr = DBUnity.ExecuteScalar(CommandType.Text, sql, para); int newId = Convert.ToInt32(IdStr); return GetBG_BudAppendixByAPID(newId); } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
protected void btn_Click(object sender, EventArgs e) { //检查文件是否存在 if (fup.HasFile == false)//HasFile用来检查FileUpload是否有指定文件 { lbl.Text = "* 文件不存在或者已移动、请您重新选择Doc文件 "; return; } lbl.Text = string.Empty; string fileName ="\\"+ fup.FileName; string savePath =Server.MapPath("~\\upload\\" + budid.ToString()); if (!Directory.Exists(savePath))//判断是否存在 { Directory.CreateDirectory(savePath); } savePath += common.SafeSql(fileName); fup.SaveAs(savePath); BG_BudAppendix bam = new BG_BudAppendix(); bam.BudID = budid; bam.ApTime = BGBudItemsManager.GetBudItemsByBudid(budid).BIStaTime; bam.ApName = common.SafeSql(Path.GetFileNameWithoutExtension(fup.FileName)); bam.APPath = savePath; if (BGBudAppendixManager.AddBudAppendix(bam)) { lbl.Text = "*添加成功"; repAnnexBind(budid); } else { lbl.Text = "*操作失败、请检查数据后重试"; } }
/// <summary> /// 添加预算项目附件信息 /// </summary> /// <returns>bool</returns> public static bool AddBudAppendix(BG_BudAppendix BudAppendix) { bool flag = false; try { string sqlStr = @"insert into BG_BudAppendix(BudID,APPath,ApName,ApTime) values(@BudID,@APPath,@ApName,@ApTime)"; SqlParameter[] Pars = new SqlParameter[]{ new SqlParameter("@BudID",BudAppendix.BudID), new SqlParameter("@APPath",BudAppendix.APPath), new SqlParameter("@ApName",BudAppendix.ApName), new SqlParameter("@ApTime",BudAppendix.ApTime) }; flag = DBUnity.ExecuteNonQuery(CommandType.Text, sqlStr, Pars) > 0; } catch (Exception ex) { flag = false; Log.WriteLog(ex.Message, "BGBudAppendixService--AddBudAppendix"); } return flag; }
public static BG_BudAppendix GetBG_BudAppendixByAPID(int aPID) { string sql = "SELECT * FROM BG_BudAppendix WHERE APID = @APID"; try { SqlParameter para = new SqlParameter("@APID", aPID); DataTable dt = DBUnity.AdapterToTab(sql, para); if(dt.Rows.Count > 0) { BG_BudAppendix bG_BudAppendix = new BG_BudAppendix(); bG_BudAppendix.APID = dt.Rows[0]["APID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["APID"]; bG_BudAppendix.BudID = dt.Rows[0]["BudID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["BudID"]; bG_BudAppendix.APPath = dt.Rows[0]["APPath"] == DBNull.Value ? "" : (string)dt.Rows[0]["APPath"]; bG_BudAppendix.ApName = dt.Rows[0]["ApName"] == DBNull.Value ? "" : (string)dt.Rows[0]["ApName"]; bG_BudAppendix.ApTime = dt.Rows[0]["ApTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["ApTime"]; return bG_BudAppendix; } else { return null; } } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
public static bool DeleteBG_BudAppendix(BG_BudAppendix bG_BudAppendix) { return DeleteBG_BudAppendixByAPID( bG_BudAppendix.APID ); }
public static bool ModifyBG_BudAppendix(BG_BudAppendix bG_BudAppendix) { string sql = "UPDATE BG_BudAppendix " + "SET " + "BudID = @BudID, " + "APPath = @APPath, " + "ApName = @ApName, " + "ApTime = @ApTime " + "WHERE APID = @APID"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@APID", bG_BudAppendix.APID), new SqlParameter("@BudID", bG_BudAppendix.BudID), new SqlParameter("@APPath", bG_BudAppendix.APPath), new SqlParameter("@ApName", bG_BudAppendix.ApName), new SqlParameter("@ApTime", bG_BudAppendix.ApTime) }; int t = DBUnity.ExecuteNonQuery(CommandType.Text, sql, para); if(t>0) { return true; } else { return false; } } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
public static bool ModifyBG_BudAppendix(BG_BudAppendix bG_BudAppendix) { return BG_BudAppendixService.ModifyBG_BudAppendix(bG_BudAppendix); }
public static bool DeleteBG_BudAppendix(BG_BudAppendix bG_BudAppendix) { return BG_BudAppendixService.DeleteBG_BudAppendix(bG_BudAppendix); }
public static BG_BudAppendix AddBG_BudAppendix(BG_BudAppendix bG_BudAppendix) { return BG_BudAppendixService.AddBG_BudAppendix(bG_BudAppendix); }
/// <summary> /// 查询指定一条预算项目附件信息 /// </summary> /// <param name="apid">预算项目附件ID</param> /// <returns>BGDepartment</returns> public static BG_BudAppendix GetBudAppendixByapid(int apid) { BG_BudAppendix BudAppendix = new BG_BudAppendix(); string sqlStr = "select * from BG_BudAppendix where APID={0}"; sqlStr = string.Format(sqlStr, apid); DataTable dt = DBUnity.AdapterToTab(sqlStr); if (dt.Rows.Count > 0) { BudAppendix.APID = (int)dt.Rows[0]["APID"]; BudAppendix.BudID = (int)dt.Rows[0]["BudID"]; BudAppendix.APPath = dt.Rows[0]["APPath"].ToString(); BudAppendix.ApName = dt.Rows[0]["ApName"].ToString(); BudAppendix.ApTime = (DateTime)dt.Rows[0]["ApTime"]; } return BudAppendix; }
/// <summary> /// 修改指定预算项目附件信息 /// </summary> /// <param name="BudAppendix">BGBudAppendix</param> /// <returns>bool</returns> public static bool UpdBudAppendix(BG_BudAppendix BudAppendix) { bool flag = false; try { string sqlStr = @"update from BG_BudAppendix set APID = @APID,BudID=@BudID,APPath=@APPath, ApName=@ApName,ApTime=@ApTime where APID = @APID"; SqlParameter[] Pars = new SqlParameter[]{ new SqlParameter("@APID",BudAppendix.APID), new SqlParameter("@BudID",BudAppendix.BudID), new SqlParameter("@APPath",BudAppendix.APPath), new SqlParameter("@ApName",BudAppendix.ApName), new SqlParameter("@ApTime",BudAppendix.ApTime) }; flag = DBUnity.ExecuteNonQuery(CommandType.Text, sqlStr, Pars) > 0; } catch (Exception ex) { flag = false; Log.WriteLog(ex.Message, "BGBudAppendixService--UpdBudAppendix"); } return flag; }
/// <summary> /// 修改指定预算项目附件信息 /// </summary> /// <param name="BudAppendix">BGBudAppendix</param> /// <returns>bool</returns> public static bool UpdBudAppendix(BG_BudAppendix BudAppendix) { return BGBudAppendixService.UpdBudAppendix(BudAppendix); }