public void CreateOfficialFile(OfficialFile officialFile) { using (SqlConnection connection = base.GetConnection()) { SqlCommand command = new SqlCommand("_OfficialFileUpdate", connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.AddWithValue("@Type", 0); command.Parameters.AddWithValue("@OfficialFileID", 0); command.Parameters.AddWithValue("@OfficialID", officialFile.OfficialID); command.Parameters.AddWithValue("@FileName", officialFile.FileName); command.Parameters.AddWithValue("@Title", officialFile.Title); connection.Open(); if (command.ExecuteNonQuery() <= 0) { throw new DataAccessException("Kh\x00f4ng thể th\x00eam h\x00ecnh ảnh"); } command.Dispose(); } }
public void CreateOfficialFile(OfficialFile officialFile) { new OfficialFileDAO().CreateOfficialFile(officialFile); }
public void UpdateOfficialFile(OfficialFile officialFile) { new OfficialFileDAO().UpdateOfficialFile(officialFile); }
private OfficialFile ReceiveHtml() { string path = Request.PhysicalApplicationPath.Replace(@"\", "/") + "/Upload/Official/Files/"; commonBSO commonBSO = new commonBSO(); string file_upload = commonBSO.UploadFile(file_attached, path, 180000000000); OfficialFile officialFile = new OfficialFile(); officialFile.OfficialFileID = (hddOfficialFileID.Value != "") ? Convert.ToInt32(hddOfficialFileID.Value) : 0; officialFile.OfficialID = Convert.ToInt32(hddOfficialID.Value); officialFile.Title = txtTitle.Text; officialFile.FileName = (file_upload != "") ? file_upload : hddFileName.Value; return officialFile; }
protected void btn_edit_Click(object sender, EventArgs e) { try { OfficialFile file = new OfficialFile(); file = ReceiveHtml(); OfficialFileBSO filesBSO = new OfficialFileBSO(); filesBSO.UpdateOfficialFile(file); ViewFiles(Convert.ToInt32(hddOfficialID.Value)); clientview.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
protected void btn_add_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(file_attached.FileName)) { ViewFiles(Convert.ToInt32(hddOfficialID.Value)); clientview.Text = "Chưa có file đính kèm"; } else { OfficialFile file = new OfficialFile(); file = ReceiveHtml(); OfficialFileBSO filesBSO = new OfficialFileBSO(); filesBSO.CreateOfficialFile(file); ViewFiles(Convert.ToInt32(hddOfficialID.Value)); clientview.Text = String.Format(Resources.StringAdmin.AddNewsSuccessful); } } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }