public ActionResult Delete( string idCat) { //viết code xóa ở đây ICatologieBAL itemBAL = new CatologieBAL(); try { itemBAL.Delete(new Guid(idCat)); } catch { return Json("error", JsonRequestBehavior.AllowGet); } return Json("ok", JsonRequestBehavior.AllowGet); }
public ActionResult Edit_view(Guid q) { ICatologieBAL itemBAL = new CatologieBAL(); int user = WebSecurity.CurrentUserId; //lay len danh sach danh muc List<Catologie> list = itemBAL.GetAllCatologiesByUserIDNotChilrend(user,q); string temp; foreach (Catologie item in list) { temp = string.Empty; if (item.Levels > 1) temp += "|"; for (int i = 1; i < item.Levels; i++) { temp = temp + "____"; } item.CatologyName = temp + " " + item.CatologyName; } ViewBag.ListCat = list; //neu catology guid rong thi xem nhu tao moi. neu co guild thi load du lieu len if (q != Guid.Empty) return PartialView("CauHinhCoBan/_PartialEditCauHinhCaiDat", itemBAL.GetCatologie(q)); return PartialView("CauHinhCoBan/_PartialEditCauHinhCaiDat", new Catologie()); }
//Kiểm tra trùng lắp dữ liệu private bool CheckItemCatologie(Catologie itemSP) { ICatologieBAL ItemBAL = new CatologieBAL(); return ItemBAL.CheckExistUser(itemSP); // return false; }
void ImageButtonSave_Click(object sender, EventArgs e) { PopulateControls(Step.Step3); if (!IsError) { ICatologieBAL itemBAL = new CatologieBAL(); using (DataSet ds = TempXMLHelper.ReadTemporayDataFromXml(Server.MapPath(ConfigurationManager.AppSettings["VALUE_PATH_XML_INFOTEACHING"] + "/" + SiteUtils.GetCurrentUserId().ToString() + ".xml"))) { if (ds.Tables.Count > 0) { DataTable dataTable = ds.Tables[0]; int count = 0; //Save data DateTime _dateUpdate = DateTime.Now; int maxPosition = itemBAL.GetMaxPositionByKindGuid(ConstantVariable.Catologys_Root_Value); foreach (DataRow row in dataTable.Rows) { try { //nếu có đã có tài khoản thì bỏ qua Catologie sv = new Catologie(); sv.CatologyName = row["hovaten"].ToString(); sv.Khoa = row["khoa"].ToString(); sv.Lop = row["lop"].ToString(); sv.Massv = row["Massv"].ToString(); sv.Role = "SinhVien"; sv.PassWord = "******"; //WebSecurity.CreateUserAndAccount(sv.Massv, "123"); //Roles.AddUserToRole(sv.Massv, "SinhVien"); //int userID= WebSecurity.GetUserId(sv.Massv); // Membership.GeneratePassword( sv.KindCatologyGuid = ConstantVariable.Catologys_Root_Value; sv.IsActive = true; //sv.UserID = userID; sv.Position = ++maxPosition; sv.ListStringToSort = ConstantVariable.ToBinary(sv.Position); Guid catGuid=Guid.Empty; Guid catRootGuid = Guid.Empty; catRootGuid = itemBAL.CreateImport(sv);//lưu gốc if (catRootGuid != Guid.Empty) { sv = new Catologie(); sv.IsNotDelete = true; sv.Massv = row["Massv"].ToString(); sv.CatologyName = "Danh mục chưa phân loại"; sv.ListStringToSort = ConstantVariable.ToBinary(sv.Position); sv.KindCatologyGuid = catRootGuid; sv.IsActive = true; catGuid = itemBAL.Save(sv);//lưu thư mục mặc định } if (catGuid != Guid.Empty) { count++; row["ErrorContent"] = "save successful!"; row["IsDongLoi"] = false; } else { row["ErrorContent"] = "không tạo được thư mục mặc định!"; row["IsDongLoi"] = true; continue; } } catch (Exception ex) { row["ErrorContent"] = ex; row["IsDongLoi"] = true; } } ErrorMessage(false, "Lưu thành công " + count.ToString() + " record!"); GridViewSaveOK.DataSource = dataTable; GridViewSaveOK.DataBind(); } } } }
//Kiểm tra trùng lắp dữ liệu private bool CheckItemCatologie(Catologie itemSP) { //kiểm tra tồn tại trong bảng user chưa ICatologieBAL ItemBAL = new CatologieBAL(); return ItemBAL.CheckExistUser(itemSP); //return false; }