override protected Boolean LoadData() { try { // Load Data For Page. DACategory daProductCat = new DACategory(); daProductCat.USP_Category_GetFullID(this.KeyID); fCategory.Value = daProductCat.fCategory.ToString(); fMetaTitle.Value = daProductCat.fMetaTitle.ToString(); fMetaDescription.Value = daProductCat.fMetaDescription.ToString(); fMetaKeywords.Value = daProductCat.fMetaKeywords.ToString(); // // Khi cần enabled cột nào //if (this.KeyID > 0) //{ // if (mode != Act.Clone) // fUserName.Enabled = false; // else // fUserName.Text = ""; //} } catch (Exception e) { ShowErrorMes("Lỗi hệ thống: " + e.ToString()); return(false); } return(true); }
override protected Boolean GetDataComboBox() { DACategory daCategory = new DACategory(); sCategory.DataSource = daCategory.USP_Category_GetDataForComboBox(); sCategory.DataBind(); return(true); }
public void TestTPTWhetherInsertToSubTypeCauseAutomaticallyInsertToBaseTypeBeforeHand() { var category = new DACategory { CategoryName = "test" }; using (var context = new DataAnnotationContext("DataAnnotation")) { context.Categories.Add(category); context.ProductOutOfStocks.Add(new DAProductOutOfStock {Category = category, LastDate = DateTime.Now}); context.SaveChanges(); } }
override protected int DeleteByID(int pID) { try { DACategory DACategory = new DACategory(); DACategory.USP_Category_Delete(pID); return(1); } catch { return(0); } }
protected override int ExecUpdate() { DACategory daCategory = new DACategory(); daCategory.fID = this.KeyID; daCategory.fMetaDescription = fMetaDescription.Value; daCategory.fMetaKeywords = fMetaDescription.Value; daCategory.fMetaTitle = fMetaTitle.Value; daCategory.USP_Category_UpdateSEO(); return(1); }
override protected int ExecUpdate() { // Update with ID = this.ID try { DACategory DACategory = CreateObjectFromPage(); DACategory.fID = this.KeyID; DACategory.USP_Category_Update(); return(1); } catch { return(0); } }
override protected Boolean GetDataComboBox() { try { DACategory daCategory = new DACategory(); fParentID.DataSource = daCategory.USP_Category_GetDataForComboBox(this.KeyID); fParentID.DataBind(); return(true); } catch (Exception ex) { ShowErrorMes("Lỗi hệ thống: " + ex.Message); return(false); } }
// GET /api/Category/{ID} public HttpResponseMessage Get(int ID) { Category category = new DACategory().selectOne(ID); if(category == null) return new HttpResponseMessage() { StatusCode = HttpStatusCode.ExpectationFailed, Content = new StringContent("Failed to read data.") }; var json = new JavaScriptSerializer(); string data = json.Serialize(category); return new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(data, Encoding.UTF8, "application/json") }; }
override protected Boolean GetDataComboBox() { try { DACategory daCategory = new DACategory(); fCategoryID.DataSource = daCategory.USP_Category_GetDataForComboBox(); fCategoryID.DataBind(); DARecordStatus daRecordStatus = new DARecordStatus(); fRecordStatusID.DataSource = daRecordStatus.USP_RecordStatus_GetComboBox_ByTableName("Article"); fRecordStatusID.DataBind(); return(true); } catch (Exception ex) { ShowErrorMes("Lỗi hệ thống: " + ex.Message); return(false); } }
public JsonResult search() { try { if (PValidateHeader(Request.Headers["Authorization"].ToString())) { DACategory category = new DACategory(PUser); ENResult result = category.search(); result.token = PCreateToken(); return(Json(result)); } else { return(PSecurityError()); } } catch (Exception ex) { return(PUnexpectedError(ex)); } }
override protected int ExecInsert() { try { DACategory DACategory = CreateObjectFromPage(); if (this.mode == ActParam.New) { DACategory.fID = DACategory.USP_GetKey(); this.KeyID = DACategory.fID; // --> Update new SessionID for continue edit. } else { DACategory.fID = 0; } DACategory.USP_Category_Insert(); return(1); } catch { return(0); } }
override protected Boolean LoadData() { try { // Load Data For Page. DACategory daCategory = new DACategory(); daCategory.USP_Category_GetFullID(this.KeyID); // fCategory.Value = daCategory.fCategory.ToString(); fParentID.Value = daCategory.fParentID.ToString(); fUrlRewrite.Value = daCategory.fUrlRewrite.ToString(); fImgLink.ImageUrl = "~" + daCategory.fImgLink.ToString(); fMetaTitle.Value = daCategory.fMetaTitle.ToString(); fMetaDescription.Value = daCategory.fMetaDescription.ToString(); fMetaKeywords.Value = daCategory.fMetaKeywords.ToString(); fTags.Value = daCategory.fTags.ToString(); fActive.Checked = daCategory.fActive; fPos.Value = daCategory.fPos.ToString(); // // Khi cần enabled cột nào //if (this.KeyID > 0) //{ // if (mode != Act.Clone) // fUserName.Enabled = false; // else // fUserName.Text = ""; //} } catch (Exception e) { ShowErrorMes("Lỗi hệ thống: " + e.ToString()); return(false); } return(true); }
public void TestTPHOfProductAndProductInStock() { var category = new DACategory { CategoryName = "test" }; using (var context = new DataAnnotationContext("DataAnnotation")) { context.Categories.Add(category); context.Products.Add(new DAProduct { ProductIdentity = 123, ProductName = "Product 1", CategoryId = category.CategoryId }); context.SaveChanges(); } using (var context = new DataAnnotationContext("DataAnnotation")) { var persistedCategory = context.Categories.FirstOrDefault(x => x.CategoryId == category.CategoryId); context.ProductInStocks.Add(new DAProductInStock { ProductIdentity = 2, ProductName = "Product 2", Remaining = 2, Category = persistedCategory }); context.SaveChanges(); } }
public JsonResult delete(int idCategory) { try { if (PValidateHeader(Request.Headers["Authorization"].ToString())) { uspGECategorySearch_Result data = new uspGECategorySearch_Result(); data.idCategory = idCategory; DACategory category = new DACategory(PUser); ENResult result = category.delete(data); result.token = PCreateToken(); return(Json(result)); } else { return(PSecurityError()); } } catch (Exception ex) { return(PUnexpectedError(ex)); } }
// POST /api/Category public HttpResponseMessage Post(Category category) { if(!ModelState.IsValid) return new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Failed to insert data. The model state is invalid: " + ModelState.ToString()) }; int categoryID = new DACategory().insert(category); if (categoryID == -1) return new HttpResponseMessage() { StatusCode = HttpStatusCode.ExpectationFailed, Content = new StringContent("Failed to insert data.") }; var json = new JavaScriptSerializer(); string data = json.Serialize(categoryID); return new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(data, Encoding.UTF8, "application/json") }; }
private DACategory CreateObjectFromPage() { // check DACategory daCategory = new DACategory(); // daCategory.fCategory = fCategory.Value.Trim(); daCategory.fParentID = Convert.ToInt32(fParentID.Value.Trim()); daCategory.fUrlRewrite = fUrlRewrite.Value.Trim(); HttpPostedFile file = inputFile.PostedFile; if (file != null && file.ContentLength > 0) { //Delete old file Utils.DeleteFile(fImgLink.ImageUrl, Server); daCategory.fImgLink = Utils.UploadImage(file, Server, "~/Media/Category"); } else { daCategory.fImgLink = fImgLink.ImageUrl.Replace("~", ""); } fImgLink.ImageUrl = "~" + daCategory.fImgLink; daCategory.fMetaTitle = fMetaTitle.Value.Trim(); daCategory.fMetaDescription = fMetaDescription.Value.Trim(); daCategory.fMetaKeywords = fMetaKeywords.Value.Trim(); daCategory.fTags = fTags.Value.Trim(); daCategory.fActive = fActive.Checked; daCategory.fPos = Convert.ToInt32(fPos.Value.Trim()); daCategory.fOperator = MySession.UserName; // return(daCategory); }
public CategoryBLL() { dal = new DACategory(); }