void deleteBranchEx() { Version v2 = new Version(); v2.version_id = b.start_id; if (!vd.SelectByID(ref v2)) { Response.Write("<script>alert('invalid argument.')</script>"); return; } while (true) { if (v2.version_id == 0) { break; } if (!vd.SelectByID(ref v2)) { break;//warnning } //warnning vd.Delete(ref v2); //remove files FileSystem.RemoveFolder(Server.MapPath("~/") + @"data\" + v2.warehouse_id.ToString() + @"\" + v2.version_id.ToString()); v2.version_id = v2.next_id; } bd.Delete(v2.branch_id); }
public Boolean Delete(SqlInt32 BranchID) { BranchDAL branchDAL = new BranchDAL(); if (branchDAL.Delete(BranchID)) { return(true); } else { this.Message = branchDAL.Message; return(false); } }
public bool DeleteBranch(Branch item) { return(branchDAL.Delete(item)); }
protected void createButton_Click(object sender, EventArgs e) { if (name.Value.Length == 0 || desc.Value.Length == 0) { //error Response.Write("<script>alert('invalid name or desc.');</script>"); return; } if (name.Value == "master") { Response.Write("<script>alert('invalid name.');</script>"); return; } Version v2 = new Version(); v2.version_name = name.Value; v2.description = desc.Value; v2.prev_id = v.version_id; v2.next_id = 0; v2.warehouse_id = v.warehouse_id; v2.user_id = v.user_id; v2.branch_id = 0;//warning if (!vd.Insert(ref v2)) { Response.Write("<script>alert('insert error 1.');</script>"); return; } Branch b = new Branch(); b.branch_name = name.Value; b.description = desc.Value; b.warehouse_id = v.warehouse_id; b.user_id = v.user_id; b.start_id = v2.version_id; b.end_id = 0; bd = new BranchDAL(); if (!bd.Insert(ref b)) { Response.Write("<script>alert('insert error 2.');</script>"); vd.Delete(ref v2); return; } v2.branch_id = b.branch_id; if (!vd.Update(ref v2)) { Response.Write("<script>alert('update error.');</script>"); vd.Delete(ref v2); bd.Delete(b.branch_id); return; } //create files if (!FileSystem.CopyFolder(Server.MapPath("~/") + @"data\" + v.warehouse_id.ToString() + @"\" + v.version_id.ToString(), Server.MapPath("~/") + @"data\" + v.warehouse_id.ToString() + @"\" + v2.version_id.ToString())) { vd.Delete(ref v2); bd.Delete(b.branch_id); Response.Write("<script>alert('file error.');</script>"); return; } Response.Write("<script>alert('create success.');</script>"); Response.Redirect("warehouse_page.aspx?vid=" + v.version_id.ToString() + "&wid=" + v.warehouse_id.ToString()); }
protected void createButton_Click(object sender, EventArgs e) { if (Session["user"] == null) { Response.Write("<script>alert('please login.');window.location.href='login.aspx';</script>"); return; } if (name.Value.Length == 0 || desc.Value.Length == 0) { Response.Write("<script>alert('emoty data');</script>"); return; } //create warehouse User u = Session["user"] as User; Warehouse w = new Warehouse(); WarehouseDAL wd = new WarehouseDAL(); w.user_id = u.user_id; w.warehouse_name = name.Value; w.warehouse_description = desc.Value; if (wd.Insert(ref w)) { } else { Response.Write("<script>alert('error: warehouse insert');</script>"); return; } //create first version Version v = new Version(); VersionDAL vd = new VersionDAL(); v.user_id = u.user_id; v.warehouse_id = w.warehouse_id; v.version_name = "master"; v.description = "master"; if (vd.Insert(ref v)) { w.master_version_id = v.version_id; } else { //delete warehouse wd.Delete(ref w); Response.Write("<script>alert('error: version insert');</script>"); return; } if (wd.Update(ref w)) { } else { //delete warehouse and version wd.Delete(ref w); vd.Delete(ref v); Response.Write("<script>alert('error: warehouse update');</script>"); return; } //insert branch Branch b = new Branch(); BranchDAL bd = new BranchDAL(); b.warehouse_id = w.warehouse_id; b.user_id = u.user_id; b.start_id = v.version_id; b.end_id = 0; b.branch_name = "master"; b.description = "master"; if (bd.Insert(ref b)) { } else { Response.Write("<script>alert('error: branch insert');</script>"); wd.Delete(ref w); vd.Delete(ref v); return; } v.branch_id = b.branch_id; if (!vd.Update(ref v)) { Response.Write("<script>alert('error: version update');</script>"); wd.Delete(ref w); vd.Delete(ref v); bd.Delete(b.branch_id); return; } //crete files if (FileSystem.CreateFolder(Server.MapPath("~/") + @"data\" + w.warehouse_id.ToString() + @"\" + v.version_id.ToString()) == false) { Response.Write("<script>alert('error: file error');</script>"); wd.Delete(ref w); vd.Delete(ref v); bd.Delete(b.branch_id); return; } //create success Response.Write("<script>alert('create success.');window.location.href='user_page.aspx?uid=" + u.user_id.ToString() + "';</script>"); }