/// <summary> /// 得到一个对象实体 /// </summary> public LPWeb.Model.PointFolders GetModel(int FolderId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PointFolders.FolderId,PointFolders.Name,PointFolders.BranchId,PointFolders.Path,PointFolders.Enabled,PointFolders.ImportCount,PointFolders.LastImport,PointFolders.LoanStatus, Branches.Name AS BranchName from PointFolders LEFT OUTER JOIN Branches ON PointFolders.BranchId = Branches.BranchId "); strSql.Append(" where PointFolders.FolderId=@FolderId "); SqlParameter[] parameters = { new SqlParameter("@FolderId", SqlDbType.Int, 4) }; parameters[0].Value = FolderId; LPWeb.Model.PointFolders model = new LPWeb.Model.PointFolders(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["FolderId"].ToString() != "") { model.FolderId = int.Parse(ds.Tables[0].Rows[0]["FolderId"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["BranchId"].ToString() != "") { model.BranchId = int.Parse(ds.Tables[0].Rows[0]["BranchId"].ToString()); } model.BranchName = ds.Tables[0].Rows[0]["BranchName"].ToString(); model.Path = ds.Tables[0].Rows[0]["Path"].ToString(); if (ds.Tables[0].Rows[0]["Enabled"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true")) { model.Enabled = true; } else { model.Enabled = false; } } if (ds.Tables[0].Rows[0]["ImportCount"].ToString() != "") { model.ImportCount = int.Parse(ds.Tables[0].Rows[0]["ImportCount"].ToString()); } if (ds.Tables[0].Rows[0]["LastImport"].ToString() != "") { model.LastImport = DateTime.Parse(ds.Tables[0].Rows[0]["LastImport"].ToString()); } if (ds.Tables[0].Rows[0]["LoanStatus"].ToString() != "") { model.LoanStatus = int.Parse(ds.Tables[0].Rows[0]["LoanStatus"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LPWeb.Model.PointFolders model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PointFolders("); strSql.Append("Name,BranchId,Path,Enabled,ImportCount,LastImport,LoanStatus)"); strSql.Append(" values ("); strSql.Append("@Name,@BranchId,@Path,@Enabled,@ImportCount,@LastImport,@LoanStatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.NVarChar, 255), new SqlParameter("@BranchId", SqlDbType.Int, 4), new SqlParameter("@Path", SqlDbType.NVarChar, 255), new SqlParameter("@Enabled", SqlDbType.Bit, 1), new SqlParameter("@ImportCount", SqlDbType.SmallInt, 2), new SqlParameter("@LastImport", SqlDbType.DateTime), new SqlParameter("@LoanStatus", SqlDbType.SmallInt, 2) }; parameters[0].Value = model.Name; parameters[1].Value = model.BranchId; parameters[2].Value = model.Path; parameters[3].Value = model.Enabled; parameters[4].Value = model.ImportCount; parameters[5].Value = model.LastImport; parameters[6].Value = model.LoanStatus; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LPWeb.Model.PointFolders model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PointFolders set "); strSql.Append("FolderId=@FolderId,"); strSql.Append("Name=@Name,"); strSql.Append("BranchId=@BranchId,"); strSql.Append("Path=@Path,"); strSql.Append("Enabled=@Enabled,"); strSql.Append("ImportCount=@ImportCount,"); strSql.Append("LastImport=@LastImport,"); strSql.Append("LoanStatus=@LoanStatus"); strSql.Append(" where FolderId=@FolderId "); SqlParameter[] parameters = { new SqlParameter("@FolderId", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 255), new SqlParameter("@BranchId", SqlDbType.Int, 4), new SqlParameter("@Path", SqlDbType.NVarChar, 255), new SqlParameter("@Enabled", SqlDbType.Bit, 1), new SqlParameter("@ImportCount", SqlDbType.SmallInt, 2), new SqlParameter("@LastImport", SqlDbType.DateTime), new SqlParameter("@LoanStatus", SqlDbType.SmallInt, 2) }; parameters[0].Value = model.FolderId; parameters[1].Value = model.Name; parameters[2].Value = model.BranchId; parameters[3].Value = model.Path; parameters[4].Value = model.Enabled; parameters[5].Value = model.ImportCount; parameters[6].Value = model.LastImport; parameters[7].Value = model.LoanStatus; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
private void LoadControls() { this.tbxFolderName.Text = ""; this.tbxBranch.Text = ""; this.tbxImportCount.Text = ""; this.tbxLastImportDate.Text = ""; this.tbxPath.Text = ""; this.tbxEnabled.Text = ""; this.gridSyncLogList.DataSource = null; LPWeb.Model.PointFolders model = null; try { model = this.folderMgr.GePonitFolderModel(this.iFolderID); if (model == null) { return; } this.tbxFolderName.Text = model.Name; this.tbxBranch.Text = model.BranchName; this.tbxImportCount.Text = model.ImportCount.ToString(); if (model.LastImport != null) { this.tbxLastImportDate.Text = Convert.ToDateTime(model.LastImport).ToString("MM/dd/yyyy HH:mm:ss"); } this.tbxPath.Text = model.Path; this.tbxEnabled.Text = model.Enabled.ToString(); this.cbEnableAutoFileNaming.Checked = model.AutoNaming; if (model.PreFix != null) { this.txbPrefix.Text = model.PreFix.ToString(); } this.cbdigitsName.Checked = model.RandomFileNaming; if (model.FilenameLength != null) { this.txtdigits.Text = model.FilenameLength.ToString(); } #region Get sync log PointImportHistory importHistory = new PointImportHistory(); DataSet dsSyncLog = importHistory.GetList(" FileId IN(SELECT FileId FROM PointFiles WHERE FolderId =" + this.iFolderID.ToString() + ")"); this.gridSyncLogList.DataSource = dsSyncLog.Tables[0]; this.gridSyncLogList.DataBind(); #endregion } catch (Exception ex) { throw ex; } }